[pmwiki-devel] bug(?) report: preg_replace() problem

Peter Bowers pbowers at pobox.com
Fri Mar 27 09:17:52 CDT 2009


On Fri, Mar 27, 2009 at 1:32 PM, Petko Yotov <5ko at 5ko.fr> wrote:

> On Thursday 26 March 2009 17:31:02 Peter Bowers wrote:
> >    preg_replace('/(a)/e', 'strtoupper($1)', 'asdfasdfasdfasdf');
> >
> > I'm running into a situation where it is returning AsdfAsdfasdfasdf
> > (without replacing all occurrences).
>
> I have experienced this when some other pattern has already processed and
> modified (or skipped) some of the occurrences. In PmWiki it might happen if
> the "when" parameter for Markup() is not correctly/optimally set.
>
>
> > (As you can see I left a non-ptv pagelist at the top just for
> demonstration
> > purposes.)  The end result is that any (:markup:) blocks after the FIRST
> > pagelist which contains a PTV reference remain un-processed.
> >
> > It's easier to see than to describe:
>
> > http://pmwiki.org/wiki/Test/PageListA
>
> Right, there is a problem with more than two (:markup:)[=code=] although it
> doesn't seem to happen on other places like BasicEditing where it appears
> more than twice. We'll have to investigate further to find out why and how
> to
> fix it, but I suspect something messes with the $KPV array.
>
> Otherwise, using (:markup:)...(:markupend:) seems to work fine with more
> than
> two pagelists.
>

Interesting that (:markup:)...(:markupend:) works fine.

If it helps at all I narrowed it down to needing about 3900 lines (each with
a PTV def) in ThrottlePage before the problem disappeared. (Note that I
still had 8-10 "(:markup:) [=...=]" markups and it worked without difficulty
once the data on that page was more limited.)  Around the 3900 mark the
behavior started getting non-repeatable -- reloading the page 3-4 times
would result in different results.  To me this sounds like a memory problem
and bumping into some limit in PHP (particularly since I have verified that
the preg_replace() in MarkupToHTML() does *not* call the MarkupMarkup()
function past the problem-markup -- in other words preg_replace() is not
replacing all occurrences of the given pattern - something that to my
knowledge should *never* happen.)

In any event, if anybody else is going to play with this please make a copy
of the ThrottlePage -- I'm going to delete it since it will cause an
unnecessary load on the server whenever it is accessed in a PTV context
(i.e., a pagelist specifying any PTV condition which runs over the Test
group)...

-Peter
-------------- next part --------------
An HTML attachment was scrubbed...
URL: http://www.pmichaud.com/pipermail/pmwiki-devel/attachments/20090327/e68e2cf3/attachment.html 


More information about the pmwiki-devel mailing list