TinyPortal

Development => Support => Topic started by: Arantor on June 27, 2017, 08:35:16 AM

Title: PHP 5.x/7/7.1 compat fixes
Post by: Arantor on June 27, 2017, 08:35:16 AM
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 :)
Title: Re: PHP 5.x/7/7.1 compat fixes
Post by: lurkalot on June 27, 2017, 08:53:02 AM
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)