Icinga / icingaweb2-module-elasticsearch

This module will not be updated by Icinga anymore. Please don't attempt to use it.
GNU General Public License v2.0
29 stars 9 forks source link

quick fix for "count(): Parameter must be an array or an object that … #43

Closed dolito closed 5 years ago

dolito commented 5 years ago

…implements Countable" in PHP 7.2

Bug: when the first handle will be executed and $this->handles is checked the first time, it is NULL, so PHP throws an error:

count(): Parameter must be an array or an object that implements Countable
#0 [internal function]: Icinga\Application\ApplicationBootstrap->Icinga\Application\{closure}(Integer, String, String, Integer, Array)
#1 /usr/share/icingaweb2/modules/elasticsearch/library/vendor/iplx/Http/Client.php(180): count(NULL)
#2 /usr/share/icingaweb2/modules/elasticsearch/library/vendor/iplx/Http/Client.php(195): iplx\Http\Client->executeHandle(Object(iplx\Http\Handle))
#3 /usr/share/icingaweb2/modules/elasticsearch/library/Elasticsearch/Query.php(147): iplx\Http\Client->send(Object(iplx\Http\Request), Array)
#4 /usr/share/icingaweb2/modules/elasticsearch/library/Elasticsearch/Query.php(178): Icinga\Module\Elasticsearch\Query->execute()
#5 /usr/share/icingaweb2/modules/elasticsearch/application/controllers/EventsController.php(106): Icinga\Module\Elasticsearch\Query->fetchAll()
#6 /usr/share/icingaweb2/library/vendor/Zend/Controller/Action.php(507): Icinga\Module\Elasticsearch\Controllers\EventsController->indexAction()
#7 /usr/share/php/Icinga/Web/Controller/Dispatcher.php(76): Zend_Controller_Action->dispatch(String)
#8 /usr/share/icingaweb2/library/vendor/Zend/Controller/Front.php(937): Icinga\Web\Controller\Dispatcher->dispatch(Object(Icinga\Web\Request), Object(Icinga\Web\Response))
#9 /usr/share/php/Icinga/Application/Web.php(300): Zend_Controller_Front->dispatch(Object(Icinga\Web\Request), Object(Icinga\Web\Response))
#10 /usr/share/php/Icinga/Application/webrouter.php(104): Icinga\Application\Web->dispatch()
#11 /usr/share/icingaweb2/public/index.php(4): require_once(String)
#12 {main}

Env: on default Ubuntu 18.04 with icinga2, icingaweb2 und php-fpm (7.2.15) (all defaults)

Sev: critical

Solution:

Other solutions (not tested)

dolito commented 5 years ago

fixes #38

lippserd commented 5 years ago

Hi,

Thanks for your PR. Much appreciated 👍

I pushed a fix which makes handles an array by default.

Best, Eric