Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

When installing or upgrading, PHP recommendations may not always return a valid value #3753

Closed
mikygee opened this issue Aug 13, 2020 · 16 comments
Labels
bug Undesired behaviour resolved A fixed issue
Milestone

Comments

@mikygee
Copy link

mikygee commented Aug 13, 2020

Version: 1.2.14

Hello,

I do a fresh install and I see this message
2020/08/13 09:43:11 [error] 57141#0: *116 FastCGI sent in stderr: "PHP message: PHP Warning: Invalid argument supplied for foreach() in /htdocs/cacti-1.2.14/lib/installer.php on line 1791" while reading response header from upstream, client: 192.168.99.202, server: _, request: "POST /install/step_json.php HTTP/1.1", upstream: "fastcgi://unix:/run/php-fpm.cacti.sock:", host: "MyIP:8080", referrer: "http://MyIP:8080/install/install.php?data={%22Step%22:%222%22,%22Eula%22:true}"

I saw a message stating it was fixed in 1.2.3 but I have it on 1.2.14

I'm stuck at page 2 because I have warnings saying php modules cli - No

I open this issue for the error message

@mikygee mikygee added bug Undesired behaviour unverified Some days we don't have a clue labels Aug 13, 2020
@netniV
Copy link
Member

netniV commented Aug 13, 2020

Check your path_php_bin setting is correct. I need to modify the 1.3 installer to ask for the file paths first so we can handle things properly.

@mikygee
Copy link
Author

mikygee commented Aug 13, 2020

Hello Mark,
Yes I think it's correct

select * from settings where name='path_php_binary';
+-----------------+----------+
| name | value |
+-----------------+----------+
| path_php_binary | /bin/php |
+-----------------+----------+
1 row in set (0.000 sec)

$ /bin/php -v
PHP 7.3.17 (cli) (built: Aug 1 2020 11:59:21) ( NTS )
Copyright (c) 1997-2018 The PHP Group
Zend Engine v3.3.17, Copyright (c) 1998-2018 Zend Technologies

$ php -m
[PHP Modules]
bcmath
calendar
Core
ctype
curl
date
dom
exif
fileinfo
filter
ftp
gd
gettext
gmp
hash
iconv
imagick
intl
json
ldap
libxml
mbstring
mysqli
mysqlnd
openssl
pcntl
pcre
PDO
pdo_mysql
Phar
posix
readline
Reflection
session
SimpleXML
snmp
sockets
sodium
SPL
standard
sysvmsg
sysvsem
sysvshm
tokenizer
wddx
xml
xmlreader
xmlwriter
zip
zlib

[Zend Modules]

So the problem lives somewhere else.

Please also check the rights for the php binary. The http user should be able to execute it.

@netniV
Copy link
Member

netniV commented Aug 13, 2020

What OS is this?

@mikygee
Copy link
Author

mikygee commented Aug 14, 2020

The OS is Openbsd + Nginx and Chrooted
But cacti is already installed on a different machine with the same version and it works.
Which tests are done by the installer ?

@netniV
Copy link
Member

netniV commented Aug 14, 2020

It requests a list of enabled modules from PHP runtime and returns that back via json to the webserver. This is suggesting there's something different setup between the two machines then

@mikygee
Copy link
Author

mikygee commented Aug 15, 2020

Is it this invoked command ?
php -q /cacti/install/cli_check.php

@netniV
Copy link
Member

netniV commented Aug 15, 2020

Yes, and you can call it with a single argument of either

  • extensions
  • recommends
  • optionals

In your case, I believe it's the recommends section that's blowing up, but you may as well check all three.

@mikygee
Copy link
Author

mikygee commented Aug 15, 2020

Thank you Mark.

All three display these output

$ php -c /etc/php-cli.ini -q /cacti-1.2.14/install/cli_check.php extensions
{"ctype":{"cli":true,"web":false},"PDO":{"cli":true,"web":false},"zlib":{"cli":true,"web":false},"xml":{"cli":true,"web":false},"standard":{"cli":true,"web":false},"spl":{"cli":true,"web":false},"sockets":{"cli":true,"web":false},"simplexml":{"cli":true,"web":false},"session":{"cli":true,"web":false},"pdo_mysql":{"cli":true,"web":false},"pcre":{"cli":true,"web":false},"date":{"cli":true,"web":false},"openssl":{"cli":true,"web":false},"mbstring":{"cli":true,"web":false},"ldap":{"cli":true,"web":false},"json":{"cli":true,"web":false},"hash":{"cli":true,"web":false},"gmp":{"cli":true,"web":false},"gd":{"cli":true,"web":false},"filter":{"cli":true,"web":false},"posix"

$ php -c /etc/php-cli.ini -q /cacti-1.2.14/install/cli_check.php recommends
[{"name":"version","value":"5.4.0","current":"7.3.17","status":2},{"name":"memory_limit","value":"400M","current":"1024M","status":2},{"name":"max_execution_time","value":60,"current":"300","status":2},{"name":"date.timezone","value":"","current":"Europe/Paris","status":2}]

$php -c /etc/php-cli.ini -q /cacti-1.2.14/install/cli_check.php optionals
{"snmp":{"web":false,"cli":true},"gettext":{"web":false,"cli":true},"TrueType Box":{"web":false,"cli":true},"TrueType Text":{"web":false,"cli":true}}$

@netniV
Copy link
Member

netniV commented Aug 16, 2020

Hmm, did you get any warnings in the error log or php logs? Something strange is happening with your system. Maybe you can add a cacti_log() with to record the output of the php call made within utilities.

@mikygee
Copy link
Author

mikygee commented Aug 16, 2020

Please explain me where I should add this instruction ?
In cli_check.php, at the begining of the script ?

@netniV
Copy link
Member

netniV commented Aug 16, 2020

No, in the utility.php that calls it. Verify that the output coming back is clean json.

@mikygee
Copy link
Author

mikygee commented Aug 17, 2020

Hello,
Where exactly in utility.php should I add cacti_log();
In the begining ?

@TheWitness
Copy link
Member

Anything going on with this one @netniV or @mikygee ?

@netniV
Copy link
Member

netniV commented Sep 18, 2020

Sorry, I missed the reply, I'll have to make a diff file for the utility.php from the 1.2.14 release (though I don't think the 1.2.15 one has changed)

@netniV
Copy link
Member

netniV commented Sep 18, 2020

diff --git a/lib/utility.php b/lib/utility.php
index b7d460b42..65c353e11 100644
--- a/lib/utility.php
+++ b/lib/utility.php
@@ -1429,6 +1429,8 @@ function utility_php_recommends() {
        utility_php_verify_recommends($ext['web'], 'web');
        utility_php_set_recommends_text($ext);

+       cacti_log("UTILITY RECOMMENDS: $json");
+
        return $ext;
 }

TheWitness added a commit that referenced this issue Sep 30, 2020
Invalid argument supplied for foreach()
@TheWitness TheWitness added this to the 1.2.15 milestone Sep 30, 2020
@TheWitness TheWitness added resolved A fixed issue and removed unverified Some days we don't have a clue labels Sep 30, 2020
@TheWitness
Copy link
Member

I've done a quick fix to handle at least the error. However, the underlying issue remains. So, can you guys open another ticket with the root cause of the path issue?

@netniV netniV changed the title Invalid argument supplied for foreach() When installing or upgrading, PHP recommendations may not always return a valid value Nov 2, 2020
@github-actions github-actions bot locked and limited conversation to collaborators Feb 1, 2021
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
bug Undesired behaviour resolved A fixed issue
Projects
None yet
Development

No branches or pull requests

3 participants