Update to php8

Hi
I have been using PWS dashboard for ages now and have now decided to update to php 8. When I update the server with my Provider (IONOS) to PHP 8 the website wont load, but on php 7.4 it works fine.

I uploaded a test site using PHP8 and that loaded fine, so is there a tool, command that I can use/lookat to see which blocks if any are causing the problem.
Thanks

Hi,

The current 2012_lts release is tested with PHP 8.1.13

check 2.1 : Your current PHP version is  : 8.1.13

If you are using a higher version please use . . . your website . . /startHere.php and note down the version.
IONOS.eu uses 8.0, 8.1 for which PWDS_Dashboard is fully tested.
But it serves 8.2 also.
=> That version is not extensively tested as I have limited access to a 8.2 test server.
=> PHP 8.2 was introduced on Dec 8, not yet available for my own test-servers.
==> Important: always re-run . ./pwsWD/startHere.php just to make sure that all php modules are included (f.i. xml and GD support)
==> Important: check Saratoga scripts such as NWS-alerts, see next post from Ken True (saratogaWX)

All PHP errors / all versions:
As not all scripts are original PWS_Dashboard scripts I need to see the errors, please copy the errors and add them to a .txt file, zip them and post the zip.

You should see the errors / cause of the blank screen by adding ?test to the url
Or even better use . . your website . . /_test.php

Also you could pinpoint problems with . . your website . . /PWS_module_test.php

Be aware that most providers have a different folder structure when moving to PHP 8.
It is the same as when moving to another provider and the scripts will therefor loose contact with included file-load scripts.

You should always run

  1. . ./pwsWD/startHere.php => check for errors
  2. easyweather-setup when moving from PHP 7.x to PHP 8.x

PHP 8.2
Also there are not a lot of PHP 8.2 users in the coming months.
Most users will wait until at least 8.2.1 is available
Today (2022-12-28) the first PHP 8.2 is not widely available therefor not all dashboard scripts are tested with PHP 8.2
My resources are limited to 8.1.9 → 8.1.13 and only a few tests at a Raspberry with 8.2.0

Wim

Edit 2022-12-28 10:30 UTC → added warning to wait with 8.2 until version 8.2.1

I posted this on WXForum.net about PHP 8.2

Heads up - PHP 8.2 has a deprecation for variable definitions of ${varname}

I’ve just started testing the Saratoga templates and scripts and found that PHP 8.2 has a deprecation for a variable naming the is used in many of my (and others) scripts:

[b]"${var}" and "${expr}" style interpolation[/b]

The “${var}” and “${expr}” style of string interpolation is deprecated.
Use “$var”/“{$var}” and “{${expr}}”, respectively.

