Skip to content

Commit 8e28f7f

Browse files
dwmThomas-Gelf
authored andcommitted
Avoid failing when attempting to render NULL column-set
PHP 7.2 is stricter about invoking count() with parameters which are not countable: https://secure.php.net/manual/en/migration72.incompatible.php This case is triggered in QueryBasedTable, for example when reviewing the Activity Log: count(): Parameter must be an array or an object that implements Countable (QueryBasedTable.php:115) #0 [internal function]: Icinga\Application\ApplicationBootstrap->Icinga\Application\{closure}(2, 'count(): Parame...', '/usr/share/icin...', 115, Array) Icinga#1 /usr/share/icingaweb2/modules/director/library/vendor/ipl/Web/Table/QueryBasedTable.php(115): count(NULL) Icinga#2 /usr/share/icingaweb2/modules/director/library/vendor/ipl/Html/BaseElement.php(133): dipl\Web\Table\QueryBasedTable->renderContent() Icinga#3 /usr/share/icingaweb2/modules/director/library/vendor/ipl/Html/Html.php(171): dipl\Html\BaseElement->render() Icinga#4 /usr/share/icingaweb2/modules/director/library/vendor/ipl/Html/BaseElement.php(105): dipl\Html\Html->render() Icinga#5 /usr/share/icingaweb2/modules/director/library/vendor/ipl/Html/BaseElement.php(133): dipl\Html\BaseElement->renderContent() Icinga#6 /usr/share/icingaweb2/modules/director/library/vendor/ipl/Html/Html.php(259): dipl\Html\BaseElement->render() Icinga#7 /usr/share/icingaweb2/modules/director/library/vendor/ipl/Zf1/SimpleViewRenderer.php(47): dipl\Html\Html->__toString() Icinga#8 /usr/share/icingaweb2/modules/director/library/vendor/ipl/Zf1/SimpleViewRenderer.php(66): dipl\Zf1\SimpleViewRenderer->render() Icinga#9 /usr/share/icingaweb2/library/vendor/Zend/Controller/Action/HelperBroker.php(272): dipl\Zf1\SimpleViewRenderer->postDispatch() Icinga#10 /usr/share/icingaweb2/library/vendor/Zend/Controller/Action.php(518): Zend_Controller_Action_HelperBroker->notifyPostDispatch() Icinga#11 /usr/share/php/Icinga/Web/Controller/Dispatcher.php(76): Zend_Controller_Action->dispatch('activitiesActio...') Icinga#12 /usr/share/icingaweb2/library/vendor/Zend/Controller/Front.php(937): Icinga\Web\Controller\Dispatcher->dispatch(Object(Icinga\Web\Request), Object(Icinga\Web\Response)) Icinga#13 /usr/share/php/Icinga/Application/Web.php(389): Zend_Controller_Front->dispatch(Object(Icinga\Web\Request), Object(Icinga\Web\Response)) Icinga#14 /usr/share/php/Icinga/Application/webrouter.php(109): Icinga\Application\Web->dispatch() Icinga#15 /usr/share/icingaweb2/public/index.php(4): require_once('/usr/share/php/...') Icinga#16 {main} Perhaps over-simplistically, this failure can be avoided by first checking the countability of the relevant value with isset().
1 parent 473bbd4 commit 8e28f7f

File tree

1 file changed

+2
-1
lines changed

1 file changed

+2
-1
lines changed

library/vendor/ipl/Web/Table/QueryBasedTable.php

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -110,7 +110,8 @@ abstract protected function prepareQuery();
110110

111111
public function renderContent()
112112
{
113-
if (count($this->getColumnsToBeRendered())) {
113+
$columns = $this->getColumnsToBeRendered();
114+
if (isset($columns) && count($columns)) {
114115
$this->generateHeader();
115116
}
116117
$this->fetchRows();

0 commit comments

Comments
 (0)