php error if function formatBytes get calles with some non numeric value
Only happens if something goes wrong somewhere.
Example if email backup has no size written back into DB than if you click on Email Backup Tab the following error occurs
[Fri Jun 09 19:44:32.274647 2023] [fcgid:warn] [pid 1425757:tid 139802577917504] mod_fcgid: stderr: PHP Fatal error: Uncaught TypeError: log(): Argument #1 ($num) must be of type float, string given in /usr/local/ispconfig/interface/lib/classes/functions.inc.php:290
Could happens in other (non standard) conditions too.
A is_numeric() check or something like this would be useful to make it more failsafe.
public function formatBytes($size, $precision = 2) { if (!is_numeric($size)) { global $app; $app->log('Function formatBytes got non nummeric value - check it', LOGLEVEL_ERROR); return ''; } $base=log($size)/log(1024); $suffixes=array('', ' kB', ' MB', ' GB', ' TB'); return round(pow(1024, $base-floor($base)), $precision).$suffixes[floor($base)]; }
Edited by Hannes