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 4018) - 28 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

PHP errors with php 7.3.7

Discussion of Ken True's web site templates

Moderator: saratogaWX

Post Reply
User avatar
HansR
Posts: 5871
Joined: Sat 20 Oct 2012 6:53 am
Weather Station: GW1100 (WS80/WH40)
Operating System: Raspberry OS/Bullseye
Location: Wagenborgen (NL)
Contact:

PHP errors with php 7.3.7

Post by HansR »

Hi,

The server logfile is filling up pretty fast with php errors. I'd like to reduce the errors.
Some of them I have solved but these three I do not understand:

1) Totally not understood:

Code: Select all

AH01071: Got error '

PHP message: PHP Warning:  Invalid argument supplied for foreach() in /var/www/clients/client13104/web75415/web/get-USNO-sunmoon.php on line 361
PHP message: PHP Warning:  Invalid argument supplied for foreach() in /var/www/clients/client13104/web75415/web/get-USNO-sunmoon.php on line 372', 

referer: https://www.meteo-wagenborgen.nl/wxutilsmap.php

2) Also totally not understood:

Code: Select all

AH01071: Got error '

PHP message: PHP Notice:  A non well formed numeric value encountered in /var/www/clients/client13104/web75415/web/ajax-dashboard.php on line 526
PHP message: PHP Notice:  A non well formed numeric value encountered in /var/www/clients/client13104/web75415/web/ajax-dashboard.php on line 526'
3) I understand the problem, but the graphs work and I have not got the clue where to set the 'sharedir' variable to empty string:

Code: Select all

AH01071: Got error '

PHP message: PHP Notice:  Undefined variable: sharedir in /var/www/clients/client13104/web75415/web/wxgraphs.php on line 121
PHP message: PHP Notice:  Undefined variable: sharedir in /var/www/clients/client13104/web75415/web/wxgraphs.php on line 122
PHP message: PHP Notice:  Undefined variable: sharedir in /var/www/clients/client13104/web75415/web/wxgraphs.php on line 123
PHP message: PHP Notice:  Undefined variable: sharedir in /var/www/clients/client13104/web75415/web/wxgraphs.php on line 124'
And the following error I corrected myself (added the quotes) and is :

Code: Select all

AH01071: Got error 'PHP message: PHP Warning:  Use of undefined constant m - assumed 'm' (this will throw an Error in a future version of PHP) in /var/www/clients/client13104/web75415/web/wxnoaarecords-include.php on line 612'
I have the most recent template version (for the files involved).
Do the Check-Fetch-Times here, I use PHP version 7.3.7
Could you help? Thnx.
Hans

https://meteo-wagenborgen.nl
CMX build 4017+ ● RPi 3B+ ● Raspbian Linux 6.1.21-v7+ armv7l ● dotnet 8.0.3
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: PHP errors with php 7.3.7

Post by saratogaWX »

For (1) above, I ran a view-source on wxastronomy.php?force=1&debug=y and saw
<!-- get-USNO-sunmoon.php - Version 3.02 - 23-Nov-2018 -->
<!-- refetch seconds=1 -->
<!-- loading ./cache/USNO-moondata.txt from https://api.usno.navy.mil/rstt/oneday?d ... 31654&tz=1 -->
<!-- curl fetching 'https://api.usno.navy.mil/rstt/oneday?d ... 31654&tz=1' -->
<!-- curl Error: TCP connection reset by peer -->
<!-- HTTP stats: RC=0 dest=199.211.133.93 port=443 (from sce=46.235.40.106)
Times: dns=6.516 conn=13.747 pxfer=0.000 get=18.057 total=18.057 secs -->
<!-- headers returned:

-->
<!-- Error loading from USNO API, cache not saved -->
<!-- loading finished. -->
<!-- processing JSON entries for Moon data -->
<!-- rawJSON size is 0 bytes -->
<!-- rawJSON is '' -->
<!-- json_decode returns - Syntax error, malformed JSON -->
<!-- JSON
-->
<!-- note: 'fracillum' not in JSON, no 'illumination' is available. -->
<!-- USNOdata
Array
(
[databy] => USNO
)
-->
note that cURL had an issue connecting to api.usno.navy.mil site, so no data was returned and the PHP Warnings were the result of no data to process.
I suggest you add $SITE['useUSNO']=false; to your Settings.php to bypass the issue and use internal calculations instead of the USNO for the moon data.

