TinyPortal

Development => Support => Topic started by: @rjen on May 23, 2017, 09:48:11 PM

Title: PHP 7 compatability for TP
Post by: @rjen on May 23, 2017, 09:48:11 PM
Today I bit the bullit and upgraded my forum to 2.0.14.
Did two manual corrections and all working fine.

Then I switched my site to PHP 7. Checked the error lof and immediately reverted to 5.6

A number of mods are not 7.0 compatible: TP being one of them.
I am running TP1.2R3

Errors I ran into in the few seconds before I reverted:

https://www.fjr-club.nl/index.php?page=36
8192: mktime(): You should be using the time() function instead
Bestand: /home/deb77453/domains/fjr-club.nl/public_html/Themes/default/TPsubs.template.php(127) : eval()'d code
Regel: 3

https://www.fjr-club.nl/index.php?action=unread;all
8: Array to string conversion
Bestand: /home/deb77453/domains/fjr-club.nl/public_html/Sources/TPortal.php
Regel: 2138

Any plans to look into the PHP7 compatibility of TP?
Title: Re: PHP 7 compatability for TP
Post by: illori on May 23, 2017, 10:50:58 PM
can you disable template eval and post the error messages without eval in them?

at this time there are no plans to make TP php 7 compatible as we dont have a real developer to do that.
Title: Re: PHP 7 compatability for TP
Post by: @rjen on May 24, 2017, 11:39:33 AM
Quote from: illori on May 23, 2017, 10:50:58 PM
can you disable template eval and post the error messages without eval in them?

at this time there are no plans to make TP php 7 compatible as we dont have a real developer to do that.

Not at the moment: my test forum and productive forum are on the same server, so I cannot put my test forum on PHP7 without bringing down the production forum.

I have another server running PHP7, so I can move my test forum there and test for real. This may be later this week. Bear in mind: without developer resources to look into it, is there really a point to test at this time?
Title: Re: PHP 7 compatability for TP
Post by: lurkalot on May 24, 2017, 08:37:30 PM
Quote from: @rjen on May 23, 2017, 09:48:11 PM

https://www.fjr-club.nl/index.php?page=36
8192: mktime(): You should be using the time() function instead
Bestand: /home/deb77453/domains/fjr-club.nl/public_html/Themes/default/TPsubs.template.php(127) : eval()'d code
Regel: 3


Do you have a custom calendar block on home page, just wondering where that mktime(): came from. I know the mini calendar block has it.  But it's not fond in any of the other tp files, they all seem to use time()



Title: Re: PHP 7 compatability for TP
Post by: @rjen on May 25, 2017, 07:35:48 AM
Yep, it is a Calendar block.
Any tips on how to fix this one?

global $scripturl, $smcFunc;

$now = mktime();
$today = date('j',$now);
$year = date("Y",$now);
$month = date("n",$now);
$days = array($today => array(NULL, NULL, '<a class="smalltext" style="color: steelblue; font-weight: bold; border: solid 1px black; background-color: white; padding: 0px 8px 0px 8px;" href="'.$scripturl.'?action=calendar;sa=view;month='.$month.';year='.$year.';day='.$today.'" target="_self">'.$today.'</a>'));

$day_name_length = 2;
$month_href = $scripturl . '?action=calendar';
$first_day = 1;
$pn = array();

$first_of_month = gmmktime(0,0,0,$month,1,$year);
//remember that mktime will automatically correct if invalid dates are entered
// for instance, mktime(0,0,0,12,32,1997) will be the date for Jan 1, 1998
// this provides a built in "rounding" feature to generate_calendar()

$day_names = array(); //generate all the day names according to the current locale
for($n=0,$t=(3+$first_day)*86400; $n<7; $n++,$t+=86400) //January 4, 1970 was a Sunday
$day_names[$n] = ucfirst(gmstrftime('%A',$t)); //%A means full textual day name

list($month, $year, $month_name, $weekday) = explode(',', gmstrftime('%m,%Y,%B,%w', $first_of_month));
$weekday = ($weekday + 7 - $first_day) % 7; //adjust for $first_day
$title   = $smcFunc['htmlspecialchars'](ucfirst($month_name)).' '.$year;  //note that some locales don't capitalize month and day names

