Package: zabbix-frontend-php
Version: 1:4.0.4+dfsg-1+deb10u1
Severity: normal
Tags: patch upstream


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


-- System Information:
Debian Release: 10.13
  APT prefers oldoldstable-updates
  APT policy: (500, 'oldoldstable-updates'), (500, 
'oldoldstable-proposed-updates'), (500, 'oldoldstable')
Architecture: amd64 (x86_64)

Kernel: Linux 4.19.0-25-amd64 (SMP w/12 CPU cores)
Locale: LANG=en_US.UTF-8, LC_CTYPE=en_US.UTF-8 (charmap=UTF-8), 
LANGUAGE=en_US:en (charmap=UTF-8)
Shell: /bin/sh linked to /bin/dash
Init: systemd (via /run/systemd/system)
LSM: AppArmor: enabled

Versions of packages zabbix-frontend-php depends on:
ii  fonts-dejavu-core               2.37-1
ii  php                             2:7.3+69
ii  php-bcmath                      2:7.3+69
ii  php-gd                          2:7.3+69
ii  php-mbstring                    2:7.3+69
ii  php-pgsql                       2:7.3+69
ii  php-xml                         2:7.3+69
ii  php7.0 [php]                    7.0.33-0+deb9u12
ii  php7.0-bcmath [php-bcmath]      7.0.33-0+deb9u12
ii  php7.0-gd [php-gd]              7.0.33-0+deb9u12
ii  php7.0-mbstring [php-mbstring]  7.0.33-0+deb9u12
ii  php7.0-pgsql [php-pgsql]        7.0.33-0+deb9u12
ii  php7.0-xml [php-xml]            7.0.33-0+deb9u12
ii  php7.3 [php]                    7.3.31-1~deb10u4
ii  php7.3-bcmath [php-bcmath]      7.3.31-1~deb10u4
ii  php7.3-gd [php-gd]              7.3.31-1~deb10u4
ii  php7.3-mbstring [php-mbstring]  7.3.31-1~deb10u4
ii  php7.3-pgsql [php-pgsql]        7.3.31-1~deb10u4
ii  php7.3-xml [php-xml]            7.3.31-1~deb10u4
ii  ucf                             3.0038+nmu1

Versions of packages zabbix-frontend-php recommends:
ii  apache2 [httpd]                             2.4.38-3+deb10u10
ii  libapache2-mod-php7.0 [libapache2-mod-php]  7.0.33-0+deb9u12
ii  libapache2-mod-php7.3 [libapache2-mod-php]  7.3.31-1~deb10u4
ii  php-ldap                                    2:7.3+69
ii  php7.0-ldap [php-ldap]                      7.0.33-0+deb9u12
ii  php7.3-ldap [php-ldap]                      7.3.31-1~deb10u4

zabbix-frontend-php suggests no packages.

-- Configuration Files:
/etc/zabbix/apache.conf changed:
<IfModule mod_alias.c>
    Alias /zabbix /usr/share/zabbix
</IfModule>
<Directory "/usr/share/zabbix">
    Options FollowSymLinks
    AllowOverride None
    Order allow,deny
    Allow from all
    <IfModule mod_php5.c>
        php_value max_execution_time 300
        php_value memory_limit 128M
        php_value post_max_size 16M
        php_value upload_max_filesize 2M
        php_value max_input_time 300
        php_value always_populate_raw_post_data -1
        php_value date.timezone Europe/Berlin
        # php_value date.timezone Europe/Riga
    </IfModule>
    <IfModule mod_php7.c>
        php_value max_execution_time 300
        php_value memory_limit 128M
        php_value post_max_size 16M
        php_value upload_max_filesize 2M
        php_value max_input_time 300
        php_value always_populate_raw_post_data -1
        php_value date.timezone Europe/Berlin
        # php_value date.timezone Europe/Riga
    </IfModule>
</Directory>
<Directory "/usr/share/zabbix/conf">
    Order deny,allow
    Deny from all
    <files *.php>
        Order deny,allow
        Deny from all
    </files>
</Directory>
<Directory "/usr/share/zabbix/app">
    Order deny,allow
    Deny from all
    <files *.php>
        Order deny,allow
        Deny from all
    </files>
</Directory>
<Directory "/usr/share/zabbix/include">
    Order deny,allow
    Deny from all
    <files *.php>
        Order deny,allow
        Deny from all
    </files>
</Directory>
<Directory "/usr/share/zabbix/local">
    Order deny,allow
    Deny from all
    <files *.php>
        Order deny,allow
        Deny from all
    </files>
</Directory>


-- debconf information:
  zabbix-frontend-php/restart-webserver: true
  zabbix-frontend-php/configure-apache: true
--- /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']))

Reply via email to