Author Topic: Upgraded to PHP 8.0.3 - wxindex.php not working  (Read 1216 times)

0 Members and 1 Guest are viewing this topic.

Offline mexbound

  • Senior Member
  • **
  • Posts: 66
Upgraded to PHP 8.0.3 - wxindex.php not working
« on: June 07, 2021, 11:48:28 AM »
This morning I tried upgrading my godaddy hosting to PHP8. I then tried my wxindex.php and it didn't get very far. My site is not live so that is why I tried going to PHP8. I have lots of time to debug it but I have to admit I do not know alot about PHP debugging. Where can I find an error log to start looking at?

Here is the site with PHP8: https://ajijicweather.com/wxindex.php

Any help getting me started is greatly appreciated.

Offline saratogaWX

  • Administrator
  • Forecaster
  • *****
  • Posts: 9244
  • Saratoga, CA, USA Weather - free PHP scripts
    • Saratoga-Weather.org
Re: Upgraded to PHP 8.0.3 - wxindex.php not working
« Reply #1 on: June 07, 2021, 12:21:47 PM »
It looks like something in ajax-dashboard6.php is blowing up.  Are you running the updated 6.95d version?

If not, try installing these updated versions and support scripts (attached).

Also, check the error_log on your site for details about PHP Fatal Errors -- if your site uses cPanel, there's a cPanel viewer for the error_log, otherwise, the error_log will be found in the same directory as the Apache access_log files for your website.

You can also try my ajax-dashboard6.php with debugging enabled here.
« Last Edit: June 07, 2021, 12:32:27 PM by saratogaWX »
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 mexbound

  • Senior Member
  • **
  • Posts: 66
Re: Upgraded to PHP 8.0.3 - wxindex.php not working
« Reply #2 on: June 07, 2021, 03:58:48 PM »
Ok, starting to get some progress here. Thanks for the input.
This was my first problem I encountered.  month and mday needed single quotes around them, Made that change in AltAjaxDashboardConfig6.php to this:
$month = $today['month'];
$day = $today['mday'];

I got further into the code.

Then I get this and not sure how to change it:

Fatal error: Uncaught Error: Attempt to assign property "date" on null in /home/mxo4kz4ohhnx/public_html/ajax-dashboard6.php:3461 Stack trace: #0 /home/mxo4kz4ohhnx/public_html/ajax-dashboard6.php(1336): getMoonInfo() #1 /home/mxo4kz4ohhnx/public_html/wxindex.php(70): include_once('/home/mxo4kz4oh...') #2 {main} thrown in /home/mxo4kz4ohhnx/public_html/ajax-dashboard6.php on line 3461

Line 3461 is:

@$info->date = $date;

And the following is directly from error_log:

[07-Jun-2021 13:40:56 America/Los_Angeles] PHP Fatal error:  Uncaught Error: Attempt to assign property "date" on null in /home/mxo4kz4ohhnx/public_html/ajax-dashboard6.php:3461
Stack trace:
#0 /home/mxo4kz4ohhnx/public_html/ajax-dashboard6.php(1336): getMoonInfo()
#1 /home/mxo4kz4ohhnx/public_html/wxindex.php(70): include_once('/home/mxo4kz4oh...')
#2 {main}
  thrown in /home/mxo4kz4ohhnx/public_html/ajax-dashboard6.php on line 3461
« Last Edit: June 07, 2021, 09:34:48 PM by mexbound »

Offline saratogaWX

  • Administrator
  • Forecaster
  • *****
  • Posts: 9244
  • Saratoga, CA, USA Weather - free PHP scripts
    • Saratoga-Weather.org
Re: Upgraded to PHP 8.0.3 - wxindex.php not working
« Reply #3 on: June 08, 2021, 10:54:06 AM »
To fix the fatal error in ajax-dashboard6.php, change
Code: [Select]
   @$info->date = $date;
to
Code: [Select]
$info = new STDclass;
   @$info->date = $date;
PHP8 got a bit fussy and won't instantiate a default class on first use if previously undefined (unlike prior PHP versions).  Adding the ' $info = new STDclass; ' fixes that issue by explicitly instantiating the class.
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 mexbound

  • Senior Member
  • **
  • Posts: 66
Re: Upgraded to PHP 8.0.3 - wxindex.php not working
« Reply #4 on: June 08, 2021, 12:10:06 PM »
Thanks a bunch for explaining that. You certainly have a good grasp of PHP.

So I made the change you showed me and it got me by that error.

It made it further along until this:

[08-Jun-2021 11:02:22 America/Mexico_City] PHP Fatal error:  Uncaught TypeError: abs(): Argument #1 ($num) must be of type int|float, string given in /home/mxo4kz4ohhnx/public_html/ajax-dashboard6.php:2298
Stack trace:
#0 /home/mxo4kz4ohhnx/public_html/ajax-dashboard6.php(2298): abs()
#1 /home/mxo4kz4ohhnx/public_html/wxindex.php(70): include_once('/home/mxo4kz4oh...')
#2 {main}
  thrown in /home/mxo4kz4ohhnx/public_html/ajax-dashboard6.php on line 2298

I am using all the AltDashboard_updates.zip you attached in post#2, so I have all the latest. One other thing I notice is I get a message that it cannot find my clientraw.txt file. I have the location for it set in Settings-weather.php: $SITE['clientrawfile']  = './WD_realtime/clientraw.txt';  // directory and name of Weather-Display realtime.txt file.

edit:  I was able to figure out why it wasn't finding my clientraw.txt file so that is not an issue.
« Last Edit: June 08, 2021, 03:40:57 PM by mexbound »

Offline mexbound

  • Senior Member
  • **
  • Posts: 66
Re: Upgraded to PHP 8.0.3 - wxindex.php not working
« Reply #5 on: June 09, 2021, 12:36:04 PM »
I was able to get around the "Uncaught TypeError: abs(): Argument #1 ($num) must be of type int|float," error by adding a settype line of code before the abs().

<?php settype($sevendayet,"float"); ?>
<span class="convRain"><?php echo abs($sevendayet) . $uomRain; ?> </span>

Not sure if this was the best method, but it works.

My next error is now in cloud-base.php. I am using the cloud-base.php you supplied in the zip file in post #2. I must be blind because I can't figure this one out:

[09-Jun-2021 16:28:32 UTC] PHP Parse error:  syntax error, unexpected token "," in /home/mxo4kz4ohhnx/public_html/cloud-base.php on line 863

if (match($imgMist,$clouds["pic"])) {                    <<<<<<<<<<<<<<< line 863
      $pt = $cldhgt==0?200:170;
      $cY = $pt - $clouds["base"] - round($cldhgt/$scale["step"]);;
   } else {
      $pt = 170 - round($cldhgt/$scale["step"]);
      $cY = $pt - $clouds["base"];
   }

https://ajijicweather.com/wxindex.php

Offline the beteljuice

  • the beteljuice
  • Forecaster
  • *****
  • Posts: 316
    • test site
Re: Upgraded to PHP 8.0.3 - wxindex.php not working
« Reply #6 on: June 09, 2021, 06:50:54 PM »
PHP 8.0 introduced function match()

... but that snippet is incorrect syntax / use of it  :roll:
Imagine what you will KNOW tomorrow !

Offline mexbound

  • Senior Member
  • **
  • Posts: 66
Re: Upgraded to PHP 8.0.3 - wxindex.php not working
« Reply #7 on: June 09, 2021, 08:22:53 PM »
Thanks for that Beteljuice!  The cloud-base.php already had a function named match() defined in it and now that PHP 8 has it's own function, that was causing the problem. I redefined the "match()" function in cloud-base.php to "cloud_match()" and changed all the places referring to it. Everything is working now. Woo-hoo!

Offline mexbound

  • Senior Member
  • **
  • Posts: 66
Re: Upgraded to PHP 8.0.3 - wxindex.php not working
« Reply #8 on: June 10, 2021, 05:37:30 PM »
So it looks like I have made all the changes necessary to run the templates on PHP 8.  Here is a summary of the changes from the posts above:

1. In AltAjaxDashboardConfig6.php - changed month and mday, they needed single quotes around them:
$month = $today['month'];
$day = $today['mday'];

2. In ajax-dashboard6.php - added a "STDclass" line above the line @$info->date = $date;
 $info = new STDclass;
   @$info->date = $date;

3. In ajax-dashboard6.php - added a "settype" line above the line <span class="convRain"><?php echo abs($sevendayet) . $uomRain; ?> </span>

<?php settype($sevendayet,"float"); ?>
<span class="convRain"><?php echo abs($sevendayet) . $uomRain; ?> </span>

4. In cloud-base.php - changed the function named match( ) to a new name of cloud_match( ) and changed all references of match( ) to cloud_match( ).

I'm currently doing some detail testing but all the main template files seem to be working correctly.

I do have some problems with PHP8 and the "Murray" wxtempdetail.php (and subsequent scripts). Will post in a different thread.

Offline mexbound

  • Senior Member
  • **
  • Posts: 66
Re: Upgraded to PHP 8.0.3 - wxindex.php not working
« Reply #9 on: June 22, 2021, 09:24:27 AM »
I found one more PHP8 change I needed to make. In cloud-base.php, line 1162, variable $metRainStopped is undefined. I defined it in the GLOBAL just above it and the error went away.

 

anything