//Begin calendar. Uses a real <caption>. See http://diveintomark.org/archives/2002/07/03
@list($p, $pl) = each($pn);
@list($n, $nl) = each($pn); //previous and next links, if applicable
if($p)
$p = '<span class="smalltext">'.($pl ? '<a href="'.htmlspecialchars($pl).'">'.$p.'</a>' : $p).'</span> ';
if($n)
$n = ' <span class="smalltext">'.($nl ? '<a href="'.htmlspecialchars($nl).'">'.$n.'</a>' : $n).'</span>';
$calendar = '<table>'."\n".
'<caption >'.$p.($month_href ? '<a href="'.htmlspecialchars($month_href).'">'.$title.'</a>' : $title).$n."</caption>\n<tr>";

if($day_name_length){ #if the day names should be shown ($day_name_length > 0)
//if day_name_length is >3, the full name of the day will be printed
foreach($day_names as $d)
$calendar .= '<th class="smalltext" abbr="'.htmlentities($d).'">'.htmlentities($day_name_length < 4 ? substr($d,0,$day_name_length) : $d).'</th>';

$calendar .= "</tr>\n<tr style=\"text-align:right;\">";
}

if($weekday > 0)
$calendar .= '<td class="smalltext" colspan="'.$weekday.'"> </td>'; //initial 'empty' days
for($day=1,$days_in_month=gmdate('t',$first_of_month); $day<=$days_in_month; $day++,$weekday++){
if($weekday == 7){
$weekday   = 0; #start a new week
$calendar .= "</tr>\n<tr style=\"text-align:right;\">";
}
if(isset($days[$day]) and is_array($days[$day])){
@list($link, $classes, $content) = $days[$day];
if(is_null($content)) 
$content  = $day;
$calendar .= '<td '.($classes ? ' class="'.htmlspecialchars($classes).'">' : '>').
($link ? '<a href="'.htmlspecialchars($link).'?">'.$content.'</a>' : $content).'</td>';
}
else
{
$calendar .= "<td class=\"smalltext\" style=\"padding-right:8px;\"><a";
if(((($weekday+$first_day) % 7)==0)||((($weekday+$first_day) % 7)==6))
{
$calendar .= ' style="color:#C00000;"';
}
$calendar .= " href=\"".$scripturl."?action=calendar;sa=view;month=".$month.";year=".$year.";day=".$day."\" target=\"_self\">$day</a></td>";
}
}
if($weekday != 7)
$calendar .= '<td class="smalltext" colspan="'.(7-$weekday).'"> </td>'; //remaining "empty" days

echo $calendar."</tr>\n</table>\n";

echo '<br/>';
$result = ssi_todaysEvents('array');

if (!empty($result))
{
   echo '<div class="smalltext"><b>Geplande activiteiten:</b></div>';
   echo '<div class="supersmalltext">';
   foreach ($result as $event)
      {
      $temp = explode('-', $event['date']);
      $event['date'] = $temp[2] . '-' . $temp[1] . '-' . $temp[0];
    echo '<a href="' . $event['href'] . '">' . $event['date'] . ' : ' . $event['title'] . '</a><br />';
      }
   echo '</div>';
}
else
{
      echo '<div class="supersmalltext">Er zijn geen evenementen gepland.<br /></div>';
  }

Title: Re: PHP 7 compatability for TP
Post by: lurkalot on May 25, 2017, 07:51:54 AM
I believe you need to change in your code, mktime(); to time();  as the error suggested.  Haven't a clue what else needs to be changed, as code is not my thing. 

Hopefully someone with the knowledge might come along and help with this. 
Title: Re: PHP 7 compatability for TP
Post by: @rjen on May 25, 2017, 08:16:34 AM
Quote from: lurkalot on May 25, 2017, 07:51:54 AM
I believe you need to change in your code, mktime(); to time();  as the error suggested.  Haven't a clue what else needs to be changed, as code is not my thing. 

Hopefully someone with the knowledge might come along and help with this.

I have just done that, and indeed, that seems to work.

I am now checking out the rest of the site, since I have built a test forum on the new server which is on php 7 now..
Title: Re: PHP 7 compatability for TP
Post by: lurkalot on May 25, 2017, 08:22:17 AM
Quote from: @rjen on May 25, 2017, 08:16:34 AM
Quote from: lurkalot on May 25, 2017, 07:51:54 AM
I believe you need to change in your code, mktime(); to time();  as the error suggested.  Haven't a clue what else needs to be changed, as code is not my thing. 

Hopefully someone with the knowledge might come along and help with this.

I have just done that, and indeed, that seems to work.

I am now checking out the rest of the site, since I have built a test forum on the new server which is on php 7 now..