for (2) above, the line 526-527 in ajax-dashboard.php is

Code: Select all

	if ( (strip_units($avgspd) + strip_units($gstspd) < 0.1 ) and
     ($wrCalm <> '') ) { // use calm instead
The strip_units() function

Code: Select all

function strip_units ($data) {
  preg_match('/([\d\,\.\+\-]+)/',$data,$t);
  return $t[1];
}
should just keep numeric data and flush any units/spaces in the data.
$avgspd and $gstspd are formed in CU-defs.php

Code: Select all

$avgspd = $WX['wspeed'];
$gstspd = $WX['wgust'];
and looking at your CUtags.php?sce=dump shows

Code: Select all

$WX['wspeed'] = '0,0';
$WX['wgust'] = '0,0';
Since you're using comma-decimal notation, and PHP is expecting period-decimal, it casts the Notice errata I think.

for (3), I don't know .. the wxgraphs.php page is not my script. The Saratoga template has a wxgraphs.php that is for Cumulus 1.9.4 only (images, not HighCharts).

for (4), the wxnoaarecords-include.php error is in a script not a part of the Saratoga distribution .. you'll need to consult the script author about that. You may be able to fix it (on your line 612) by simply changing m to 'm' , but I don't really know as I don't have that script.

Hope this helps...
User avatar
HansR
Posts: 5871
Joined: Sat 20 Oct 2012 6:53 am
Weather Station: GW1100 (WS80/WH40)
Operating System: Raspberry OS/Bullseye
Location: Wagenborgen (NL)
Contact:

Re: PHP errors with php 7.3.7

Post by HansR »

1) Thnx, OK, done.
2) But there is comma's all over the place. and strip_units is used multiple times but only in this line there is a problem.
3) Yes, that's the one, I tweaked it so I could use it. Apparently, sharedir escaped my attention, I'll look deeper. Thnx.
4) OK, sorry thought it was yours. I did indeed change m to 'm'. Thnx.

So, it helped. I am a lot further, it's only 2) which I still do not really see how to solve. I have no influence on the generation of CU-defs.php the comma's are generated by Cumulus (and why don't I see a problem in the dashboard or anywhere) and why only with the speed. I don't get it.
Hans

https://meteo-wagenborgen.nl
CMX build 4017+ ● RPi 3B+ ● Raspbian Linux 6.1.21-v7+ armv7l ● dotnet 8.0.3
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: PHP errors with php 7.3.7

Post by saratogaWX »

Please attach a .zip of your current ajax-dashboard.php and I'll take a look.

Glad the other 3 issues were resolved.
User avatar
beteljuice
Posts: 3292
Joined: Tue 09 Dec 2008 1:37 pm
Weather Station: None !
Operating System: W10 - Threadripper 16core, etc
Location: Dudley, West Midlands, UK

Re: PHP errors with php 7.3.7

Post by beteljuice »

2) But there is comma's all over the place. and strip_units is used multiple times but only in this line there is a problem.
Not true ... I've seen other (comma) problems appearing with this function.
In the past it has failed "quietly" and in the most part unnoticed.

Code: Select all

<?php
ini_set('display_startup_errors',1);
ini_set('display_errors',1);
error_reporting(-1);
error_reporting(E_ALL);

$var1 = '1,6';
$var2 = '3,9';

// if ( (strip_units($avgspd) + strip_units($gstspd) < 0.1 ) and ($wrCalm <> '') );
echo "strip_inits(values) ...<br />"
echo "\$var1: ".strip_units ($var1). " \$var2: " .strip_units ($var2). "<br /><br />";
echo "\$var1 + \$var2 = " .($var1 + $var2);

function strip_units ($data) {
  preg_match('/([\d\,\.\+\-]+)/',$data,$t);
  return $t[1];
}
?>

Output:

strip_inits(values) ...
$var1: 1,6 $var2: 3,9
$var1 + $var2 = 4
Note that only the (string) number before the comma is processed.
The + in the script mark-up

Code: Select all

 strip_units($avgspd) + strip_units($gstspd)
is explicitly saying it wants something that could be a number (not just a string), and now throws the error reports. (I think)
Last edited by beteljuice on Fri 22 Nov 2019 12:01 pm, edited 1 time in total.
Image
......................Imagine, what you will KNOW tomorrow !
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: PHP errors with php 7.3.7

