Author Topic: NWS (Atom) Alerts for Saratoga Templates PHP 7.1 problem  (Read 5125 times)

0 Members and 1 Guest are viewing this topic.

Offline cirrus

  • Kevin Hough
  • Member
  • *
  • Posts: 48
  • Davis Vantage Pro2 Plus
    • Gorge-East Weather
NWS (Atom) Alerts for Saratoga Templates PHP 7.1 problem
« on: January 02, 2017, 05:26:22 AM »
Hello Ken!,
Just thought I'd give you a heads up that the Atom Warnings throws illegal string warnings on the array using PHP 7.1 ... reverted back to PHP 7.0 and all is well.

Example of PHP 7.1 errors when running nws-alerts.php:

Warning: A non-numeric value encountered in /home/rkcrk201/public_html/nws-alerts.php on line 127

Warning: Illegal string offset 'Central Col. R. Gorge, OR' in /home/rkcrk201/public_html/nws-alerts.php on line 219

Warning: Illegal string offset 'N. OR Cascades' in /home/rkcrk201/public_html/nws-alerts.php on line 219

Warning: Illegal string offset 'S. WA Cascades' in /home/rkcrk201/public_html/nws-alerts.php on line 219

Warning: Illegal string offset 'W. Col. R. Gorge, OR' in /home/rkcrk201/public_html/nws-alerts.php on line 219

Warning: Illegal string offset 'ORZ041' in /home/rkcrk201/public_html/nws-alerts.php on line 308

Fatal error: Uncaught Error: Cannot use string offset as an array in /home/rkcrk201/public_html/nws-alerts.php:308 Stack trace: #0 {main} thrown in /home/rkcrk201/public_html/nws-alerts.php on line 308


Best Regards,
-Kevin
« Last Edit: January 02, 2017, 05:48:54 AM by cirrus »
Regards, --Kevin


Offline yamiacaveman

  • Forecaster
  • *****
  • Posts: 439
    • Penn Lake Weather
Re: NWS (Atom) Alerts for Saratoga Templates PHP 7.1 problem
« Reply #1 on: January 02, 2017, 12:13:26 PM »
www.pennlake.us

I'm using 7.1 and I don't seem to be having any issues.

yamiacaveman

Offline cirrus

  • Kevin Hough
  • Member
  • *
  • Posts: 48
  • Davis Vantage Pro2 Plus
    • Gorge-East Weather
Re: NWS (Atom) Alerts for Saratoga Templates PHP 7.1 problem
« Reply #2 on: January 02, 2017, 04:21:09 PM »
www.pennlake.us

I'm using 7.1 and I don't seem to be having any issues.

yamiacaveman

How many NWS alert zones are you using? I'm using 8 zones with cron to run nws-alerts.php
Regards, --Kevin


Offline yamiacaveman

  • Forecaster
  • *****
  • Posts: 439
    • Penn Lake Weather
Re: NWS (Atom) Alerts for Saratoga Templates PHP 7.1 problem
« Reply #3 on: January 02, 2017, 08:45:10 PM »
I am using 10 well 11 I have my town listed separately but I also have an alert for my county, which of-course my town is in, running a cron job on the server.

Offline cirrus

  • Kevin Hough
  • Member
  • *
  • Posts: 48
  • Davis Vantage Pro2 Plus
    • Gorge-East Weather
Re: NWS (Atom) Alerts for Saratoga Templates PHP 7.1 problem
« Reply #4 on: January 02, 2017, 09:04:09 PM »
Okay thanks...I don't know why the php 7.1 version on mine throws errors but my 7.0 version is fine... hopefully Ken can help
Regards, --Kevin


Offline yamiacaveman

  • Forecaster
  • *****
  • Posts: 439
    • Penn Lake Weather
Re: NWS (Atom) Alerts for Saratoga Templates PHP 7.1 problem
« Reply #5 on: January 02, 2017, 09:30:49 PM »
I wish I could help you out more but I haven't a clue. I am also running the Meteotemplate and that works fine also in 7.1

Offline saratogaWX

  • Administrator
  • Forecaster
  • *****
  • Posts: 9257
  • Saratoga, CA, USA Weather - free PHP scripts
    • Saratoga-Weather.org
Re: NWS (Atom) Alerts for Saratoga Templates PHP 7.1 problem
« Reply #6 on: January 03, 2017, 11:11:15 AM »
Hello Ken!,
Just thought I'd give you a heads up that the Atom Warnings throws illegal string warnings on the array using PHP 7.1 ... reverted back to PHP 7.0 and all is well.

Example of PHP 7.1 errors when running nws-alerts.php:

