Welcome to the Cumulus Support forum.

Latest Cumulus MX V3 release 3.28.6 (build 3283) - 21 March 2024

Cumulus MX V4 beta test release 4.0.0 (build 4017) - 17 March 2024

Legacy Cumulus 1 release v1.9.4 (build 1099) - 28 November 2014 (a patch is available for 1.9.4 build 1099 that extends the date range of drop-down menus to 2030)

Download the Software (Cumulus MX / Cumulus 1 and other related items) from the Wiki

Saratoga Base-* Templates and PHP 8

Discussion of Ken True's web site templates

Moderator: saratogaWX

Post Reply
User avatar
saratogaWX
Posts: 1170
Joined: Wed 06 May 2009 5:02 am
Weather Station: Davis Vantage Pro Plus
Operating System: Windows 10 Professional
Location: Saratoga, CA, USA
Contact:

Saratoga Base-* Templates and PHP 8

Post by saratogaWX »

I've done testing with the Base-Canada, Base-USA and Base-World templates and only found two scripts that needed minor updates to run on PHP 8.+ (and still compatible with older PHP versions).

common.php V1.11 and flyout-menu.php V1.09 are now available using the update tool with a query of Base-*, Plugin-* 07-Dec-2020

The remaining support scripts seem to work fine and not cast errata in the error_log. It's safe to update before you update PHP to 8.0.0 as the fixes were backward compatible to prior PHP5/PHP7.
User avatar
PaulMy
Posts: 3775
Joined: Sun 28 Sep 2008 11:54 pm
Weather Station: Davis VP2 Plus 24-Hour FARS
Operating System: Windows8 and Windows10
Location: Komoka, ON Canada
Contact:

Re: Saratoga Base-* Templates and PHP 8

Post by PaulMy »

Thanks Ken,
I am all up to date again with scripts for www.komokaweather.com/komokaweather-ca
PHP 7.4 is the latest available on the GoDaddy list so will be a while before I will look at PHP 8.

Enjoy,
Paul
Davis Vantage Pro2+
C1 www.komokaweather.com/komokaweather-ca
MX www.komokaweather.com/cumulusmx/index.htm /index.html /index.php
MX www.komokaweather.com/cumulusmxwll/index.htm /index.html /index.php
MX www. komokaweather.com/cumulusmx4/index.htm

Image
User avatar
ConligWX
Posts: 1570
Joined: Mon 19 May 2014 10:45 pm
Weather Station: Davis vPro2+ w/DFARS + AirLink
Operating System: Ubuntu 22.04 LTS
Location: Bangor, NI
Contact:

Re: Saratoga Base-* Templates and PHP 8

Post by ConligWX »

Ken to the rescue again. Thank you. :clap:
Regards Simon

https://www.conligwx.org - @conligwx
Davis Vantage Pro2 Plus with Daytime FARS • WeatherLink Live • Davis AirLink • PurpleAir •

Image
User avatar
N0BGS
Posts: 205
Joined: Sat 10 Nov 2012 2:26 am
Weather Station: Davis Vantage Pro 2
Operating System: Win10vm,VMWare ESXi 7.0
Location: Hermon, Maine USA
Contact:

Re: Saratoga Base-* Templates and PHP 8

Post by N0BGS »

Meanwhile, one year later....

I just updated my Linux server to Fedora 35 today which also updated PHP to version 8.0.13. After doing so my home page would no longer display the forecast and wxforecast.php was also blank.

After investigating this a bit I found that the error was caused by a typo on line 537 of advforecast2.php:

Code: Select all

$Status.= "<!-- JSON decode $JSONerror -->\n";
  if (jason_last_error() !== JSON_ERROR_NONE) {
    $Status.= "<!-- content='" . print_r($content, true) . "' -->\n";
  }
Obviously that should be "json_last_error" not "jason." :lol: Why PHP 7.x didn't care about that I don't know.

This seems like an error I may have caused myself rather than Ken since he doesn't make errors, ;) but if it was me I don't remember doing it.

So if you're having a similar problem you may want to check that line.

--Kurt

www.kpw3.com
Blitzortung Station 1809
BCJKiwi
Posts: 1255
Joined: Mon 09 Jul 2012 8:40 pm
Weather Station: Davis VP2 Cabled
Operating System: Windows 10 Pro
Location: Auckland, New Zealand
Contact:

