Hey Guys,
When I just updated my Ubuntu server with Zabbix 7.4.3 to Zabbix 7.4.4 I found an error on the CGraphHelper widget as below.
With a little help from GPT I changed the code of CGraphHelper.php between lines 305 and 306.
From:
To:
This cleared the error for me on the webpage.
Hope this gives you enough feedback for a new minor version of the CGraphHelper.php
Regards!
When I just updated my Ubuntu server with Zabbix 7.4.3 to Zabbix 7.4.4 I found an error on the CGraphHelper widget as below.
- Undefined array key "key_" [zabbix.php:17 → require_once() → ZBase->run() → ZBase->processRequest() → CController->run() → Widgets\SvgGraph\Actions\WidgetView->doAction() → Widgets\SvgGraph\Includes\CSvgGraphHelper::get() → CGraphHelper::calculateMetricsDelay() → CGraphHelper::getItemMaxDelay() in include/classes/helpers/CGraphHelper.php:306]
- preg_match(): Passing null to parameter #2 ($subject) of type string is deprecated [zabbix.php:17 → require_once() → ZBase->run() → ZBase->processRequest() → CController->run() → Widgets\SvgGraph\Actions\WidgetView->doAction() → Widgets\SvgGraph\Includes\CSvgGraphHelper::get() → CGraphHelper::calculateMetricsDelay() → CGraphHelper::getItemMaxDelay() → preg_match() in include/classes/helpers/CGraphHelper.php:306]
- Undefined array key "key_" [zabbix.php:17 → require_once() → ZBase->run() → ZBase->processRequest() → CController->run() → Widgets\SvgGraph\Actions\WidgetView->doAction() → Widgets\SvgGraph\Includes\CSvgGraphHelper::get() → CGraphHelper::calculateMetricsDelay() → CGraphHelper::getItemMaxDelay() in include/classes/helpers/CGraphHelper.php:306]
- preg_match(): Passing null to parameter #2 ($subject) of type string is deprecated [zabbix.php:17 → require_once() → ZBase->run() → ZBase->processRequest() → CController->run() → Widgets\SvgGraph\Actions\WidgetView->doAction() → Widgets\SvgGraph\Includes\CSvgGraphHelper::get() → CGraphHelper::calculateMetricsDelay() → CGraphHelper::getItemMaxDelay() → preg_match() in include/classes/helpers/CGraphHelper.php:306]
From:
Code:
/**
* Returns the maximum item update interval based on the values of the "type" and "delay" fields.
* Returns NULL if the item type does not support an update interval or if an error occurred during calculation.
*
* @param array $item
*
* @return int|float|null
*/
private static function getItemMaxDelay(array $item): int|float|null {
if (($item['type'] == ITEM_TYPE_ZABBIX_ACTIVE && preg_match('/^(event)?log(rt)?\[/', $item['key_']))
Code:
/**
* Returns the maximum item update interval based on the values of the "type" and "delay" fields.
* Returns NULL if the item type does not support an update interval or if an error occurred during calculation.
*
* @param array $item
*
* @return int|float|null
*/
private static function getItemMaxDelay(array $item): int|float|null {
// Guard against empty or missing key_
if (!isset($item['key_']) || $item['key_'] === null || $item['key_'] === '') {
return 0; // of: continue; afhankelijk van de loop/verwachte semantics
}
// cast extra definition:
$subject = (string)$item['key_'];
if (($item['type'] == ITEM_TYPE_ZABBIX_ACTIVE && preg_match('/^(event)?log(rt)?\[/', $subject, $m))
Hope this gives you enough feedback for a new minor version of the CGraphHelper.php
Regards!
Comment