Warning: A non-numeric value encountered in /home/rkcrk201/public_html/nws-alerts.php on line 127

Warning: Illegal string offset 'Central Col. R. Gorge, OR' in /home/rkcrk201/public_html/nws-alerts.php on line 219

Warning: Illegal string offset 'N. OR Cascades' in /home/rkcrk201/public_html/nws-alerts.php on line 219

Warning: Illegal string offset 'S. WA Cascades' in /home/rkcrk201/public_html/nws-alerts.php on line 219

Warning: Illegal string offset 'W. Col. R. Gorge, OR' in /home/rkcrk201/public_html/nws-alerts.php on line 219

Warning: Illegal string offset 'ORZ041' in /home/rkcrk201/public_html/nws-alerts.php on line 308

Fatal error: Uncaught Error: Cannot use string offset as an array in /home/rkcrk201/public_html/nws-alerts.php:308 Stack trace: #0 {main} thrown in /home/rkcrk201/public_html/nws-alerts.php on line 308


Best Regards,
-Kevin

that is very odd.  I'm still in Illinois so access to my debugging tools is limited.  I did download a copy of your nws-alerts.php and it appears to match with the current version (minus one comment line).

Looking at the errors reported, the line 127 error is in
Code: [Select]
  $cmyzc += substr_count($myv, '|'); // total count of codes in $myZC array
which is valid syntax for the substr_count() function.

The line 219 errors are in
Code: [Select]
    $noAlrt[$nk] = $nv[0];                                                                                    which should be alright if $noAlrt was previously declared to be an array().  On line 103, it is declared as a string by
Code: [Select]
$noAlrt  = '';
so should probably be
Code: [Select]
$noAlrt  = array(); to avoid that type conversion.  Similarly:


The line 308 errors are in
Code: [Select]
            $ad[$lCode][] = array($event,$urgency,$severity,$certainty,$effective,$expires,
                            $areaDesc,$instruction,$description,$clr,$ico,$sev,$cvk,$WA,$cvv[0],$poly,$ck);   
which (again) should be ok if $ad has been previously declared to be an array() .. unfortunately, that was declared
Code: [Select]
$ad      = ''; on line 101.  It should likely be
Code: [Select]
$ad      = array();
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 Curly

  • Forecaster
  • *****
  • Posts: 724
    • Michiana Weather
Re: NWS (Atom) Alerts for Saratoga Templates PHP 7.1 problem
« Reply #7 on: January 03, 2017, 11:31:44 AM »
Try removing the periods and commas in the locations.

Offline BCJKiwi

  • Forecaster
  • *****
  • Posts: 302
    • Silver Acorn Weather - N.Z.
Re: NWS (Atom) Alerts for Saratoga Templates PHP 7.1 problem
« Reply #8 on: January 03, 2017, 03:35:13 PM »
The likely issue is with the php 7.1 handling of arrays.

php 7.0 made some changes in array handling. php 7.1 has made further significant changes to array handling.

http://php.net/manual/en/migration71.incompatible.php
Of interest is;
The empty index operator is not supported for strings anymore
Applying the empty index operator to a string (e.g. $str[] = $x) throws a fatal error instead of converting silently to array.

Offline Curly

  • Forecaster
  • *****
  • Posts: 724
    • Michiana Weather
Re: NWS (Atom) Alerts for Saratoga Templates PHP 7.1 problem
« Reply #9 on: January 03, 2017, 06:23:30 PM »
I've made the two changes per Kens recommendations.

You can download the single file here:
http://www.weather.ricksturf.com/scripts/nws-alerts_138.zip

Offline cirrus

  • Kevin Hough
  • Member
  • *
  • Posts: 48
  • Davis Vantage Pro2 Plus
    • Gorge-East Weather
Re: NWS (Atom) Alerts for Saratoga Templates PHP 7.1 problem
« Reply #10 on: January 03, 2017, 10:14:41 PM »
I've made the two changes per Kens recommendations.

You can download the single file here:
http://www.weather.ricksturf.com/scripts/nws-alerts_138.zip

Hi Curly,
Tried it out on 7.1 but it produced errors;

Warning: A non-numeric value encountered in /home/rkcrk201/public_html/nws-alerts.php on line 128

Warning: Illegal string offset 'ORC065' in /home/rkcrk201/public_html/nws-alerts.php on line 327

Warning: Illegal string offset 'ORC065' in /home/rkcrk201/public_html/nws-alerts.php on line 327

Warning: Illegal string offset 'ORC065' in /home/rkcrk201/public_html/nws-alerts.php on line 327

Warning: Illegal string offset 'ORC065' in /home/rkcrk201/public_html/nws-alerts.php on line 327

