[pmwiki-users] Templates and PHP 7.x

Petko Yotov 5ko at 5ko.fr
Wed Nov 6 22:09:23 PST 2019


I've updated the script, you can get it from:

   https://www.pmwiki.org/wiki/Cookbook/Templates

To reply to your question, to return true, is_callable() expects exactly 
a function name without the "('$1')" parts.

So the 4th argument of Markup() should now be "ParametersParse" rather 
than "ParametersParse('\$1')".

Because of this, the functions ParametersParse() and Template() need to 
be updated because now they receive the full match array instead of its 
1st element. So I rewrote from:

   function ParametersParse($text) {...}

into:

   function ParametersParse($m) {$text = $m[1]; ...}

Similarly for Template().

Lastly, at the end of the 3rd argument to both Markup() calls, the "e" 
letter needs to be removed, previously:

   "/\(:template(.*?):\)/e",

now: "/\(:template(.*?):\)/",


Petko

-- 
If you upgrade :  http://www.pmwiki.org/Upgrades


On 07/11/2019 03:39, Michael Eager wrote:
> I'm trying to use the PmForm and Captcha Cookbook addons, which use
> the Template addon.  This fails because the Template code uses the
> deprecated /e extension to preg_replace:
> 
> templates.php:45
> Markup(
> 	'parameters',
> 	'>include',	## or where?
> 	"/($Parameters_mg|$Parameters_ms|$Parameters_mu)/e",    <====
> 	"ParametersParse('\$1')"
> );
> 
> Markup(
> 	'template',
> 	'<include',
> 	"/\(:template(.*?):\)/e",   <====
> 	"Template('\$1')"
> );
> 
> which eventually calls preg_replace(), not preg_replace_callback()
> pmwiki.php:1845
>         if (is_callable($r)) $x = preg_replace_callback($p,$r,$x);
>         else $x=preg_replace($p,$r,$x);   <====
> 
> I'm a bit confused by the code, but it looks to me that $r should be
> callable (which I suppose is the the callback function passed to
> Markup()), but preg_replace_callback() is not being called.
> 
> Is there a fix for this?



More information about the pmwiki-users mailing list