01158: complex, nested conditional markup broken

Summary: complex, nested conditional markup broken
Created: 2009-12-22 12:47
Status: Closed
Category: Documentation
From: bang
Priority: 3
Version: 2.2.8
OS: all; PHP 5.3, 5.2.10 & pmwiki.org

Description: complex, nested conditions seem to be broken. for instance, this fails:

(:if expr false && (true || false):)
expr false && (true || false) succeeds

expr false && (true || false) succeeds

in more realistic expressions though, that general form can succeed. for instance in a page list this works:

if="expr date {(ftime %Y%m%d)}.. {=$:eventtime} && (!equal {=$:nsasevent} no || equal {=$:bigevent} yes)"

but this doesn't:

if="expr (!equal {=$:nsasevent} no || equal {=$:bigevent} yes) && date {(ftime %Y%m%d)}.. {=$:eventtime}"

addenda: actually, that second real example will fail too if the condtions are "(false || false) && true".

(:if expr (false || false) && true:)
expr (false || false) && true succeeds

expr (false || false) && true succeeds

The bug essentially comes from the way you're writing the conditional expression: all logical expression token must be white space separated to be taken in account. See below:

(:if expr false && ( true || false ):)
expr false && ( true || false ) succeeds
(:if expr ( false || false ) && true:)
expr ( false || false ) && true succeeds

Your realistic expressions should be written like below:

if="expr date {(ftime %Y%m%d)}.. {=$:eventtime} && ( ! equal {=$:nsasevent} no || equal {=$:bigevent} yes )"

but this doesn't:

if="expr ( ! equal {=$:nsasevent} no || equal {=$:bigevent} yes ) && date {(ftime %Y%m%d)}.. {=$:eventtime}"

--Dfaure December 22, 2009, at 02:11 PM

thanks very much for the clarification. i had missed the note saying: "Spaces around operators and brackets are required." would it be a good idea to highlight that somehow in the documentation?

sorry for the false alarm.

/dan - bang December 22, 2009, at 02:40 PM