[ZBX-24683] problem.view PHP Fatal error: Uncaught TypeError: count() Created: 2024 Jun 19  Updated: 2024 Aug 01  Resolved: 2024 Jul 30

Status: Closed
Project: ZABBIX BUGS AND ISSUES
Component/s: API (A)
Affects Version/s: 7.0.0
Fix Version/s: 7.0.2rc2, 7.2.0alpha1

Type: Problem report Priority: Critical
Reporter: Damian Vermeulen Assignee: Alexander Vladishev
Resolution: Fixed Votes: 7
Labels: None
Remaining Estimate: Not Specified
Time Spent: 1h
Original Estimate: Not Specified
Environment:

Ubuntu 22
PHP 8.1.2
postgresql 16.3
Apache 2.4.52


Attachments: PNG File Scherm­afbeelding 2024-07-16 om 10.23.41-1.png     PNG File image-2024-07-24-21-04-46-578.png     PNG File screenshot.png    
Issue Links:
Causes
caused by ZBXNEXT-6974 Trigger top 100, extend filtering Closed
Duplicate
is duplicated by ZBX-24913 tr_events.php Event View PHP Fatal er... Closed
Team: Team C
Sprint: S24-W30/31
Story Points: 0.25

 Description   

Steps to reproduce:

  1. Open Zabbix Web UI
  2. Expand Monitoring
  3. Click on Problems (without any filters applied)

Result:
[php:error] [pid 562821] [client *.*.*.*:26666] PHP Fatal error:  Uncaught TypeError: count(): Argument #1 ($value) must be of type Countable|array, bool given in /usr/share/zabbix/include/classes/screens/CScreenProblem.php:286\nStack trace:\n#0 /usr/share/zabbix/include/classes/screens/CScreenProblem.php(824): CScreenProblem::getData()\n#1 /usr/share/zabbix/app/partials/monitoring.problem.view.html.php(73): CScreenProblem->get()\n#2 /usr/share/zabbix/include/classes/mvc/CPartial.php(104): include('...')\n#3 /usr/share/zabbix/include/classes/html/CObject.php(81): CPartial->getOutput()\n#4 /usr/share/zabbix/include/classes/html/CObject.php(61): unpack_object()\n#5 /usr/share/zabbix/include/classes/html/CTag.php(90): CObject->addItem()\n#6 /usr/share/zabbix/include/classes/html/CObject.php(68): CTag->addItem()\n#7 /usr/share/zabbix/include/classes/html/CTag.php(90): CObject->addItem()\n#8 /usr/share/zabbix/include/classes/html/CObject.php(68): CTag->addItem()\n#9 /usr/share/zabbix/include/classes/html/CTag.php(90): CObject->addItem()\n#10 /usr/share/zabbix/include/classes/html/CTag.php(47): CTag->addItem()\n#11 /usr/share/zabbix/include/classes/html/CHtmlPage.php(131): CTag->__construct()\n#12 /usr/share/zabbix/include/classes/html/CHtmlPage.php(98): CHtmlPage->toString()\n#13 /usr/share/zabbix/app/views/monitoring.problem.view.php(77): CHtmlPage->show()\n#14 /usr/share/zabbix/include/classes/mvc/CView.php(128): include('...')\n#15 /usr/share/zabbix/include/classes/core/ZBase.php(721): CView->getOutput()\n#16 /usr/share/zabbix/include/classes/core/ZBase.php(645): ZBase->processResponseFinal()\n#17 /usr/share/zabbix/include/classes/core/ZBase.php(228): ZBase->processRequest()\n#18 /usr/share/zabbix/include/config.inc.php(20): ZBase->run()\n#19 /usr/share/zabbix/zabbix.php(17): require_once('...')\n#20 {main}\n  thrown in /usr/share/zabbix/include/classes/screens/CScreenProblem.php on line 286
[Tue Jun 18 06:57:06.467750 2024] [php:warn] [pid 562821] [client *.*.*.*:26666] PHP Warning:  Undefined array key "file" in /usr/share/zabbix/include/classes/debug/CProfiler.php on line 376
[Tue Jun 18 06:57:06.467771 2024] [php:warn] [pid 562821] [client *.*.*.*:26666] PHP Warning:  Undefined array key "line" in /usr/share/zabbix/include/classes/debug/CProfiler.php on line 376
[Tue Jun 18 06:57:06.467784 2024] [php:warn] [pid 562821] [client *.*.*.*:26666] PHP Warning:  Cannot modify header information - headers already sent in /usr/share/zabbix/include/classes/helpers/CCookieHelper.php on line 54
[Tue Jun 18 06:57:06.467797 2024] [php:warn] [pid 562821] [client *.*.*.*:26666] PHP Warning:  Unknown: Failed to write session data using user defined save handler. (session.save_path: /var/lib/php/sessions) in Unknown on line 0
Expected:
The problem view to open up and display any problems that it might have retrieved.

