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

Recent

Welcome to TinyPortal. Please login or sign up.

March 29, 2024, 05:43:51 AM

Login with username, password and session length
Members
Stats
  • Total Posts: 195,105
  • Total Topics: 21,213
  • Online today: 358
  • Online ever: 3,540 (September 03, 2022, 01:38:54 AM)
Users Online
  • Users: 1
  • Guests: 334
  • Total: 335
  • @rjen

PHP 5.x/7/7.1 compat fixes

Started by Arantor, June 27, 2017, 08:35:16 AM

Previous topic - Next topic

0 Members and 1 Guest are viewing this topic.

Arantor

So I grabbed TP 1.3 from the mod site this morning, tried it on PHP 7.1 to see about fixing the issues I knew about.

So the 'non well formed numeric value' in Subs.php around line 756 is annoying but easy enough to fix.

TPSubs.template.php:

Code (find) Select

foreach($whos['users_online'] as $w => $wh)
{
$ids[] = $wh['id'];
$names[$wh['id']] = $wh['name'];
$times[$wh['id']] = timeformat($w);
}


Code (replace) Select

foreach($whos['users_online'] as $w => $wh)
{
// For reasons historical, SMF produces the timestamp as
// the timestamp followed by the user's name, so let's fix it.
$timestamp = (int) strtr($w, array($wh['username'] => ''));
$ids[] = $wh['id'];
$names[$wh['id']] = $wh['name'];
$times[$wh['id']] = timeformat($timestamp);
}


There's also a 5.4 compat issue with a previous suggested fix to TPortal.php around line 2447.

I don't have an environment I can easily test this in right now but this should fix what it's complaining about:

Code (find) Select

foreach ((array) $context['TPortal'][$panelside][$side] as $i => &$block)


Code (replace) Select

$context['TPortal'][$panelside][$side] = (array) $context['TPortal'][$panelside][$side];
foreach ($context['TPortal'][$panelside][$side] as $i => &$block)



There is one last error I know about but can't reproduce myself:


8: Array to string conversion
File: /user/whatever/public_html/smf/Sources/TPortal.php
Line: 1820


This corresponds to a complex array transformation but I can't see what might be an issue on that one because I can't reproduce it. However, as a speculation, maybe this:

Code (find) Select

// collect up frontblocks
$blocks = array('front' => '');


Code (replace) Select

// collect up frontblocks
$blocks = array('front' => array());


since it only occurs on the front page, I wonder if that's it. (It's further up TPortal.php around line 1760)

Lemme know how these work out :)

lurkalot

OK, had just about enough time to try the front panel block fix, and that works nicely now.  Brilliant.  Thanks Arantor.

Will add and test the other fixes after work.. 8)