Weather-Station-Software / live-weather-station

Display on your WordPress site, in many elegant ways, the meteorological data collected by public or personal weather stations.
https://weather.station.software/
GNU General Public License v2.0
7 stars 2 forks source link

DataUnitConversion.php error with PHP 8.2 #33

Open lahyenne opened 11 months ago

lahyenne commented 11 months ago

functions like this one in the file /wp-content/plugins/live-weather-station/includes/traits/DataUnitConversion.php :

protected function get_wind_angle($value)
    {
        $result = $value;
        return sprintf('%d', round($result, 0));
    }

throw an error in PHP 8.2 (it works fine in PHP 7.4) when $result='NULL' when executing the round command. I run a test with the following modification, and it works for me (maybe not the best) :

protected function get_wind_angle($value)
    {
    // Convert non-numeric values to 0
    $result = is_numeric($value) ? $value : 0;

    // Round the numeric value
    return sprintf('%d', round($result, 0));
    }
jaz-on commented 11 months ago

Hello @lahyenne thanks for the feedback. The Weather Station plugin hasn't been tested up to PHP 8.2 yet. In fact, I guess the whole codebase has been developed when PHP 7.x was the current version, I guess the whole codebase will have to be tested for PHP 8.x.

I committed and merged a fix. This needs to be tested as part of the future 3.8.14 version (FYI the review and validation of 3.8.13 is pending on WordPress.org).

jaz-on commented 10 months ago

@lahyenne I just released version 3.8.14, would you mind testing it and providing feedback if it resolves the error you reported? Many thanks