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

PHP 8.0 Compatibility #361

Open
giddie opened this issue Apr 8, 2021 · 8 comments
Open

PHP 8.0 Compatibility #361

giddie opened this issue Apr 8, 2021 · 8 comments

Comments

@giddie
Copy link

giddie commented Apr 8, 2021

There seem to be multiple fixes required for compatibility with PHP 8.0.3. It starts with:

2021/04/08 21:58:36 [error] 984#984: *21 FastCGI sent in stderr: "PHP message: PHP Warning:  "continue" targeting switch is equivalent to "break" in /usr/share/webapps/ganglia/functions.php on line 732PHP message: PHP Fatal error:  Uncaught ArgumentCountError: Too few arguments to function ganglia_api_error_handler(), 4 passed and exactly 5 expected in /usr/share/webapps/ganglia/lib/common_api.php:18
Stack trace:
#0 /usr/share/webapps/ganglia/ganglia.php(353): ganglia_api_error_handler()
#1 /usr/share/webapps/ganglia/get_ganglia.php(11): Gmetad()
#2 /usr/share/webapps/ganglia/index.php(7): include_once('...')
#3 {main}

It seems the fifth argument to set_error_handler() was deprecated a while back, and is now removed in PHP 8. After that:

2021/04/08 21:57:19 [error] 984#984: *19 FastCGI sent in stderr: "PHP message: PHP Warning:  "continue" targeting switch is equivalent to "break" in /usr/share/webapps/ganglia/functions.php on line 732PHP message: PHP Fatal error:  Uncaught TypeError: in_array(): Argument #2 ($haystack) must be of type array, null given in /usr/share/webapps/ganglia/ganglia.php:353
Stack trace:
#0 /usr/share/webapps/ganglia/ganglia.php(353): in_array()
#1 /usr/share/webapps/ganglia/get_ganglia.php(11): Gmetad()
#2 /usr/share/webapps/ganglia/index.php(7): include_once('...')
#3 {main}
@dirtyharrycallahan
Copy link

This project is dead and there are lots of unpatched vulnerabilities. We ran ganglia for a few years but have since migrated to grafana+prometheus.

@giddie
Copy link
Author

giddie commented Apr 9, 2021

I kind of got the impression that it's at least struggling, but I notice there are commits from Jan 2021, so it's not dead dead. But yeah, probably time to consider something else 👍

@outpaddling
Copy link

Munin looks to be pretty comparable to Ganglia and simple to set up. I haven't tried it yet, but will try to remember to report back when I find some time.

jh23453 added a commit to jh23453/ganglia-web that referenced this issue Mar 6, 2022
I got the message:
PHP Warning:  "continue" targeting switch is equivalent to "break". Did you mean to use "continue 2"?
 in /usr/share/ganglia-webfrontend/functions.php on line 732

This messages is likely new with php7.3. Will be an error with PHP8.
For details see https://wiki.php.net/rfc/continue_on_switch_deprecation

This in one small step to get ready for php8. See ganglia#361
jh23453 added a commit to jh23453/ganglia-web that referenced this issue Mar 6, 2022
According to the php documentation the "context" parameter to the
error handler has been deprecated:
https://www.php.net/manual/en/function.set-error-handler.php

Let's move on and get ready for a newer php version (debian bullseye has 7.4).

This in one small step to get ready for php8. See ganglia#361
@zeekus
Copy link

zeekus commented Aug 22, 2023

I was able to get ganglia working with php82 on centos7. I made the following changes.

file: /usr/share/ganglia/ganglia.php

Line 353 - 355 commented out this

//if ( in_array($context, $SKIP_GMETAD_CONTEXTS) ) {
// return TRUE;
//}

file: /usr/share/ganglia/ganglia/functions.php
line 732 - changed 'continue' to 'break' as described in #368

file: /usr/share/ganglia/ganglia/lib/common_api.php
line 18: changed funciton to have only the first 4 variables.
18 //function ganglia_api_error_handler ($no, $str, $file, $line, $context) { //old version
19 function ganglia_api_error_handler ($no, $str, $file, $line) {

@n8falke
Copy link
Contributor

n8falke commented Sep 26, 2023

Additional: PHP Fatal error: Uncaught Error: Undefined constant "LOCALTIME"
in file: cluster_view.php
can be fixed by replacing: $cluster[LOCALTIME] with $cluster['LOCALTIME']
in line 617 and 765.

@AnkushKapoor-97
Copy link

Check for the error log file
$ vi /var/log/httpd/error_log

$ vi /usr/share/ganglia/dwoo/plugins/builtin/blocks/if.php -> on line 41 change while loop with foreach loop
//while (list($k,$v) = each($params)) {
foreach ($params as $k => $v) {
$ vi /usr/share/ganglia/dwoo/Dwoo/Compiler.php -> On line 3044 change while loop with foreach loop
//while (list($k,$v) = each($map)) {
foreach ($map as $k => $v) {
$ vi /usr/share/ganglia/cluster_view.php -> On line 617 change LOCALTIME to 'LOCALTIME'

@rokyo249
Copy link

rokyo249 commented Jan 22, 2024

After applying all the above-mentioned changes to the appropriate files in an installation of Ganglia on Debian 12, there is now still one error appearing in /var/log/apache2/error.log:

PHP Fatal error: Uncaught Error: Call to undefined function each() in /usr/share/ganglia-webfrontend/dwoo/Dwoo/Compiler.php:2530\nStack trace:\n#0 /usr/share/ganglia-webfrontend/dwoo/Dwoo/Compiler.php(1427): Dwoo_Compiler->parseOthers()\n#1 /usr/share/ganglia-webfrontend/dwoo/Dwoo/Compiler.php(1674): Dwoo_Compiler->parse()\n#2 /usr/share/ganglia-webfrontend/dwoo/Dwoo/Compiler.php(1365): Dwoo_Compiler->parseFunction()\n#3 /usr/share/ganglia-webfrontend/dwoo/Dwoo/Compiler.php(805): Dwoo_Compiler->parse()\n#4 /usr/share/ganglia-webfrontend/dwoo/Dwoo/Template/String.php(369): Dwoo_Compiler->compile()\n#5 /usr/share/ganglia-webfrontend/dwoo/Dwoo/Core.php(373): Dwoo_Template_String->getCompiledTemplate()\n#6 /usr/share/ganglia-webfrontend/dwoo/Dwoo/Core.php(299): Dwoo_Core->get()\n#7 /usr/share/ganglia-webfrontend/header.php(449): Dwoo_Core->output()\n#8 /usr/share/ganglia-webfrontend/index.php(38): include_once('...')\n#9 {main}\n thrown in /usr/share/ganglia-webfrontend/dwoo/Dwoo/Compiler.php on line 2530

The line 2530 in /dwoo/Dwoo/Compiler.php reads:

while (list($k,$char) = each($breakChars)) {

so, I assume it needs to be re-written as a foreach as well?

Maybe foreach ($breakChars as $k => $char) { if it follows the same logic as the above? Sorry, I don't know any PHP ;)

EDIT: Yup, that worked!

@berlin2123
Copy link
Contributor

berlin2123 commented Feb 21, 2024

Thank you all ! its is fixed now in PR #376, which has include some of your fix.
it can be easy tested by the rpm files in epel now.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

8 participants