[ZBX-24633] Uncaught TypeError: array_key_exists(): Argument #2 ($array) must be of type array, null given in /usr/share/zabbix/graphs.php:722 Created: 2024 Jun 08  Updated: 2024 Oct 29  Resolved: 2024 Oct 29

Status: Closed
Project: ZABBIX BUGS AND ISSUES
Component/s: Frontend (F)
Affects Version/s: 6.4.15
Fix Version/s: 6.0.36rc1, 7.0.6rc1, 7.2.0beta1

Type: Problem report Priority: Minor
Reporter: Matthew Enger Assignee: Janis Freibergs
Resolution: Fixed Votes: 0
Labels: None
Remaining Estimate: Not Specified
Time Spent: 74h
Original Estimate: Not Specified

Issue Links:
Duplicate
is duplicated by ZBX-25212 Host Graphs with LLD items on "DataCo... Closed
is duplicated by ZBX-25254 Viewing host graphs at "DataCollectio... Closed
Team: Team C
Sprint: Prev.Sprint, S24-W28/29, S24-W30/31, S24-W32/33, S24-W34/35, S24-W38/39, S24-W40/41, S24-W42/43
Story Points: 1

 Description   

When clicking through the host graphs /graphs.php?context=host&page=4 it goes to a blank page. Looking at the php logs we get:

[Sat Jun 08 11:14:13.711280 2024] [php:warn] [pid 1305477] [client 103.51.114.32:53578] PHP Warning:  Undefined array key 9346 in /usr/share/zabbix/graphs.php on line 722, referer: http://removed.com.au/zabbix/graphs.php?context=host&page=3

[Sat Jun 08 11:14:13.711381 2024] [php:warn] [pid 1305477] [client 103.51.114.32:53578] PHP Warning:  Trying to access array offset on value of type null in /usr/share/zabbix/graphs.php on line 722, referer: http://removed.com.au/zabbix/graphs.php?context=host&page=3

[Sat Jun 08 11:14:13.711422 2024] [php:error] [pid 1305477] [client 103.51.114.32:53578] PHP Fatal error:  Uncaught TypeError: array_key_exists(): Argument #2 ($array) must be of type array, null given in /usr/share/zabbix/graphs.php:722\nStack trace:\n#0 {main}\n  thrown in /usr/share/zabbix/graphs.php on line 722, referer: http://removed.com.au/zabbix/graphs.php?context=host&page=3

I believe this is due to graphs referring to objects which have been removed as this zabbix instance has been upgraded multiple times.



 Comments   
Comment by Matthew Enger [ 2024 Aug 14 ]

I am unsure where this is up to, but this patch I came up with fixed the issue for me:

— graphs.php 2024-08-14 14:53:31.374152951 +1000
+++ /usr/share/zabbix/graphs.php 2024-08-14 14:49:16.937291087 +1000
@@ -735,7 +735,12 @@
}

foreach (array_column($item['graphs'], 'graphid') as $graphid) {

  • if (!array_key_exists('ts_delete', $data['graphs'][$graphid]['graphDiscovery'])) {
    + if (!is_array($data['graphs'][$graphid]['graphDiscovery'])) { + $graph_ts_delete = $data['graphs'][$graphid]['graphDiscovery']['ts_delete']; + $data['graphs'][$graphid]['graphDiscovery']['ts_delete'] = ($graph_ts_delete > 0) + ? min($ts_delete, $graph_ts_delete) + : $ts_delete; + }

    else if (!array_key_exists('ts_delete', $data['graphs'][$graphid]['graphDiscovery']))

    { $data['graphs'][$graphid]['graphDiscovery']['ts_delete'] = $ts_delete; }

    else {

Comment by Janis Freibergs [ 2024 Oct 25 ]

Available in versions:

Generated at Sat May 10 07:27:21 EEST 2025 using Jira 9.12.4#9120004-sha1:625303b708afdb767e17cb2838290c41888e9ff0.