[pmwiki-devel] strange FmtPV behavior...

The Editor editor at fast.st
Thu Apr 5 09:43:03 CDT 2007


On 4/5/07, Patrick R. Michaud <pmichaud at pobox.com> wrote:
> On Thu, Apr 05, 2007 at 09:54:41AM -0400, The Editor wrote:
> > Any explanation why the following give different results?
> >
> > #1)
> > $FmtPV['$orderpage'] = 'ZAPorderpage()';
> > function ZAPorderpage() {
> >       $OrderGroup = ZAPconfig('Order', 'Order');
> >       $OrderName = strftime("%Y%j", time()) . "-" .
> > strtoupper(substr(session_id(), 0, 16));
> >       return $OrderGroup . "." . $OrderName;
> >       }
> >
> > #2)
> > $FmtPV['$orderpage'] = "'" . ZAPconfig('Order', 'Order') . "." .
> > strftime("%Y%j", time()) . "-" . strtoupper(substr(session_id(), 0,
> > 16)) . "'";
>
> The first one computes the value when the $orderpage page variable
> is being evaluated -- ZAPConfig() isn't called until someone requests
> the value of {$orderpage} .
>
> The second one computes the value at the time the $FmtPV['$orderpage']
> is being set.  In other words, it immediately calls ZAPConfig()
> and uses the results as the constant output value.
>
> So, the reason why they are different is that ZAPConfig() returns
> different values depending on if it's being called immediately
> or later in the program.

Ok, I understand this.  But it still doesn't really explain to me why
ZAPConfig should return different values.  I've looked at the
ZAPConfig code and it doesn't use any global variables that could
change as far as I can tell.  Looking at the code, the line that fails
calls PageTextVar(). The results I'm getting are as if that function
fails even though the parameters are all there properly.

> Note that session_id() may return different values as well, depending
> on whether the session is being opened before or after setting
> $FmtPV['$orderpage'].

This is a bigger concern for me, as I'm using this to track items put
into a shopping cart.  Is there some way to get the same value at all
times?  I originally was going to use AuthId but don't want to require
individuals to login.  Someone suggested this, and it looks great--but
if it's unreliable I need another solution.  Do I need to set up a
special session variable, for id store or something that won't be
changing at all?  Help?

Cheers,
Dan



More information about the pmwiki-devel mailing list