Cool, got something right then. lol..  Thanks for testing and reporting, it will at least give us something to work up to. That piece of code mktime(); has been depreciated for a long time, I guess your new php version being stricter has just picked up on it
Title: Re: PHP 7 compatability for TP
Post by: @rjen on May 25, 2017, 08:38:01 AM
Ok, the good news is: I only had two errors on PHP7.0 those two I fixed succesfully: the time() issue and another issue with the proximus mod.

I switched to 7.0 for now in the live forum, no errors now, see how it goes.

The main issue is in PHP 7.1 (the second error) that really breaks the complete TP layout at this time. So 7.1 is the one to fix...
Title: Re: PHP 7 compatability for TP
Post by: lurkalot on May 25, 2017, 08:43:22 AM
Quote from: @rjen on May 25, 2017, 08:38:01 AM
Ok, the good news is: I only had two errors on PHP7.0 those two I fixed succesfully: the time() issue and another issue with the proximus mod.

I switched to 7.0 for now in the live forum, no errors now, see how it goes.

The main issue is in PHP 7.1 (the second error) that really breaks the complete TP layout at this time. So 7.1 is the one to fix...

Thanks for letting us know.  I will see if I can get help with that second one, it's beyond me atm.
Title: Re: PHP 7 compatability for TP
Post by: @rjen on May 25, 2017, 09:11:43 AM
This one might be relevant also:

I just found this error in my webhosts error log:

[Thu May 25 09:28:55.368469 2017] [lsapi:notice] [pid 373625:tid 140390126552832] [client 91.121.175.91:34525] [host www.fjr-club.nl] Backend log: PHP Deprecated:  Methods with the same name as their class will not be constructors in a future version of PHP; chain has a deprecated constructor in /home/deb77453/domains/fjr-club.nl/public_html/Sources/TPSubs.php on line 612\n
Title: Re: PHP 7 compatability for TP
Post by: lurkalot on June 09, 2017, 07:36:09 AM
@rjen Think you did say somewhere, but just to confirm, what version of TP were / are you testing with php 7 / 7.1 ?

Was it the very latest TP1.2R3 that allvip posted in the beta thread?
Title: Re: PHP 7 compatability for TP
Post by: @rjen on June 09, 2017, 01:00:08 PM
Quote from: lurkalot on June 09, 2017, 07:36:09 AM
@rjen Think you did say somewhere, but just to confirm, what version of TP were / are you testing with php 7 / 7.1 ?

Was it the very latest TP1.2R3 that allvip posted in the beta thread?

I believe so, but I am not 100% sure to be honest.

Since Allvip has reposted that version a number of times without changing version numbers I have lost track  :'(.
It would be nice if there was a formal version at some point (1.3R?) so we would be sure we are on the latest...
Title: Re: PHP 7 compatability for TP
Post by: lurkalot on June 09, 2017, 05:27:30 PM
Quote from: @rjen on June 09, 2017, 01:00:08 PM

I believe so, but I am not 100% sure to be honest.

Since Allvip has reposted that version a number of times without changing version numbers I have lost track  :'(.
It would be nice if there was a formal version at some point (1.3R?) so we would be sure we are on the latest...

Totally get what you're saying.  I lost track after the first few to be honest, I did try and get the new versions posted to the admin board first, so we could do a quick minor version change, but this just didn't happen for some reason.

As you're testing this particular version, and it works apart for a couple of errors, I might ask if you could attach that exact package here so we can take a look at it. 
Title: Re: PHP 7 compatability for TP
Post by: @rjen on June 09, 2017, 08:21:19 PM
I attached the package that I am currently using (and testing) to this post.

I tried to download the version from this post: http://www.tinyportal.net/index.php?topic=35806.msg289193#msg289193

But I am getting error: 404 - Attachment Not Found
???

Trying to upload an attachment now throws THIS error: Cannot access attachments upload path!
Seems this forum is in trouble now?
Title: Re: PHP 7 compatability for TP
Post by: illori on June 09, 2017, 08:34:38 PM
can you try again?
Title: Re: PHP 7 compatability for TP
Post by: @rjen on June 09, 2017, 08:36:25 PM
fixed
Title: Re: PHP 7 compatability for TP
Post by: lurkalot on June 09, 2017, 08:52:13 PM
Quote from: @rjen on June 09, 2017, 08:21:19 PM
I attached the package that I am currently using (and testing) to this post.

I tried to download the version from this post: http://www.tinyportal.net/index.php?topic=35806.msg289193#msg289193

