#1050341 zabbix-frontend-php: Graphs can not be created or updated

#1050341#5
Date:
2023-08-23 12:00:36 UTC
From:
To:
Hello,
when creating or updating a graph an error is displayed and the configured items for this graph are vanished (list of items is emty).

I opened an graph "some name for graph" with two items configured and just clicked the "Update" button without any changes, then the following error
message is displayed and the list of configured item is displayed as empty:

== error message ==
Cannot update graph

- json_decode() expects parameter 1 to be string, array given [graphs.php:94 -> json_decode() in graphs.php:94]
- array_key_exists() exspects parameter 2 to be array, null given [graphs.php:96 -> array_key_exists() in graphs.php:96]
- json_decode() expects parameter 1 to be string, array given [graphs.php:94 -> json_decode() in graphs.php:94]
- array_key_exists() exspects parameter 2 to be array, null given [graphs.php:96 -> array_key_exists() in graphs.php:96]
- Missing items for graphs "some name for graph".
== error message ==

I worked around this error with patching the file /usr/share/zabbix/graphs.php:

== patch to workaround ==
# diff -u /usr/share/zabbix/graphs.php_1:4.0.4+dfsg-1+deb10u1 /usr/share/zabbix/graphs.php
--- /usr/share/zabbix/graphs.php_1:4.0.4+dfsg-1+deb10u1 2023-04-11 20:50:56.000000000 +0200
+++ /usr/share/zabbix/graphs.php        2023-08-22 10:22:54.162756296 +0200
@@ -91,7 +91,7 @@

 $gitems = [];
 foreach (getRequest('items', []) as $item) {
-       $gitem = json_decode($item, true);
+       $gitem = json_decode(json_encode($item), true);

        if ((array_key_exists('itemid', $gitem) && ctype_digit($gitem['itemid']))
                        && (array_key_exists('type', $gitem) && ctype_digit($gitem['type']))
== patch to workaround ==

This may not the correct solution, but worked for this error.

BTW: I tried to create a new graph, but run into the identical error. Above patch worked too for creating new graphs.

Best Regards,
  Olaf Ohlenmacher

#1050341#10
Date:
2023-08-24 07:35:24 UTC
From:
To:
Hello Dmitry,
this error seems to be present in security update 1:4.0.4+dfsg-1+deb10u2 too. After installation of this security fix version the error reappears.

Best Regards
  Olaf Ohlenmacher