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

update for PHP 8 #376

Merged
merged 4 commits into from
Feb 21, 2024
Merged

update for PHP 8 #376

merged 4 commits into from
Feb 21, 2024

Conversation

berlin2123
Copy link
Contributor

now woks fine in php8. It is tested in RHEL8 (php7) and RHEL9 (php8). Both works fine !!!

PHP Fatal error:  Uncaught TypeError: in_array(): Argument ganglia#2 ($haystack) must be of type array, null given in /usr/share/ganglia/ganglia.php:353
…/usr/share/ganglia/functions.php on line 732
@berlin2123
Copy link
Contributor Author

in the test in RHEL8/9. the display is fine, and no errors log in /var/log/www-error.log

@berlin2123
Copy link
Contributor Author

berlin2123 commented Feb 21, 2024

@vvuksan , It is recommended to publish a new release now.

@vvuksan vvuksan merged commit 0f92146 into ganglia:master Feb 21, 2024
@@ -1820,7 +1820,7 @@ protected function parseFunction($in, $from, $to, $parsingParams = false, $curBl
if ($func === 'tif') {
$params[] = $tokens;
}
$output = call_user_func_array($funcCompiler, $params);
$output = call_user_func_array($funcCompiler, array_values($params));
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

fix: PHP Fatal error: Uncaught Error: Unknown named parameter $* in /usr/share/ganglia/dwoo/Dwoo/Compiler.php:1823

Not sure if this would introduce a logic bug, but the web page looks normal.

@@ -594,7 +594,7 @@ function get_load_heatmap($hosts_up, $host_regex, $metrics, $load_scale, $tpl_da
if (array_key_exists($user_metricname, $metrics))
$units = $metrics[$user_metricname]['UNITS'];
} else {
if (array_key_exists($user_metricname, $metrics[key($metrics)]))
if ((!is_null($metrics[key($metrics)])) && array_key_exists($user_metricname, $metrics[key($metrics)]))
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

fix: PHP Fatal error: Uncaught TypeError: array_key_exists(): Argument #2 ($array) must be of type array, null given in /usr/share/ganglia/cluster_view.php:597

@@ -350,7 +350,7 @@ function Gmetad () {
}

if ($debug) print "<br/>DEBUG: Creating parser\n";
if ( in_array($context, $SKIP_GMETAD_CONTEXTS) ) {
if ( isset($context) && is_array($context) && isset($SKIP_GMETAD_CONTEXTS) && is_array($SKIP_GMETAD_CONTEXTS) && in_array($context, $SKIP_GMETAD_CONTEXTS) ) {
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

fix: PHP Fatal error: Uncaught TypeError: in_array(): Argument #2 ($haystack) must be of type array, null given in /usr/share/ganglia/ganglia.php:353

$count=0;
} else {
$count=count($names);
}
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

fix: PHP Fatal error: Uncaught TypeError: count(): Argument #1 ($value) must be of type Countable|array, null given in /usr/share/ganglia/meta_view.php:211

@iGeorgeX
Copy link

iGeorgeX commented May 3, 2024

I still get a PHP error PHP Fatal error: Uncaught TypeError: number_format(): Argument #1 ($num) must be of type float, string given in /usr/share/ganglia/graph.d/metric.php:58.

@berlin2123
Copy link
Contributor Author

I still get a PHP error PHP Fatal error: Uncaught TypeError: number_format(): Argument #1 ($num) must be of type float, string given in /usr/share/ganglia/graph.d/metric.php:58.

It is not a bug of php versions. It is the same issue inside php5\7\8. You can test php versions in a oline-php-tester, such as testing the follow code in php tester

<?php
  
#$value = 1003.1;
$value = 'asdfa';

$value = ($value > 1000)
  ? number_format($value)
  : number_format($value, 2);
print($value);
?>

You are Wellcome to report a new issue. note show how to reproduce it.

@iGeorgeX
Copy link

iGeorgeX commented May 3, 2024

Ah all right. At least that was the last error I noticed when looking through the log files.

@berlin2123
Copy link
Contributor Author

berlin2123 commented May 4, 2024

@iGeorgeX
This log is cased by hosts down, which is an old issue when change from php5.2 to php5.3, teated in https://onlinephp.io/

Can be fixed by adding $value = (float)$value; on line 56, seeing #379

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

Successfully merging this pull request may close these issues.

None yet

3 participants