01092: Markup expressions not properly parsed inside of if statements within searches

Summary: Markup expressions not properly parsed inside of if statements within searches
Created: 2009-04-26 02:11
Status: Open
Category: Bug
From: ZakGreant
Priority: 544
Version: 2.2.1
OS: n/a

Description: Markup expressions inside of if statements within searches are not processed.

e.g. A search string such as:

   if="equal {(ftime %Y-%m {$:date})} 2009-04" 

will generate intermediate code within pagelist.php/PageListIf() like:

   equal {(ftime %Y-%m 2009-04-23)} 2009-04 

instead of code like:

  equal 2009-04 2009-04  

Adding the following snippet after line 315 fixes the problem (but I'm not sure if it fixes the problem in the right way. :-) )

    $condspec = preg_replace('/\\{(\\(\\w+\\b.*?\\))\\}/e', "MarkupExpression(\$pn, PSS('$1'))", $condspec); 

Hello. Pm will soon review this entry. The discussion at PITS:00986 is somewhat related, and so is PITS:01091. --Petko May 08, 2009, at 12:08 AM

In PmWiki the expected behaviour for variables appears to be that they are expanded as late as possible in the parsing when generating a page. Some markup that specified that variables and expressions are to be expanded when first encountered in the parsing would be a good way to explicitly handle this. simon March 16, 2010, at 07:22 PM

I am having a problem with parsing {$Name} or variables in markup expressions. Seems related.

For example I'm using an events calendar where the pagename is the date of the event. I want to be able to find dates relative to the date of the event. I can't seem to process any page variables or nest markup expressions to get to the output I'm looking for. It seems the markup expression wants to end when it encounters } rather than waiting for ")}" thus the page variables get lost in the scope of the markup expression. I think there were alternative ways to call page variables, but wouldn't this be both counter-intuitive and a bug if the markup expression ends at } rather than )}?

I'll have to create custom functions in PHP to render the dates I'm looking for in the meantime. :/ XES

(:month:{(ftime fmt="%Y-%m" when="last month")}:)

{(ftime fmt="%A, %B %d, %Y" when="first day {$:month}")}

{(ftime fmt="%A, %B %d, %Y" when="first day 2010-04")}


Thursday, January 01, 1970")}

Thursday, April 01, 2010

The markup expression doesn't end at the first "}", it ends at the first ")}". The {$:month} variable contains what you entered inside (:month::) and it is not evaluated (converted by MX) until MX are processed: but at that point, it is already placed literally in your second markup expression and contains the ")}" thing. --Petko October 09, 2011, at 06:58 AM