Re: Saratoga Base-* Templates and PHP 8

Post by BCJKiwi »

OK, have made the changes to both files.

Using World and Cumulus files.
However now have an error in PHP 7.4.26 ( and earlier) and PHP 8.1
Undefined variable $string in common.php @ line 502

Code: Select all

<img src="'. $SITE['imagesDir'] . 'flag-'. $k .'.gif" alt="'. $v .'" title="'. $v .'" style="border: none;" /></a>
Have 2 different issues with PHP8
1:-
Deprecated:
Implicit conversion from float4.3111111111111 to int loses precision in CU-defs.php on line 1006
This is here
$dir = $windlabel[ fmod((($winddir + 11) / 22.5),16) ];
the CUdefs file

#-------------------------------------------------------------------------------------
# CU support function - CU_deg2dir - Convert wind direction degrees to cardinal name
#-------------------------------------------------------------------------------------

Code: Select all

function CU_deg2dir ($degrees) {
   // figure out a text value for compass direction
// Given the wind direction, return the text label
// for that value.  16 point compass
   $winddir = $degrees;
   if ($winddir == "n/a") { return($winddir); }

  if (!isset($winddir)) {
    return "---";
  }
  if (!is_numeric($winddir)) {
	return($winddir);
  }
  $windlabel = array ("N","NNE", "NE", "ENE", "E", "ESE", "SE", "SSE", "S",
	 "SSW","SW", "WSW", "W", "WNW", "NW", "NNW");
  $dir = $windlabel[ fmod((($winddir + 11) / 22.5),16) ];
  return($dir);

} // end function CU_deg2dir
2:-
Also the same Deprecated error but in these lines (in a non Saratoga template addon file for current conditions.

Code: Select all

  $auto .= $langWindShort[ round(($RT_avgbearing +11) / 22.5 % 16)];
  $hybrid .= $langWindShort[ round(($RT_avgbearing +11) / 22.5 % 16)];
Any assistance correcting these issues would be appreciated.
NOTE:- our public websites are still running PHP7 and does not have these updates yet.

Thanks
User avatar
saratogaWX
Posts: 1170
Joined: Wed 06 May 2009 5:02 am
Weather Station: Davis Vantage Pro Plus
Operating System: Windows 10 Professional
Location: Saratoga, CA, USA
Contact:

Re: Saratoga Base-* Templates and PHP 8

Post by saratogaWX »

For common.php lne 502 change it to

Code: Select all

 $string1 = ''; $string = '';
For the CU-defs.php, try

Code: Select all

$dir = $windlabel[ (integer)round(fmod((($winddir + 11) / 22.5),16),0) ];
and see if that fixes the deprecated error.

For the non-saratoga scripts, try

Code: Select all

  $auto .= $langWindShort[ (integer)round(($RT_avgbearing +11) / 22.5 % 16)];
  $hybrid .= $langWindShort[ (integer)round(($RT_avgbearing +11) / 22.5 % 16)];
BCJKiwi
Posts: 1255
Joined: Mon 09 Jul 2012 8:40 pm
Weather Station: Davis VP2 Cabled
Operating System: Windows 10 Pro
Location: Auckland, New Zealand
Contact:

Re: Saratoga Base-* Templates and PHP 8

Post by BCJKiwi »

OK

@ Line 495 changed
$string1 = '';
to
$string = '';
== success for both php 7 and 8.

Also success with change to CU-defs.php for php 7 and 8

However no joy with change to
$auto .= $langWindShort[ (integer)round(($RT_avgbearing +11) / 22.5 % 16)];
$hybrid .= $langWindShort[ (integer)round(($RT_avgbearing +11) / 22.5 % 16)]; }
which reports the same error in php 8 but OK in php 7

Thanks
User avatar
saratogaWX
Posts: 1170
Joined: Wed 06 May 2009 5:02 am
Weather Station: Davis Vantage Pro Plus
Operating System: Windows 10 Professional
Location: Saratoga, CA, USA
Contact:

Re: Saratoga Base-* Templates and PHP 8

Post by saratogaWX »

So, try my same hack with the non-saratoga scripts:

Code: Select all

  $auto .= $langWindShort[ (integer)round(fmod((($RT_avgbearing + 11) / 22.5),16),0)];
  $hybrid .= $langWindShort[ (integer)round(fmod((($RT_avgbearing + 11) / 22.5),16),0)];
