TP-Docs
HTML5 Icon HTML5 Icon HTML5 Icon
TP on Social Media

Recent

Welcome to TinyPortal. Please login or sign up.

April 18, 2024, 02:32:09 AM

Login with username, password and session length
Members
  • Total Members: 3,885
  • Latest: Growner
Stats
  • Total Posts: 195,164
  • Total Topics: 21,219
  • Online today: 190
  • Online ever: 3,540 (September 03, 2022, 01:38:54 AM)
Users Online
  • Users: 0
  • Guests: 173
  • Total: 173

PHP 7 compatability for TP

Started by @rjen, May 23, 2017, 09:48:11 PM

Previous topic - Next topic

0 Members and 1 Guest are viewing this topic.

@rjen

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?
Running Latest TP on SMF2.1 at: www.fjr-club.nl

illori

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.

@rjen

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?
Running Latest TP on SMF2.1 at: www.fjr-club.nl

lurkalot

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()




@rjen

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>';
  }

Running Latest TP on SMF2.1 at: www.fjr-club.nl

lurkalot

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. 

@rjen

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..
Running Latest TP on SMF2.1 at: www.fjr-club.nl

lurkalot

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

@rjen

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...
Running Latest TP on SMF2.1 at: www.fjr-club.nl

lurkalot

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.