ganglia / ganglia-web

Ganglia Web Frontend
BSD 3-Clause "New" or "Revised" License
317 stars 169 forks source link

update for PHP 8 #376

Closed berlin2123 closed 5 months ago

berlin2123 commented 5 months ago

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

berlin2123 commented 5 months ago

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

berlin2123 commented 5 months ago

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

iGeorgeX commented 3 months ago

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 commented 3 months ago

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 commented 3 months ago

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

berlin2123 commented 3 months ago

@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