Glad the other ones worked out 8-) :D

PHP 8 seems to be more fussed about typing of variables. The round() returns a float value, so (integer)round() makes it an integer for the index in to the wind direction array.
PHP 7 seemed to do the typing-to-integer automatically, PHP 8 insists on having it match the integer index.
BCJKiwi
Posts: 1255
Joined: Mon 09 Jul 2012 8:40 pm
Weather Station: Davis VP2 Cabled
Operating System: Windows 10 Pro
Location: Auckland, New Zealand
Contact:

Re: Saratoga Base-* Templates and PHP 8

Post by BCJKiwi »

Well, That seems to have sorted it.
Thanks V much. :clap: :clap: :clap:

However,
there is ? (was ?) an error with the CU-defs.php fix in php 7. Not sure about php 8 as it is a fleeting value depending on wind direction.

Undefined offset: 16 in CU-defs.php on line 1007
It seems only to occur when the value is 16 - have not seen it on any other value (yet).
User avatar
saratogaWX
Posts: 1170
Joined: Wed 06 May 2009 5:02 am
Weather Station: Davis Vantage Pro Plus
Operating System: Windows 10 Professional
Location: Saratoga, CA, USA
Contact:

Re: Saratoga Base-* Templates and PHP 8

Post by saratogaWX »

So maybe the 'round' wasn't such a good idea.

Try

Code: Select all

$dir = $windlabel[ (integer)fmod((($winddir + 11) / 22.5),16) ];
and

Code: Select all

 $auto .= $langWindShort[ (integer)fmod((($RT_avgbearing + 11) / 22.5),16)];
  $hybrid .= $langWindShort[ (integer)fmod((($RT_avgbearing + 11) / 22.5),16)];
then the array selector value will be 0..15 which matches the array size of 16 elements.
BCJKiwi
Posts: 1255
Joined: Mon 09 Jul 2012 8:40 pm
Weather Station: Davis VP2 Cabled
Operating System: Windows 10 Pro
Location: Auckland, New Zealand
Contact:

Re: Saratoga Base-* Templates and PHP 8

Post by BCJKiwi »

Thanks,

Will let it run for a while and report the outcome in due course.
User avatar
mcrossley
Posts: 12689
Joined: Thu 07 Jan 2010 9:44 pm
Weather Station: Davis VP2/WLL
Operating System: Bullseye Lite rPi
Location: Wilmslow, Cheshire, UK
Contact:

Re: Saratoga Base-* Templates and PHP 8

Post by mcrossley »

saratogaWX wrote: Sat 04 Dec 2021 12:53 am PHP 7 seemed to do the typing-to-integer automatically, PHP 8 insists on having it match the integer index.
Actually, I think PHP 8 still does, it is only a deprecation notice not an error. The change will come in PHP 9?
BCJKiwi
Posts: 1255
Joined: Mon 09 Jul 2012 8:40 pm
Weather Station: Davis VP2 Cabled
Operating System: Windows 10 Pro
Location: Auckland, New Zealand
Contact:

Re: Saratoga Base-* Templates and PHP 8

Post by BCJKiwi »

Well, the deprecation warnings were up AND the relevant code was not executed.
User avatar
mcrossley
Posts: 12689
Joined: Thu 07 Jan 2010 9:44 pm
Weather Station: Davis VP2/WLL
Operating System: Bullseye Lite rPi
Location: Wilmslow, Cheshire, UK
Contact:

Re: Saratoga Base-* Templates and PHP 8

Post by mcrossley »

Hmm, I stand corrected then. But deprecation warnings are normally just that. A warning that something will stop working in a future release, otherwise it is an error.
BCJKiwi
Posts: 1255
Joined: Mon 09 Jul 2012 8:40 pm
Weather Station: Davis VP2 Cabled
Operating System: Windows 10 Pro
Location: Auckland, New Zealand
Contact:

Re: Saratoga Base-* Templates and PHP 8

Post by BCJKiwi »

@ Mark

You may be correct (partially?) as some things were definitely not working.
The page was some what unreadable with multiple deprecation notices all over the place for different errors despite error notification being turned off.

Have found other issues with php 8.1.0 that do not occur with 8.0.13

It seems 8.1.0 has introduced numerous additional changes.
Post Reply