Author Topic: Forecast-compare script and PHP 8?  (Read 449 times)

0 Members and 1 Guest are viewing this topic.

Offline RickNY

  • Contributor
  • ***
  • Posts: 116
    • College Hills Weather - Farmingville, NY
Forecast-compare script and PHP 8?
« on: April 28, 2022, 04:50:16 PM »
I'been using jmcmurry's WXSIM forecast-compare script for a while... Figured I would try to start sorting out PHP 8 issues since I'm on 7.4... I did run into some with PHP 8, I was just wondering if there are some known issues with this script?

I did have to clear my existing data for forecast results because I was using an older version that didn't use abbreviations for the special characters, and I thought that may have been my issue.

I guess I should wait until my cron jobs start populating the log files a bit -- but wanted to check if maybe I did something wrong on my end.

Thanks
Rick
« Last Edit: May 21, 2022, 08:02:24 AM by RickNY »

Offline RickNY

  • Contributor
  • ***
  • Posts: 116
    • College Hills Weather - Farmingville, NY
Re: Forecast-compare script and PHP 8?
« Reply #1 on: April 28, 2022, 05:06:18 PM »
OK, I probably have to wait until I fill up more data again in my forecast logs again -- but so far I was able to correct things by changing:

Code: [Select]
if (count($deltas[$i])
to

Code: [Select]
if (count((array)$deltas[$i])
on Lines 798, 850, and 903 of forecast-compare-include.php

Offline RickNY

  • Contributor
  • ***
  • Posts: 116
    • College Hills Weather - Farmingville, NY
Re: Forecast-compare script and PHP 8?
« Reply #2 on: May 20, 2022, 03:16:18 PM »

Another change I needed to make with PHP 8.1.5 to get my logs to start working.  Was receiving this error when forecast-compare-include.php fired:
Code: [Select]
Fatal error</b>: Uncaught TypeError: date(): Argument #2 ($timestamp) must be of type ?int, string given in /home/indigopc/public_html/forecast-compare-include.php:254
Changed Line 254 from:
Code: [Select]
if ($WSUpdate == date($mask,$entry[0])) {        // then we have an entry for that day
to

Code: [Select]
if ($WSUpdate == date($mask,(int)$entry[0])) {        // then we have an entry for that day



Offline RickNY

  • Contributor
  • ***
  • Posts: 116
    • College Hills Weather - Farmingville, NY
Re: Forecast-compare script and PHP 8?
« Reply #3 on: May 20, 2022, 05:36:56 PM »

Some more changes related to date() -- I think this should be all of them:

Line 370:
Code: [Select]
$fday = date("m/d/Y",$entry[0]);  //  ** Do not change this!!! ** - it is just to determine day/nightto
Code: [Select]
$fday = date("m/d/Y",(int)$entry[0]);  //  ** Do not change this!!! ** - it is just to determine day/night
Line 454:
Code: [Select]
<td><?php echo $Langupdated date($FCdatestr,$entry[0]) . $Langat date($FCtimestr,$entry[0]); ?> </td>to
Code: [Select]
<td><?php echo $Langupdated date($FCdatestr,$(int)entry[0]) . $Langat date($FCtimestr,(int)$entry[0]); ?> </td>
Line 532:
Code: [Select]
echo date($FCdatestr,$entry[0]);to
Code: [Select]
echo date($FCdatestr,(int)$entry[0]);
Line 534:
Code: [Select]
echo "<br />" . date($FCtimestr,$entry[0]);to
Code: [Select]
echo "<br />" . date($FCtimestr,(int)$entry[0]);
Line 957:
Code: [Select]
echo '>' . date($FCdatestr,$entry[0]) . '</option>' . "\n";to
Code: [Select]
echo '>' . date($FCdatestr,(int)$entry[0]) . '</option>' . "\n";

 

anything