But I am getting error: 404 - Attachment Not Found
???

Trying to upload an attachment now throws THIS error: Cannot access attachments upload path!
Seems this forum is in trouble now?

Thanks for adding that file. ;)  I guess we still have some path problems here due to the server move a couple of weeks ago.  Thankfully, looks like illori has got it under control.  ;).   
Title: Re: PHP 7 compatability for TP
Post by: lurkalot on June 11, 2017, 09:58:34 AM
Quote from: @rjen on May 25, 2017, 09:11:43 AM
This one might be relevant also:

I just found this error in my webhosts error log:

[Thu May 25 09:28:55.368469 2017] [lsapi:notice] [pid 373625:tid 140390126552832] [client 91.121.175.91:34525] [host www.fjr-club.nl] Backend log: PHP Deprecated:  Methods with the same name as their class will not be constructors in a future version of PHP; chain has a deprecated constructor in /home/deb77453/domains/fjr-club.nl/public_html/Sources/TPSubs.php on line 612\n

Try replacing the TPSubs.php file with the one I've attached, and see if it works out better
Title: Re: PHP 7 compatability for TP
Post by: @rjen on June 11, 2017, 09:59:26 PM
This version of the file seems to work. To be honest this is not my main concern:

this one is, because it is completely breaking Tinyportal on the website when php 7..1 is activated:

Quote8: Array to string conversion
Bestand: /home/deb77453/domains/fjr-club.nl/public_html/Sources/TPortal.php
Regel: 2138
Title: Re: PHP 7 compatability for TP
Post by: lurkalot on June 11, 2017, 10:13:35 PM
Quote from: @rjen on June 11, 2017, 09:59:26 PM
This version of the file seems to work. To be honest this is not my main concern:

this one is, because it is completely breaking Tinyportal on the website when php 7..1 is activated:

Quote8: Array to string conversion
Bestand: /home/deb77453/domains/fjr-club.nl/public_html/Sources/TPortal.php
Regel: 2138

Thanks, for testing, will have to see if this one can be fixed as well.  Last fix fixed was given to me by Pete aka Arantor. (Thanks Pete if you're reading this).
Title: Re: PHP 7 compatability for TP
Post by: lurkalot on June 11, 2017, 11:47:33 PM
Quote from: @rjen on June 11, 2017, 09:59:26 PM
This version of the file seems to work. To be honest this is not my main concern:

this one is, because it is completely breaking Tinyportal on the website when php 7..1 is activated:

Quote8: Array to string conversion
Bestand: /home/deb77453/domains/fjr-club.nl/public_html/Sources/TPortal.php
Regel: 2138

Ok. try replacing /Sources/TPortal.php with the one attached. Hopefully it will fix that issue with php 7..1
Title: Re: PHP 7 compatability for TP
Post by: @rjen on June 12, 2017, 12:49:14 PM
After replacing both files TP1.2R3 now works without errors on PHP version 7.1.

After succesfully testing it on my test server, I have now moved the code into the productive forum and switched that server to PHP7.1 as well.
So far so good: no error messages in the logs, and the forum operates fine.

I will let it run for a day or so and report back.

Maybe now it is time to release an official version op TP1.2R???

Title: Re: PHP 7 compatability for TP
Post by: lurkalot on June 12, 2017, 05:57:19 PM
Quote from: @rjen on June 12, 2017, 12:49:14 PM
After replacing both files TP1.2R3 now works without errors on PHP version 7.1.

After succesfully testing it on my test server, I have now moved the code into the productive forum and switched that server to PHP7.1 as well.
So far so good: no error messages in the logs, and the forum operates fine.

I will let it run for a day or so and report back.

Maybe now it is time to release an official version op TP1.2R???

Nice one.  8) Getting somewhere at least. As you correctly ascertained, those fixes can be applied to TP1.2 and TP2 for SMF 2.1 as well. Credit again goes to Pete AKA Arantor for these fixes.

As for the new release, well yes I'd like to, but atm I've no idea what 2.0.15 is going to include yet, and whether it'll break anything else related to TP.  Let us know if you find any problems in testing, thank you.   
Title: Re: PHP 7 compatability for TP
Post by: @rjen on June 13, 2017, 01:30:27 PM
After 24 hours nothing new to report: all working OK, no errors, and no complaints from users.
Title: Re: PHP 7 compatability for TP
Post by: lurkalot on June 13, 2017, 05:34:51 PM
Quote from: @rjen on June 13, 2017, 01:30:27 PM
After 24 hours nothing new to report: all working OK, no errors, and no complaints from users.

