Page 1 of 1

Some older templates problem with php 7.2.13

Posted: Tue Feb 12, 2019 6:36 pm
by Nicky
I'm looking at/testing some of OldNema's templates. Some of them I used for a few clients. Most templates work fine with php7.2.13 and the latest cmsimple version, however one of them 'ferrariclub' is completely blocked..

There are a significant number of php errors. It seems that something is wrong in the combination of the template and the "xtoc menu", more specifically the vertical one.

Now, unfortunately I don't understand much of php programming, but is is weird that the 'pizza' template, which also uses 'xtoc', but in the horizontal form, has no problems at all.

I'm worried because I used the "Ferrari template" for a client, so as soon as the hosting provider stops with older php version, website is 'gone'. And that's a website of significant size..

Is there an 'easy' solution within the community?

Take a look:
Working fine : https://walhalles.be/pizza/

Big trouble here : https://walhalles.be/ferrari

Thanks in advance for your time.

Grtz

Re: Some older templates problem with php 7.2.13

Posted: Tue Feb 12, 2019 8:08 pm
by cmb
Nicky wrote:
Tue Feb 12, 2019 6:36 pm
There are a significant number of php errors. It seems that something is wrong in the combination of the template and the "xtoc menu", more specifically the vertical one.
The fix should be as simple as replacing line 14 of xtoc.php with:

Code: Select all

function xtoc($start = null, $end = null) {global $c, $cl, $s, $l, $cf;$ta = array();if (isset($start)) {if (!isset($end))$end = $start;}else $start = 1;if (!isset($end))$end = $cf['menu']['levels'];$ta = array();if ($s > -1) {$tl = $l[$s];for($i = $s; $i > -1; $i--) {	if ($l[$i] <= $tl && $l[$i] >= $start && $l[$i] <= $end)if(!hide($i))$ta[] = $i;if ($l[$i] < $tl)$tl = $l[$i];}@sort($ta);$tl = $l[$s];}else $tl = 0;$tl += 1+$cf['menu']['levelcatch'];for($i = $s+1; $i < $cl; $i++) {if ($l[$i] <= $tl && $l[$i] >= $start && $l[$i] <= $end)if(!hide($i))$ta[] = $i;	if ($l[$i] < $tl)$tl = $l[$i];}return xli($ta, $start);}

Re: Some older templates problem with php 7.2.13

Posted: Tue Feb 12, 2019 9:42 pm
by Nicky
OMG, this works!
Chapeau pour les ingenieurs, grand respect.

Re: Some older templates problem with php 7.2.13

Posted: Tue Feb 12, 2019 10:46 pm
by cmb
Nicky wrote:
Tue Feb 12, 2019 9:42 pm
OMG, this works!
Fine. :)

Note that this problem exists as of PHP 7.1.0 (not only PHP 7.2.13), and all existing templates with this potential issue should be fixed, even if they're running on an older PHP version yet. The fix above is compatible with whatever PHP version xtoc is compatible (at least PHP 5.0.0).

Note to self: promote Toxic_XH to GA as soon as possible, since it could be used as replacement for xtoc, keeping such updates in a single place (instead of potentially having to fix all existing templates using xtoc).

Re: Some older templates problem with php 7.2.13

Posted: Fri Feb 15, 2019 5:27 pm
by Nicky
Still a small warning as follows:

XH-DEPRECATED: Function editmenu() is deprecated
/home/walhalles/domains/walhalles.be/public_html/ferrari/templates/ferrariclub/template.htm:45

However, everything works fine, so that should not be a problem?

Re: Some older templates problem with php 7.2.13

Posted: Fri Feb 15, 2019 5:39 pm
by cmb
Nicky wrote:
Fri Feb 15, 2019 5:27 pm
Still a small warning as follows:

XH-DEPRECATED: Function editmenu() is deprecated
/home/walhalles/domains/walhalles.be/public_html/ferrari/templates/ferrariclub/template.htm:45

However, everything works fine, so that should not be a problem?
No, that's not an immediate problem, but since editmenu() does nothing as of CMSimple_XH 1.5, I suggest that you simply delete line 45 of template.htm.