-
Type:
Problem report
-
Resolution: Unresolved
-
Priority:
Trivial
-
None
-
Affects Version/s: 7.4.12, 8.0.0beta2
-
Component/s: Frontend (F)
-
None
-
Environment:Zabbix 7.4.12
Official Docker image: zabbix/zabbix-web-nginx-pgsql:alpine-7.4.12
PHP 8.5.8
PostgreSQL 17.9 with TimescaleDB 2.26.4
Browser: Chromium-based
Steps to reproduce:
1. Run Zabbix 7.4.12 using the official `zabbix/zabbix-web-nginx-pgsql:alpine-7.4.12` image with PHP 8.5.
2. Monitor two hosts with numeric items created through low-level discovery.
3. Ensure the hosts do not expose exactly the same items, for example:
- host A: `Service1`, `Service2`;
- host B: `Service1`, `Service3`.
4. Create a dashboard and add a *Top items* widget.
5. Select the host group containing both hosts.
6. Select the items using a wildcard pattern or an item tag.
7. Select the horizontal layout and save the dashboard.
Result:
The sparse matrix is rendered, including empty cells for missing host/item intersections, but repeated PHP deprecation messages are displayed:
Using null as the key parameter for array_key_exists() is deprecated, use an empty string instead [zabbix.php:17 → require_once() → ZBase->run() → ZBase->processRequest() → CController->run() → Widgets\TopItems\Actions\WidgetView->doAction() → Widgets\TopItems\Actions\WidgetView->getData() → Widgets\TopItems\Actions\WidgetView::makeColumnizedTable() → array_key_exists() in widgets/topitems/actions/WidgetView.php:441]
The same diagnostic is emitted at line 442 for sparkline data.
The affected code in `ui/widgets/topitems/actions/WidgetView.php` passes a nullable item ID to `array_key_exists()`:
$itemid = $itemids[$hostid] ?? null; $value = array_key_exists($itemid, $db_values) ? $db_values[$itemid] : null; $sparkline_value = array_key_exists($itemid, $db_sparkline_values) ? $db_sparkline_values[$itemid] : null;
The same code is present in the official `release/7.4` and `master` branches.
Expected:
- Missing host/item intersections are displayed as empty cells.
- No PHP warning or deprecation is emitted.
- Hosts and LLD-created items continue to appear and disappear dynamically.
Suggested patch
--- a/ui/widgets/topitems/actions/WidgetView.php
+++ b/ui/widgets/topitems/actions/WidgetView.php
@@ -439,6 +439,9 @@
foreach ($hostids as $hostid) {
$itemid = $itemids[$hostid] ?? null;
- $value = array_key_exists($itemid, $db_values) ? $db_values[$itemid] : null;
- $sparkline_value = array_key_exists($itemid, $db_sparkline_values)
+ $value = $itemid !== null && array_key_exists($itemid, $db_values)
+ ? $db_values[$itemid]
+ : null;
+ $sparkline_value = $itemid !== null
+ && array_key_exists($itemid, $db_sparkline_values)
? $db_sparkline_values[$itemid]
: null;