Observations:

CScreenProblem.php
$problems = ($filter['show'] == TRIGGERS_OPTION_ALL)
        ? self::getDataEvents($options)
        : self::getDataProblems($options);
$end_of_data = (count($problems) < $limit + 1);
$problems seems to be returning a boolean instead of an array when getDataProblems is called. 



 Comments   
Comment by Yury Larin [ 2024 Jun 20 ]

I also have this issue.

$problems is Array, but count() thinks it is bool.

I change the line 286 to:

$end_of_data = (count((array)$problems) < $limit + 1);

And it fixes issue.

But it is possible the is another root of the problem...

However, I have error in the top on this page:

Invalid parameter "/eventid_till": a timestamp is too large.

 

Debian 12

php8.2

nginx

mariadb 10.11

Comment by Alexey [ 2024 Jul 01 ]

same problems

debian 12 arm64
PHP 8.3.8
nginx/1.22.1
MariaDB 10.11.6

Comment by Andrey [ 2024 Jul 04 ]

The same problem after upgrading zabbix instances from version 5.4 and 6.0 to 7.0, while those updated from version 6.4 do not have the same problem
OpenSUSE leap 15.6 
php8.0, php8.1, php8.2
nginx
postgresql 13,14,15

Comment by Geoffrey Timmerman [ 2024 Jul 16 ]

Same here after upgrade from 6.0 to 7.0 and also fixed it in the same way as mentioned by Hawk128. I wished I had found this earlier, it would have saved me some time

 

For people bumping into this; in detail you need to edit /usr/share/zabbix/include/classes/screens/CScreenProblem.php" and change line 286 from:

$end_of_data = (count($problems) < $limit + 1);

To this:

$end_of_data = (count((array)$problems) < $limit + 1);

 

The problem widget will then load but as mentioned you are still left with the error message "Invalid parameter "/eventid_till": a timestamp is too large.".


Hopefully this will be fixed properly soon.


  • Ubuntu 22.04.4 LTS
  • Apache 2.4
  • PHP 8.1.2
  • MySQL 8.0.37
Comment by Geoffrey Timmerman [ 2024 Jul 18 ]

We have just encountered another issue in one of our instances which is probably depending on this same issue reported here. We are unable to load alert instructions which normally popup when you hover over "duration". Also when clicking the timestamp next to a trigger, a blank page appears where normally you would see the trigger details.

The Apache error log shows a bunch of errors like:

[Thu Jul 18 09:57:33.508581 2024] [php:error] [pid 1312743] [client 10.73.95.90:50966] PHP Fatal error:  Uncaught TypeError: CArrayHelper::sort(): Argument #1 ($array) must be of type array, bool given, called in /usr/share/zabbix/app/controllers/CControllerHintboxEventlist.php on line 127 and defined in /usr/share/zabbix/include/classes/helpers/CArrayHelper.php:160\nStack trace:\n#0 /usr/share/zabbix/app/controllers/CControllerHintboxEventlist.php(127): CArrayHelper::sort()\n#1 /usr/share/zabbix/include/classes/mvc/CController.php(473): CControllerHintboxEventlist->doAction()\n#2 /usr/share/zabbix/include/classes/core/ZBase.php(642): CController->run()\n#3 /usr/share/zabbix/include/classes/core/ZBase.php(228): ZBase->processRequest()\n#4 /usr/share/zabbix/include/config.inc.php(20): ZBase->run()\n#5 /usr/share/zabbix/zabbix.php(17): require_once('...')\n#6 {main}\n  thrown in /usr/share/zabbix/include/classes/helpers/CArrayHelper.php on line 160
[Thu Jul 18 09:57:35.247622 2024] [php:error] [pid 1315986] [client 10.73.95.90:50969] PHP Fatal error:  Uncaught TypeError: CArrayHelper::sort(): Argument #1 ($array) must be of type array, bool given, called in /usr/share/zabbix/app/controllers/CControllerHintboxEventlist.php on line 127 and defined in /usr/share/zabbix/include/classes/helpers/CArrayHelper.php:160\nStack trace:\n#0 /usr/share/zabbix/app/controllers/CControllerHintboxEventlist.php(127): CArrayHelper::sort()\n#1 /usr/share/zabbix/include/classes/mvc/CController.php(473): CControllerHintboxEventlist->doAction()\n#2 /usr/share/zabbix/include/classes/core/ZBase.php(642): CController->run()\n#3 /usr/share/zabbix/include/classes/core/ZBase.php(228): ZBase->processRequest()\n#4 /usr/share/zabbix/include/config.inc.php(20): ZBase->run()\n#5 /usr/share/zabbix/zabbix.php(17): require_once('...')\n#6 {main}\n  thrown in /usr/share/zabbix/include/classes/helpers/CArrayHelper.php on line 160


