[pmwiki-users] processing order

Peter & Melodye Bowers pbowers at pobox.com
Sun Feb 17 15:49:46 CST 2008


I have a MarkupExpression I am putting together which reads a given page,
checks for a certain value, and if it doesn't find it then it writes the
value to the end of the page.

 

I am finding inconsistent results with it where often it somehow writes the
value *before* the read, even though there's no possibility that I can see
that that could happen based on my code.  And the strangest thing is that I
have all this code heavily debugged both with MessageFmt[]/(:messages:) as
well as using straight echo statements.  The WikiShEcho() function clearly
is *NOT* processing according to both types of debugging statements and yet
the value is getting written to the page before the WikiShGrep tries to read
it?!?!?  

 

Is there any kind of situation in which directives (like markup expressions)
get processed twice in a single browse of a page?  Or (more surprising) that
echo statements could somehow be suppressed during an earlier invocation of
the MX?

 

I'm completely befuzzled by this - any hints anybody could give would be
greatly appreciated.

 

-Peter

 

PS Below is the relevant section of code - if you want to see more context
the whole recipe is at pmwiki/cookbook/wikish - the function is
WikiShOnce().  Again, I clearly see in my debug statements the fact that
WikiShGrep is being invoked and finding the value that shouldn't get written
until 9 lines later in the WikiShEcho() call.  I'm making up random strings
to write to the file, so it's not like some other part of the page would be
writing the same values.  (There are no loops in this function, neither
before nor after this section of code, and this function is called directly
by $MarkupExpr[] stuff.  If the MX were being called in some kind of
"preview mode" that would explain the whole thing, but I've never heard of
such a thing and I don't know how the echo statements would be being
suppressed.

 

    WikiShGrep($pagename, array('q'=>true), array("^$pat$", $ControlPage));
<-- here I read the page and search for the value

    if ($WikiShVars['STATUS'] == 0) {

        # If found then we shouldn't run again - return false

        $WikiShVars['STATUS'] = 1;

        wdbg(4,"$func: Returning (a) with STATUS=" . $WikiShVars['STATUS']);

        return($opt['r'] ? '0' : '');

    } else {

        # not found - WRITE the pattern to $WikiShControlPage

        # if successful write to $WikiShControlPage then return true

        WikiShEcho($pagename, array('stdout'=>$ControlPage,
'stdout_append'=>true), array("$pat")); <-- here I write the value to the
page

        # $WikiShVars['STATUS'] was set by echo - if it succeeded then we

        # succeed.  If it didn't succeed then we don't succeed.  Thus no

        # need to check it or set it.

        wdbg(4,"$func: Returning (b) with STATUS=" . $WikiShVars['STATUS']);

        return($opt['r'] ? '1' : '');

    }

-------------- next part --------------
An HTML attachment was scrubbed...
URL: /pipermail/pmwiki-users/attachments/20080217/29c78d3a/attachment.html 


More information about the pmwiki-users mailing list