Warning: Illegal string offset 'ORZ510' in /home/rkcrk201/public_html/nws-alerts.php on line 327

Warning: Illegal string offset 'WAZ521' in /home/rkcrk201/public_html/nws-alerts.php on line 327

Warning: Invalid argument supplied for foreach() in /home/rkcrk201/public_html/nws-alerts.php on line 371

Warning: array_keys() expects parameter 1 to be array, null given in /home/rkcrk201/public_html/nws-alerts.php on line 391

Warning: array_shift() expects parameter 1 to be array, null given in /home/rkcrk201/public_html/nws-alerts.php on line 392

Warning: Invalid argument supplied for foreach() in /home/rkcrk201/public_html/nws-alerts.php on line 473

Warning: Invalid argument supplied for foreach() in /home/rkcrk201/public_html/nws-alerts.php on line 518

Warning: Invalid argument supplied for foreach() in /home/rkcrk201/public_html/nws-alerts.php on line 599

Warning: A non-numeric value encountered in /home/rkcrk201/public_html/nws-alerts.php on line 1088


Works fine on 7.0 though

Regards,
-Kevin
« Last Edit: January 03, 2017, 10:53:25 PM by cirrus »
Regards, --Kevin


Offline Curly

  • Forecaster
  • *****
  • Posts: 724
    • Michiana Weather
Re: NWS (Atom) Alerts for Saratoga Templates PHP 7.1 problem
« Reply #11 on: January 04, 2017, 04:41:16 AM »
Quote
Tried it out on 7.1 but it produced errors;

Have you tried it with the commas removed from the locations?

Offline cirrus

  • Kevin Hough
  • Member
  • *
  • Posts: 48
  • Davis Vantage Pro2 Plus
    • Gorge-East Weather
Re: NWS (Atom) Alerts for Saratoga Templates PHP 7.1 problem
« Reply #12 on: January 04, 2017, 08:59:51 PM »
Quote
Tried it out on 7.1 but it produced errors;

Have you tried it with the commas removed from the locations?

Curly,
I tried that with and without your nws-alerts.php mods and nws-alerts.php nor index.php would load at all.
Regards,
-Kevin
Regards, --Kevin


Offline yamiacaveman

  • Forecaster
  • *****
  • Posts: 439
    • Penn Lake Weather
Re: NWS (Atom) Alerts for Saratoga Templates PHP 7.1 problem
« Reply #13 on: January 08, 2017, 03:27:08 PM »
Ok  -- Now it's my turn  -- Had to switch back to PHP 7.0 for the alerts to work.

Is there a resolution to this problem? No problem if not, I'll just stay at 7.0 for now



Offline yamiacaveman

  • Forecaster
  • *****
  • Posts: 439
    • Penn Lake Weather
Re: NWS (Atom) Alerts for Saratoga Templates PHP 7.1 problem
« Reply #14 on: January 08, 2017, 03:30:28 PM »
So -- This is what I get in the Alert box instead of the warning: Well let me say this the alert part works but when I go to the specific County I get the stuff below.

Fatal error: Uncaught Error: [] operator not supported for strings in /home/pennla7/public_html/nws-alerts-details-inc.php:137 Stack trace: #0 /home/pennla7/public_html/wxnws-details.php(52): include() #1 {main} thrown in /home/pennla7/public_html/nws-alerts-details-inc.php on line 137

Offline Curly

  • Forecaster
  • *****
  • Posts: 724
    • Michiana Weather
Re: NWS (Atom) Alerts for Saratoga Templates PHP 7.1 problem
« Reply #15 on: January 08, 2017, 07:31:22 PM »
As soon as I have access to ver 7.1, I'll get to work on a fix.

Offline yamiacaveman

  • Forecaster
  • *****
  • Posts: 439
    • Penn Lake Weather
Re: NWS (Atom) Alerts for Saratoga Templates PHP 7.1 problem
« Reply #16 on: January 08, 2017, 08:07:31 PM »
Hi Curly,
 
Like I said no hurry or problem for me, switching back to 7.0 is easy.

Just wanted to let someone know:  Funny, it worked up until today - I wonder what changed today??

Thanks

Offline Curly

  • Forecaster
  • *****
  • Posts: 724
    • Michiana Weather
Re: NWS (Atom) Alerts for Saratoga Templates PHP 7.1 problem
« Reply #17 on: March 06, 2017, 08:07:39 PM »
The errors are fixed for php ver 7.1.

Two non-configurable files were changed:
nws-alerts.php
nws-alerts-details-inc.php

http://www.weather.ricksturf.com/wxScripts.php

Offline yamiacaveman

  • Forecaster
  • *****
  • Posts: 439
    • Penn Lake Weather