Looking good then, thank you.  By the way have you given the various options a workout on your test site, I would, but don't have a php 7.1 environment set up yet, looks like you're the only tester.  ;)
Title: Re: PHP 7 compatability for TP
Post by: lurkalot on June 16, 2017, 07:41:50 AM
Quote from: @rjen on June 13, 2017, 01:30:27 PM
After 24 hours nothing new to report: all working OK, no errors, and no complaints from users.

Everything still ok?  If so I might put a pre release of TP 1.3R in the public beta board.  It contains all those fixes and version changes so we can keep track.  I'm running it here, http://thegardenmachineryforum.co.uk atm.
Title: Re: PHP 7 compatability for TP
Post by: @rjen on June 17, 2017, 09:04:47 PM
Everything is working fine. No complaints and errors on the 'live' forum.

This evening I gave the test forum a whirl and I do not see any issues:

- created a new catageory
- created a new article
- added the article to the homepage
- activated a few standard blocks
- added entries into a menu
- added a menu bloch to the site
- changed the menu styling

Everything seems to work fine op PHP 7.1. I get no errors in the logs.

Title: Re: PHP 7 compatability for TP
Post by: lurkalot on June 18, 2017, 10:16:59 AM
Quote from: @rjen on June 17, 2017, 09:04:47 PM
Everything is working fine. No complaints and errors on the 'live' forum.

This evening I gave the test forum a whirl and I do not see any issues:

- created a new catageory
- created a new article
- added the article to the homepage
- activated a few standard blocks
- added entries into a menu
- added a menu bloch to the site
- changed the menu styling

Everything seems to work fine op PHP 7.1. I get no errors in the logs.

Excellent news.  Thanks for doing that for us, it's appreciated.  Getting ever closer to a release version methinks. 
Title: Re: PHP 7 compatability for TP
Post by: lurkalot on June 27, 2017, 08:23:05 AM
Quote from: @rjen on June 17, 2017, 09:04:47 PM
Everything is working fine. No complaints and errors on the 'live' forum.

This evening I gave the test forum a whirl and I do not see any issues:

- created a new catageory
- created a new article
- added the article to the homepage
- activated a few standard blocks
- added entries into a menu
- added a menu bloch to the site
- changed the menu styling

Everything seems to work fine op PHP 7.1. I get no errors in the logs.

Did you try adding front panel block?  Does that throw a error in the log after visiting the front page?
Title: Re: PHP 7 compatability for TP
Post by: Arantor on June 27, 2017, 08:37:53 AM
There's a few compat fixes in http://www.tinyportal.net/index.php?topic=35895.0 for anyone who is following this topic. It should fix one known issue for 7.1 and hopefully a 5.x compatibility issue (and might fix the front page issue here)
Title: Re: PHP 7 compatability for TP
Post by: lurkalot on June 27, 2017, 08:43:31 AM
Pete, thank you. 

I'll give those fixes a try tonight after work.  8) My day job always getting in the way of things and all that.

Title: Re: PHP 7 compatability for TP
Post by: @rjen on June 27, 2017, 12:51:22 PM
Quote from: lurkalot on June 27, 2017, 08:23:05 AM
Did you try adding front panel block?  Does that throw a error in the log after visiting the front page?

I did not try that, but I just did.

It does give me this error messages...

Quotehttps://test.fjr-club.nl/index.php?https://test.fjr-club.nl/
8: Array to string conversion
Bestand: /home/deb77453/domains/fjr-club.nl/public_html/test/Sources/TPortal.php
Regel: 1835
Title: Re: PHP 7 compatability for TP
Post by: lurkalot on June 27, 2017, 01:50:23 PM
Quote from: @rjen on June 27, 2017, 12:51:22 PM
Quote from: lurkalot on June 27, 2017, 08:23:05 AM
Did you try adding front panel block?  Does that throw a error in the log after visiting the front page?

I did not try that, but I just did.

It does give me this error messages...

Quotehttps://test.fjr-club.nl/index.php?https://test.fjr-club.nl/
8: Array to string conversion
Bestand: /home/deb77453/domains/fjr-club.nl/public_html/test/Sources/TPortal.php
Regel: 1835

The fix is here if you want to test it, http://www.tinyportal.net/index.php?topic=35895.0 It worked for me. Or wait for the next package,  ;)