00620: lines= option of include statement is broken with php 5.1.1

Summary: lines= option of include statement is broken with php 5.1.1
Created: 2005-12-15 13:24
Status: Closed - fixed in 2.1.beta36
Category: PHP Compatibility
From: jue?
Assigned:
Priority: 5
Version: 2.0.13
OS: Linux, php 5.1.1

Description: With php 5.1.1 (cgi-fcgi) the lines option of the include statement doesn't work. The page is still included but every variant of lines= has no effect, the whole page is included instead.

I've cross-tested this with php 5.0.5 and 4.4.1, both work as expected.


I've done some looking into this on my own and found that the following patch seems to fix the problem for me.

--- pmwiki.php  2006-03-05 19:49:49.000000000 -0700
+++ pmwiki-2.0.13/pmwiki.php    2005-10-20 06:27:46.000000000 -0600
@@ -796,8 +796,8 @@
       $upat = ($k{0} == 'p') ? ".*?(\n\\s*\n|$)" : "[^\n]*\n";
       if (!$dots) { $b=$a; $a=0; }
       if ($a>0) $a--;
-      $itext=preg_replace("/^(($upat){0,$b}).*$/s",'$1',$itext,1);
-      $itext=preg_replace("/^($upat){0,$a}/s",'',$itext,1);
+      $itext=preg_replace("/^(($upat)\{0,$b}).*$/s",'$1',$itext,1);
+      $itext=preg_replace("/^($upat)\{0,$a}/s",'',$itext,1);
       continue;
     }
   }

I'm using php 5.1.2-1ubuntu1 with pmwiki-2.0.13

--Eric Wollesen <ericw at xmtp dot net>


Tested today with 2.1.0, still the same. Seems you've forgotten to apply the patch above, which solves the Problem for me.


Here are lines 950-957 of version 2.1.0 of pmwiki.php:

      $upat = ($k{0} == 'p') ? ".*?(\n\\s*\n|$)" : "[^\n]*(?:\n|$)";
      if (!$dots) { $b=$a; $a=0; }
      if ($a>0) $a--;
      $itext=preg_replace("/^(($upat)\{0,$b}).*$/s",'$1',$itext,1);
      $itext=preg_replace("/^($upat)\{0,$a}/s",'',$itext,1);
      continue;
    }
  }

AFAICT, it's exactly the same as your patch. Are you sure you installed the latest copy of the pmwiki.php file from 2.1.0?

--Pm


Yes, I have pmwiki.php from 2.1.0. Eric's patch is created the wrong way, seems that he does a

 diff -u <new_file> <orig_file> 

instead of

 diff -u <orig_file> <new_file> 

Here a correct version of the patch against 2.1.0:

--- pmwiki.php.org      2006-03-13 16:38:57.000000000 +0100
+++ pmwiki.php  2006-03-13 16:39:27.000000000 +0100
@@ -950,8 +950,8 @@
       $upat = ($k{0} == 'p') ? ".*?(\n\\s*\n|$)" : "[^\n]*(?:\n|$)";
       if (!$dots) { $b=$a; $a=0; }
       if ($a>0) $a--;
-      $itext=preg_replace("/^(($upat)\{0,$b}).*$/s",'$1',$itext,1);
-      $itext=preg_replace("/^($upat)\{0,$a}/s",'',$itext,1);
+      $itext=preg_replace("/^(($upat){0,$b}).*$/s",'$1',$itext,1);
+      $itext=preg_replace("/^($upat){0,$a}/s",'',$itext,1);
       continue;
     }
   }

--Juergen