Re: NWS (Atom) Alerts for Saratoga Templates PHP 7.1 problem
« Reply #18 on: March 07, 2017, 08:16:09 AM »
Thanks Curly,

I updated those two files and went up to 7.1

I won't have the ability to check on it today, but it seems to work now, and I will check on it when I can.

Thanks and thanks to ricksturf!

Offline nagnal

  • Member
  • *
  • Posts: 10
Re: NWS (Atom) Alerts for Saratoga Templates PHP 7.1 problem
« Reply #19 on: July 30, 2017, 03:34:47 AM »
Not working on PHP 7.1.1  any updates

Offline saratogaWX

  • Administrator
  • Forecaster
  • *****
  • Posts: 9257
  • Saratoga, CA, USA Weather - free PHP scripts
    • Saratoga-Weather.org
Re: NWS (Atom) Alerts for Saratoga Templates PHP 7.1 problem
« Reply #20 on: July 30, 2017, 10:02:50 AM »
'Not working' is a bit vague to diagnose a problem.

What is the URL to the page(s) not working?
What are the PHP error messages shown?
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 nagnal

  • Member
  • *
  • Posts: 10
Re: NWS (Atom) Alerts for Saratoga Templates PHP 7.1 problem
« Reply #21 on: July 30, 2017, 02:45:04 PM »
Sorry sir it was early when i posted this. I downloaded the above file and it took most of the errors away but these two
Warning: A non-numeric value encountered in C:\xampp\htdocs\weather\nws-alerts.php on line 128

Warning: A non-numeric value encountered in C:\xampp\htdocs\weather\nws-alerts.php on line 1088
my site is http://westsenecaweather.com

Offline saratogaWX

  • Administrator
  • Forecaster
  • *****
  • Posts: 9257
  • Saratoga, CA, USA Weather - free PHP scripts
    • Saratoga-Weather.org
Re: NWS (Atom) Alerts for Saratoga Templates PHP 7.1 problem
« Reply #22 on: July 30, 2017, 03:07:18 PM »
Thanks!

Looking at check-fetch-times.php?show=versions on your site shows you have a few template scripts to update (just not nws-alerts.php ;) )

The Line 128 error is in the middle line of
Code: [Select]
foreach ($myZC as $myv) {
  $cmyzc += substr_count($myv, '|'); // total count of codes in $myZC array
}
and $myZC comes from
Code: [Select]
if(isset ($SITE['NWSalertsCodes'])) {$myZC = $SITE['NWSalertsCodes'];}
and your Settings.php has
Code: [Select]
$SITE['NWSalertsCodes'] = array(
"Cattaraugus|NYC009",
"Chautauqua|NYC013",
"Erie|NYC029",
);

The error message may be caused by nws-alerts.php
Code: [Select]
$cmyzc   = '';
which initializes the $cmyzc as a null string.  Try changing that to
Code: [Select]
$cmyzc   = 0;
which would cast it as an integer instead.  Maybe PHP 7.1 is more fussy about variable typing.

For the other error at line 1088 which is the second line in
Code: [Select]
$total_times = '';
$total_times += ($time_stopTotal - $time_startTotal);
try changing that to
Code: [Select]
$total_times = 0;
$total_times += ($time_stopTotal - $time_startTotal);
for the same reason.
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 nagnal

  • Member
  • *
  • Posts: 10
Re: NWS (Atom) Alerts for Saratoga Templates PHP 7.1 problem
« Reply #23 on: July 30, 2017, 03:29:42 PM »
This one just poped up    Fatal error: Uncaught Error: [] operator not supported for strings in C:\xampp\htdocs\weather\nws-alerts.php:307 Stack trace: #0 C:\xampp\htdocs\weather\header.php(41): include_once() #1 C:\xampp\htdocs\weather\index.php(43): include('C:\\xampp\\htdocs...') #2 {main} thrown in C:\xampp\htdocs\weather\nws-alerts.php on line 307

Offline saratogaWX

  • Administrator
  • Forecaster
  • *****
  • Posts: 9257
  • Saratoga, CA, USA Weather - free PHP scripts
    • Saratoga-Weather.org
Re: NWS (Atom) Alerts for Saratoga Templates PHP 7.1 problem
« Reply #24 on: July 30, 2017, 04:41:11 PM »
That's code
Code: [Select]
              (isset($abbrvd[1])) ? $abbrvDesc = $abbrvd[1] : $abbrvDesc = '';
              $logData[] = array($event,$cvk,$effective,$expires,$cis['icon'],$areaDesc,$abbrvDesc);
and it's caused by
Code: [Select]
$logData = '';
which should be
Code: [Select]
$logData = array();
Try that change...



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