[pmwiki-users] Problem with PHP 5.1

Patrick R. Michaud pmichaud at pobox.com
Sun Dec 4 19:37:48 CST 2005


On Sat, Dec 03, 2005 at 03:18:15PM +0000, J. Meijer wrote:
> It seems pmwiki is broken when using PHP 5.1. At least I can't get this to 
> work:
> 
> (:include PmWiki.PmWiki lines=2:)
> 
> It includes all of the text. Possibly ParseArgs functionality.
> 
> When reverting to an (unknown) earlier 5.0.x version all is well.

Interesting.  Apparently the implementation of backslash-escapes
changed slightly(?) between PHP 5.0 and 5.1.  In 5.0 this results in 
"{0,2}", while in 5.1 it becomes "\{0,2}".  This is affecting the 
preg_replace code in IncludeText that handles the lines= parameter.
So, the lines that read (approx line 819):

      $itext=preg_replace("/^(($upat)\{0,$b}).*$/s",'$1',$itext,1);
      $itext=preg_replace("/^($upat)\{0,$a}/s",'',$itext,1);

have to be changed to:

      $itext=preg_replace("/^(($upat){0,$b}).*$/s",'$1',$itext,1);
      $itext=preg_replace("/^($upat){0,$a}/s",'',$itext,1);

For 2.1.beta10 I'm going ahead and removing the backslash, but I don't
know if that will cause problems for older versions of PHP.  I do know 
it's okay for PHP 4.3.11.  I've also checked through the rest of the
distribution code for similar backslash problems and didn't find any.

Many thanks for finding and reporting this so quickly.

Pm




More information about the pmwiki-users mailing list