[Thu Jul 18 09:53:27.311347 2024] [php:warn] [pid 1311462] [client 10.73.95.90:50605] PHP Warning:  foreach() argument must be of type array|object, bool given in /usr/share/zabbix/include/events.inc.php on line 360
[Thu Jul 18 09:53:27.311399 2024] [php:warn] [pid 1311462] [client 10.73.95.90:50605] PHP Warning:  foreach() argument must be of type array|object, bool given in /usr/share/zabbix/include/events.inc.php on line 376
[Thu Jul 18 09:53:27.311493 2024] [php:error] [pid 1311462] [client 10.73.95.90:50605] PHP Fatal error:  Uncaught TypeError: getEventsActionsIconsData(): Argument #1 ($events) must be of type array, bool given, called in /usr/share/zabbix/include/events.inc.php on line 394 and defined in /usr/share/zabbix/include/actions.inc.php:1087\nStack trace:\n#0 /usr/share/zabbix/include/events.inc.php(394): getEventsActionsIconsData()\n#1 /usr/share/zabbix/tr_events.php(175): make_small_eventlist()\n#2 {main}\n  thrown in /usr/share/zabbix/include/actions.inc.php on line 1087
[Thu Jul 18 09:53:27.311912 2024] [php:warn] [pid 1311462] [client 10.73.95.90:50605] PHP Warning:  Undefined array key "file" in /usr/share/zabbix/include/classes/debug/CProfiler.php on line 376
[Thu Jul 18 09:53:27.311934 2024] [php:warn] [pid 1311462] [client 10.73.95.90:50605] PHP Warning:  Undefined array key "line" in /usr/share/zabbix/include/classes/debug/CProfiler.php on line 376
[Thu Jul 18 09:53:27.311969 2024] [php:warn] [pid 1311462] [client 10.73.95.90:50605] PHP Warning:  Cannot modify header information - headers already sent in /usr/share/zabbix/include/classes/helpers/CCookieHelper.php on line 54
[Thu Jul 18 09:53:27.311993 2024] [php:warn] [pid 1311462] [client 10.73.95.90:50605] PHP Warning:  Unknown: Failed to write session data using user defined save handler. (session.save_path: /var/lib/php/sessions) in Unknown on line 0 

I have tried patching it but doesn't work as new errors come up. Most probably the root case is located in one or more database records since it is down to a timestamp being too large? Any suggestions on how to resolve this? 

Comment by Alexey [ 2024 Jul 23 ]

an update came out - but the problem was not fixed, moreover, the file was overwritten with a new one and it stopped working again. need to edit again

Comment by Geoffrey Timmerman [ 2024 Jul 24 ]

We have rolled back to the 6.0 snapshot we took before upgrade as our production environment needs to be secured. We will retry to upgrade again once we are sure the issue is resolved.

Comment by Alexey [ 2024 Jul 24 ]

in DashBoard the panel with intervals of problems does not open here, I think this is related.
Colleagues, can anyone confirm?

Comment by Geoffrey Timmerman [ 2024 Jul 24 ]

Hi silencess Check the Apache error log for Zabbix (on Debian based systems this is located in "/var/log/apache2/zabbix-error.log") to see what the error is about exactly. But we also encountered this issue with the duration (I've described this in a previous post above). Also clicking the timestamp on the left of the trigger shows a blank page instead of the trigger details. 

Comment by Alexander Vladishev [ 2024 Jul 26 ]

Available in versions:

Comment by Alexey [ 2024 Aug 01 ]

in 7.0.2 version - fixed

Generated at Sat Jun 14 00:28:00 EEST 2025 using Jira 9.12.4#9120004-sha1:625303b708afdb767e17cb2838290c41888e9ff0.