2023-02-03, 08:33 AM
(2023-02-02, 01:14 PM)HLFadmin Wrote: Has anyone found the fix for using this plugin with PHP 8? Getting this error.
Warning [2] Undefined array key 2 - Line: 92 - File: inc/plugins/phptpl.php PHP 8.0.27 (Linux)
[...]
using a simple conditional in forumdisplay_threadlist template
<if $foruminfo["fid"] == "115" then>  <a href="https://www.worldcommunitygrid.org/team/viewTeamMemberDetail.do?sort=name&teamId=xxxxxxxxxx" target="_blank">click for Team stats.</a> </if>
It looks to me that the problem is that the regular expression on line 91 can match only "</if>", in which case the matches array
$m
will include entries only at index zero (</if>
) and one (/if
), and no entry will be set for index two. Without testing, it looks as though the fix, then, is to change line 192 from: return phptpl_if($m[1], phptpl_unescape_string($m[2]));
to: return phptpl_if($m[1], phptpl_unescape_string(isset($m[2]) ? $m[2] : ''));
An empty second parameter to
phptpl__if()
is fine in this scenario because it only uses the first for /if
s.