[SOLVED] HTTP 500 with 1.2.20 under PHP 5.4

Post support questions that directly relate to Linux/Unix operating systems.

Moderators: Developers, Moderators

Post Reply
dtcdan
Posts: 4
Joined: Wed Apr 06, 2022 12:15 pm

[SOLVED] HTTP 500 with 1.2.20 under PHP 5.4

Post by dtcdan »

Hello,

I've been eagerly awaiting the release of 1.2.20 due to some bugs in 1.2.19 that really had my server slowed down. I attempted upgrade via the Documentation, and when browsing to the site again, the redirect to install.php errors out with an error 500. The Apache error log contains:

[Wed Apr 06 13:06:44.695073 2022] [:error] [pid 25116] [client XXX] PHP Parse error: syntax error, unexpected '[' in /var/www/html/cacti/lib/api_device.php on line 1214, referer: http://netops.xxxxxx.com/cacti/install/install.php

That line doesn't appear to contain an extra '[', so it must be coming from something above it, I'd guess... I don't have a lot of programming experience.

In case this was an oddity from the upgrade process, I also tried an install in a fresh directory, updated my httpd conf to point to it, and get exactly the same thing. Has anyone else had any issue with the 1.2.20 release like this?
Last edited by dtcdan on Fri Apr 08, 2022 8:02 am, edited 1 time in total.
netniV
Cacti Guru User
Posts: 3441
Joined: Sun Aug 27, 2017 12:05 am

Re: HTTP 500 with 1.2.20

Post by netniV »

If you have the latest sources, this shouldn't be a problem as I have just checked our sources and there is no issue:

Code: Select all

$ php -l lib/api_device.php
No syntax errors detected in lib/api_device.php
Cacti Developer & Release Manager
The Cacti Group

Director
BV IT Solutions Ltd

+--------------------------------------------------------------------------+

Cacti Resources:
Cacti Website (including releases)
Cacti Issues
Cacti Development Releases
Cacti Development Documentation
dtcdan
Posts: 4
Joined: Wed Apr 06, 2022 12:15 pm

Re: HTTP 500 with 1.2.20

Post by dtcdan »

Interesting. Here's what I get, when running the same against a fresh extract of the archive cacti-1.2.20.tar.gz

Code: Select all

[root@netops lib]# php -l api_device.php
PHP Parse error:  syntax error, unexpected '[' in api_device.php on line 1214
Errors parsing api_device.php
This is on a machine that has PHP 5.4 on it:

Code: Select all

[root@netops ~]# php --version
PHP 5.4.16 (cli) (built: Apr  1 2020 04:07:17)
Copyright (c) 1997-2013 The PHP Group
Zend Engine v2.4.0, Copyright (c) 1998-2013 Zend Technologies
I grabbed the code for that file directly out of GitHub with the same results on the same server, but when I did so on a newer server and PHP, I got the same thing you did. Version of working test:

Code: Select all

[root@bookstack ~]# php --version
PHP 7.3.31 (cli) (built: Sep 21 2021 10:24:03) ( NTS )
Copyright (c) 1997-2018 The PHP Group
Zend Engine v3.3.31, Copyright (c) 1998-2018 Zend Technologies
Is is possible that Cacti requires a newer version of PHP than it used to? It seems like syntactically a '[' wouldn't be handled differently by different PHP versions, but that's what the evidence is suggesting. I'll try upgrading PHP on the original server and see if I can get an upgrade to happen.
dtcdan
Posts: 4
Joined: Wed Apr 06, 2022 12:15 pm

Re: [SOLVED] HTTP 500 with 1.2.20

Post by dtcdan »

Once I upgraded PHP (to 7.4), this issue went away and I was able to get my instance upgraded.
netniV
Cacti Guru User
Posts: 3441
Joined: Sun Aug 27, 2017 12:05 am

Re: [SOLVED] HTTP 500 with 1.2.20

Post by netniV »

Yes, this was confirmed as an issue under PHP 5.4 only. For some reason, the CI system seems not to have reported this to us so that's going to need investigating.
Cacti Developer & Release Manager
The Cacti Group

Director
BV IT Solutions Ltd

+--------------------------------------------------------------------------+

Cacti Resources:
Cacti Website (including releases)
Cacti Issues
Cacti Development Releases
Cacti Development Documentation
dvsing
Posts: 2
Joined: Mon Apr 18, 2022 1:32 pm

Re: [SOLVED] HTTP 500 with 1.2.20 under PHP 5.4

Post by dvsing »

Is there a solution to this for PHP 5.4? My system updated to cacti 1.2.20 today and now cacti is broken because of this issue. I'm on centos 7.9 which comes stock with PHP 5.4.
dvsing
Posts: 2
Joined: Mon Apr 18, 2022 1:32 pm

Re: [SOLVED] HTTP 500 with 1.2.20 under PHP 5.4

Post by dvsing »

Aha. It's a simple fix. Line 1214 of /usr/share/cacti/lib/api_device.php is:
} elseif (!$isset(raised[$poller_id])) {

and it should be:
} elseif (!$isset($raised[$poller_id])) {

(add a $ before "raised"). I made this change and the install/upgrade process proceeds past the blank page.
firstlove
Posts: 16
Joined: Thu Apr 21, 2022 2:23 am

Re: [SOLVED] HTTP 500 with 1.2.20 under PHP 5.4

Post by firstlove »

i get the same errors.php version is 5.4 too. so i testing....
firstlove
Posts: 16
Joined: Thu Apr 21, 2022 2:23 am

Re: [SOLVED] HTTP 500 with 1.2.20 under PHP 5.4

Post by firstlove »

dvsing wrote: Mon Apr 18, 2022 1:40 pm Aha. It's a simple fix. Line 1214 of /usr/share/cacti/lib/api_device.php is:
} elseif (!$isset(raised[$poller_id])) {

and it should be:
} elseif (!$isset($raised[$poller_id])) {

(add a $ before "raised"). I made this change and the install/upgrade process proceeds past the blank page.
it's worked.
Post Reply

Who is online

Users browsing this forum: No registered users and 2 guests