Post by saratogaWX »

Yes, the use of strip_units() calls are all over the place, but the usage in

Code: Select all

if ( (strip_units($avgspd) + strip_units($gstspd) < 0.1 ) and
     ($wrCalm <> '') ) { // use calm instead
is the only instance where the return values of the function are used in an arithmetic statement, so their values should use PHP's default of period-decimal and are instead returning the comma-decimal format.

You can fix the issue by passing the period-decimal numbers with

Code: Select all

if ( (strip_units(str_replace(',','.',$avgspd)) + strip_units(str_replace(',','.',$gstspd)) < 0.1 ) and
     ($wrCalm <> '') ) { // use calm instead
which should solve the comma-decimal issue. The other places simply print the return value of the function, so no replacement is needed.

PHP 7+ has much stronger variable typing and so the string to be processed as a number must follow the PHP default period-decimal format to be used in math equasions.
User avatar
HansR
Posts: 5871
Joined: Sat 20 Oct 2012 6:53 am
Weather Station: GW1100 (WS80/WH40)
Operating System: Raspberry OS/Bullseye
Location: Wagenborgen (NL)
Contact:

Re: PHP errors with php 7.3.7

Post by HansR »

@beteljuice: Welcome back!
@saratogaWX:
Thank you both, this gave some understanding :arrow: and it worked :arrow: :clap:

Working the apache errorlog to zero fails is not as easy as it looks, sometimes I am surprised the website is showing something at all ;)

(and I assume you do not need the current ajax-dashboard.php anymore)
Hans

https://meteo-wagenborgen.nl
CMX build 4017+ ● RPi 3B+ ● Raspbian Linux 6.1.21-v7+ armv7l ● dotnet 8.0.3
User avatar
HansR
Posts: 5871
Joined: Sat 20 Oct 2012 6:53 am
Weather Station: GW1100 (WS80/WH40)
Operating System: Raspberry OS/Bullseye
Location: Wagenborgen (NL)
Contact:

Re: PHP errors with php 7.3.7

Post by HansR »

So the error log is much clearer now, but still I got that 1071 error for some other files/lines:

Code: Select all

PHP message: 
PHP Warning:  A non-numeric value encountered in /var/www/clients/client13104/web75415/web/wxwinddirectiondetail.php on line 399
This is dumped as one entry in the logfile for hundreds of times.
Could you shed a light on this one too? (may have to do with strip_tilde which I cannot find?)
Hans

https://meteo-wagenborgen.nl
CMX build 4017+ ● RPi 3B+ ● Raspbian Linux 6.1.21-v7+ armv7l ● dotnet 8.0.3
User avatar
HansR
Posts: 5871
Joined: Sat 20 Oct 2012 6:53 am
Weather Station: GW1100 (WS80/WH40)
Operating System: Raspberry OS/Bullseye
Location: Wagenborgen (NL)
Contact:

Re: PHP errors with php 7.3.7

Post by HansR »

Ah, I see, this one isn't by you either.
Sorry :?
Hans

https://meteo-wagenborgen.nl
CMX build 4017+ ● RPi 3B+ ● Raspbian Linux 6.1.21-v7+ armv7l ● dotnet 8.0.3
User avatar
ConligWX
Posts: 1573
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: PHP errors with php 7.3.7

Post by ConligWX »

HansR wrote: Fri 22 Nov 2019 1:55 pm Ah, I see, this one isn't by you either.
Sorry :?
looks like you need to update some scripts.

https://meteo-wagenborgen.nl/check-fetc ... w=versions
Regards Simon

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

Image
User avatar
HansR
Posts: 5871
Joined: Sat 20 Oct 2012 6:53 am
Weather Station: GW1100 (WS80/WH40)
Operating System: Raspberry OS/Bullseye
Location: Wagenborgen (NL)
Contact:

Re: PHP errors with php 7.3.7

Post by HansR »

Yes, might do that but I don't use quake etc...
Did do it all manually though, so all problems are fixed.
Hans

https://meteo-wagenborgen.nl
CMX build 4017+ ● RPi 3B+ ● Raspbian Linux 6.1.21-v7+ armv7l ● dotnet 8.0.3
Post Reply