[pmwiki-users] PHP 5.3 woes.

rogutes at googlemail.com rogutes at googlemail.com
Sat Oct 24 12:04:30 CDT 2009


Vince Administration (2009-10-24 10:42):
> 
> On Oct 24, 2009, at 5:34 AM, rogutes at googlemail.com wrote:
> 
> >Vince Admin Account (2009-10-23 16:01):
> >>
> >>On Oct 19, 2009, at 5:13 PM, rogutes at googlemail.com wrote:
> >>
> >>>
> >>>The problem with pagelists lies in GlobToPCRE() function in
> >>>pmwiki.php
> >>>and is tracked at http://pmwiki.org/wiki/PITS/01149 . It concerns
> >>>exclusion patterns (name=-Page) only.
> >>>
> >>
> >
> >(:pagelist group=-PmWiki*,-Site*:) works fine here. Doesn't it
> >work for
> >you? Are you sure you've made the right changes to GlobToPCRE()? The
> >line with str_replace call looks like this after changing:
> >
> >$pat = str_replace(array('\\*', '\\?', '\\[', '\\]', '\\^', '\\-'),
> >                  array('.*',  '.',   '[',   ']',   '^', '-'), $pat);
> >
> Well, I think I am sure. I can cut and paste, in case my eyes are
> too tired. Here is the entire function.
> function GlobToPCRE($pat) {
>   $pat = preg_quote($pat, '/');
>   $pat = str_replace(array('\\*', '\\?', '\\[', '\\]', '\\^', '\\-'),
>                      array('.*',  '.',   '[',   ']',   '^', '-'),
> $pat);
>   $excl = array(); $incl = array();
>   foreach(preg_split('/,+\s?/', $pat, -1, PREG_SPLIT_NO_EMPTY) as $p) {
>     if ($p{0} == '-'  ) $excl[] = '^'.substr($p, 0).'$';
>     else $incl[] = "^$p$";
>   }
>   return array(implode('|', $incl), implode('|', $excl));
> }

You didn't answer my first question. Does the following work for you?
(:pagelist group=-PmWiki*,-Site*:)

There's no point pasting the entire function, because you should've
changed only the two lines beginning with $pat = str_replace (which look
good above)... If you did more, I you've changed more than those, I'd
suggest starting with a new pmwiki.php.

> Some other interesting things I found here.  We are running Apple
> Snow Leopard, PHP 5.3.0 and Apache 2.2.11.
> When I tried to test pieces of this code on my web page,  the line
> $pat = preg_quote($pat,'\');
> gave a syntax error.  It worked as in the manual with a few other
> characters instead of \. I did get it to work as advertised with
> $pat = preg_quote($pat,'\\');
> I tried that in GlobToPCRE, but it didn't help.     So I am
> confused.  But at least I do have the workaround.
>              Vince

Compare
    $pat = preg_quote($pat, '/');
to
    $pat = preg_quote($pat, '\');

-- 
--  Rogutės Sparnuotos



More information about the pmwiki-users mailing list