This means that all ${varname} have to be changed to {$varname} throughout the scripts. It’s as simple as doing a global find for “${” and replacing it with “{$” and it is backwards compatible to PHP 5.6 (in my testing).
I’ll be updating all my scripts with this shortly.

If you update your Saratoga site to PHP 8.2 before I finish the updates, be sure to turn off E_DEPRECATED in php error_reporting to not flood your error messages in your log (or displays on your website if display_errors is on).

Hi Ken,

I checked the Curly NWS scripts and there are also a few lines with “${”
PWS_dasboard users from the US are often using these scripts (Saratoga-Weather.org - Legacy Scripts) .

nws-alerts-details-inc.php - V1.07 - 15-May-2019
. ./nws-alerts/nws-alerts-details-inc.php:177: $zcllA = preg_replace(“/(.),(.)/”, ‘[${1},${2}]’, $zcll); // create center location formatted output from coordinates
. ./nws-alerts/nws-alerts-details-inc.php:179: $cs = preg_replace(“/(.),(.)/”, ‘[${1},${2}]’, $zv); // create formatted polygon coordinates

nws-alerts-log.php // Version 1.01 - 27-Jan-2018 - PHP7+ adjustments
. ./nws-alerts/nws-alerts-log.php:60: $l_date = preg_replace(“|(\d{4})(\d{2})(\d{2})|”, ‘${2}/${3}/${1}’, $log_date[1]); // make date readable
. ./nws-alerts/nws-alerts-log.php:72: $l_dateOLD = preg_replace(“|(\d{4})(\d{2})(\d{2})|”, ‘${2}/${3}/${1}’, $log_dateOLD2[1]);// make readable date

Thanks,
Wim

Hi Wim,

I found that the ‘[${1},${2}]’ has to be ‘[$1,$2]’ otherwise the { and } get included (which breaks the JavaScript.

Likewise ‘${2}/${3}/${1}’ can be replaced with ‘$2/$3/$1’

I don’t fully agree with their deprecation as the ${varname} notation has been with us from PHP 4+ and now is set for removal in PHP 9. Sigh.

In one of the classes used in get-USNO-sunmoon.php, I did encounter this deprecation.
I had to declare as ‘public’ each of the variables that were dynamically defined.

Does this affect any of the new Saratoga dashboard files I downloaded this morning?

No… the distributed versions in Base-USA were correct. Only the legacy-scripts version hasn’t been updated (yet). The nws-alerts-details-inc.php was the only script that needed change such as above, and that was done in Base-USA.

Base-World? And I only did a search (for ${ ) and replace (with {$ ) in the files I had already modified. . . as you suggested elsewhere.

EDIT: looks OK, I thought I remembered something similar in get-metar-conditions-inc.php. . . :slight_smile:

No, not Base-World. The Curly NWS scripts (nws-alerts*) are only in the Base-USA since they are USA specific and my comment about the two nws-alert instances were only for those scripts. Base-World has get-meteoalarm-warning-inc.php for alerts from meteoalarm.eu feeds.

Thanks, Ken :slight_smile:

I use IONOS as my host and updated to PHP 8.1.13 yesterday.

Overnight I have had some errors producing a red exclamation tick. The error shown is

./_my_settings/history.txt _history Stalled 1 days 19 hrs 30 mins 55 seconds max = 10 mins
$history[“last_roll_over”] _history_rollover Stalled 2 days 7 hrs 15 mins 55 seconds max = 23 hrs

If I run https://wx-watch.co.uk/pws/startHere.php all is reported on as ok.

However if I run Long Sutton, Lincs, UK Home Weather Station (cumulus version) all sorts of errors are thrown up.

Also if I run https://www.wx-watch.co.uk/pws/PWS_cron_stationcron.php nothing seems to happen (unless that’s me!)

Should I roll back to PHP 7.x ?

Thanks

Hi,
This is a new error, please leave as is so i can investigate.
I checked your scripts, they are recent.
I can not replicate it at my test server so i have to dig deeoper.

Wim

Ok

Many thanks

I will leave everything as it is

I have no idea why this is happening.
I tested with multiple 8.1.x versions but not your version 8.1.13

Make a copy of your current PWS_load_files.php
Unzip and upload this test version.

I added 1 one line in the script to bypass the missing data.
We can see if other errors pop-up.

Wim


PWS_load_files.php.zip (7.27 KB)

Uploaded

No tick of any colour but curl https://www.wx-watch.co.uk/pws/PWS_cron_stationcron.php

Now produces

success files loaded + history recalculated + history saved + need upload to others + 0 uploads + no roll-over needed

Long Sutton, Lincs, UK Home Weather Station (cumulus version) produces MANY errors!

That is the correct output. The thick comes from the load files script

https://wx-watch.co.uk/pws/_test.php produces [b]MANY[/b] errors!

What PHP 8.1 errors are you referring to?
The extra temp block will give identical errors with PHP 7.x
change line 74 in your version of the script to

$lines  = 3;

as you left only three sensor descriptions in the script, not 6 as that line reads now.

The messages in the footer are the debug messages from PWS_load_files.php
The last line of those messages is the one I added.
PWS_load_files.php (63) missing $statuses array with PHP version8.1.13
It seems that the array-contents which should be loaded or defined in line 44 or 45 is lost and replaced with a boolean value
Can be either
a specific PHP 8.1.13 error
or
some new error in the PWS_load_files.php

I have no access to a web-server running PHP 8.1.13
I can therefor not test if this is a PHP problem or anything else.

Continue to use the test-version of PWS_load_files.php and, if possible, check your webserver settings if another PHP 8.1 version can be selected.

Succes,
Wim

I am on Hostinger and recently switched to PHP 8.2 and all is well here.

Regards,
Jim

:thumbright:

My template runs on PHP 8.1.13 at one.com in Denmark.
I don’t experience any problems in that regard.

Mogens

Ok - I have edited 74 as recommended and downgraded to PH 8.0.26

As for the errors I mean when I run _test.php I get the following output - I have no idea what this is showing! :? :? :?

But is line relevant PWS_load_files.php (63) missing $statuses array with PHP version8.0.26