Author Topic: PHP 8.1 fixes for Saratoga templates...  (Read 670 times)

0 Members and 1 Guest are viewing this topic.

Offline saratogaWX

  • Administrator
  • Forecaster
  • *****
  • Posts: 9257
  • Saratoga, CA, USA Weather - free PHP scripts
    • Saratoga-Weather.org
PHP 8.1 fixes for Saratoga templates...
« on: January 18, 2022, 07:28:51 PM »
I'd just gotten to install PHP8.1 and found some new Deprecated errata in the Base template set.

Mainly, the default casting of a float to an integer now gives a Deprecated message so things like
Code: [Select]
$dir = $windlabel[ fmod((($winddir + 11) / 22.5),16) ]; had to change to
Code: [Select]
$dir = $windlabel[ (integer)fmod((($winddir + 11) / 22.5),16) ]; to quiet the messages.

Also, the
Code: [Select]
$minutes = intval(($sec / 60) % 60); was changed to
Code: [Select]
$minutes = intval(fmod($sec / 60, 60));
In the GD library, the imagepolygon() and imagefilledpolygon() went from 4 arguments to 3 (losing the $num_args entry).

So.. I've been working on the Base-USA, CU-plugin site and will work on the Canada and World sites shortly.
I've updated the distributions with the following fixes:

Version 3.347 - 18-Jan-2022 (Base-*) PHP 8.1 updates to fix Deprecated errata: get-USNO-sunmoon.php V3.04, include-wxstatus.php V1.13, thermometer.php V1.18;
(Base-USA) advforecast2.php V5.18, NWS-regional-radar-animate.php V1.04, radar-status.php V1.18;
(CU-Plugin) PHP8.1 updates to fix Deprecated errata and add new CumulusMX data variables: CU-defs.php V1.12

Use the update tool with your Base and Plugin for 18-Jan-2022

I've attached a text file showing the main diffs of old/new files.

p.s. -- PHP 8.1 also announced the Deprecation of strftime()/strptime() built-in's ..the mesonet-map, global-map use that (and likely others too).
Ken True/Saratoga, CA, USA main site: saratoga-weather.org
Davis VP1+ FARS, Blitzortung RED, GRLevel3, WD, WL, VWS, Cumulus, Meteobridge
Free weather PHP scripts/website templates - update notifications on Twitter saratogaWXPHP

Offline spweather

  • Contributor
  • ***
  • Posts: 130
    • Sand Point Weather
Re: PHP 8.1 fixes for Saratoga templates...
« Reply #1 on: January 18, 2022, 07:49:34 PM »
Thanks Ken, I was just about to post a request for help as I was getting those errors after upgrading to PHP8.

Dennis
« Last Edit: January 18, 2022, 07:51:45 PM by spweather »
Regards,
Dennis

- Davis Wireless Vantage Pro2 Plus w/24hr FARS
- Davis (Ultra)Sonic Anemometer
- Boltek/MicroLDN TOA Lightening Detection
- Porcupine Labs LR4/Fluke 414D Laser Rangefinder snow depth measuring sensor


Offline BCJKiwi

  • Forecaster
  • *****
  • Posts: 302
    • Silver Acorn Weather - N.Z.
Re: PHP 8.1 fixes for Saratoga templates...
« Reply #2 on: January 18, 2022, 08:24:23 PM »
Just wondering how many of these PHP 8.x.x changes will break PHP 7.x.x ?
Is it too much to hope for that everything with updated PHP 8 syntax will still work in PHP 7.x.x ??

Offline saratogaWX

  • Administrator
  • Forecaster
  • *****
  • Posts: 9257
  • Saratoga, CA, USA Weather - free PHP scripts
    • Saratoga-Weather.org
Re: PHP 8.1 fixes for Saratoga templates...
« Reply #3 on: January 18, 2022, 08:35:27 PM »
They should work with 7.x and 5.6. The (integer) cast is valid in all releases, as is the fmod() function.  The differences for the two GD functions are handled by checking for PHP version.

I always try to ensure backward compatibility for the scripts.
Ken True/Saratoga, CA, USA main site: saratoga-weather.org
Davis VP1+ FARS, Blitzortung RED, GRLevel3, WD, WL, VWS, Cumulus, Meteobridge
Free weather PHP scripts/website templates - update notifications on Twitter saratogaWXPHP

Offline Jasiu

  • Forecaster
  • *****
  • Posts: 947
    • LexMAWeather
Re: PHP 8.1 fixes for Saratoga templates...
« Reply #4 on: January 19, 2022, 06:22:57 PM »
Noted that the USNO file is one of the changes. I still have to set that to not do the fetch because api.usno.navy.mil still doesn't resolve. Any idea what's going on there?
https://lexmaweather.info
On Mastodon: @LexMAWeather@toot.community

Offline saratogaWX

  • Administrator
  • Forecaster
  • *****
  • Posts: 9257
  • Saratoga, CA, USA Weather - free PHP scripts
    • Saratoga-Weather.org
Re: PHP 8.1 fixes for Saratoga templates...
« Reply #5 on: January 19, 2022, 06:30:15 PM »
The USNO site is still not offering the lookups at aa.usno.navy.mil.  The text on the site (usno.navy.mil) alludes to being back sometime in the first half of 2022, but I'm not holding my breath for it.  They've been down for refurb since 29-Oct-2019.

The changes to get-USNO-sunmoon were all in the force to integer for returns of timestamps from the calculations (and thereby remove the Deprecated errata about implicit float->int)
Ken True/Saratoga, CA, USA main site: saratoga-weather.org
Davis VP1+ FARS, Blitzortung RED, GRLevel3, WD, WL, VWS, Cumulus, Meteobridge
Free weather PHP scripts/website templates - update notifications on Twitter saratogaWXPHP

 

anything