[pmwiki-users] Pagelist definition problem (fixed?)

Crisses crisses at kinhost.org
Fri Oct 6 22:33:42 CDT 2006


On Oct 6, 2006, at 8:25 PM, Patrick R. Michaud wrote:

> On Fri, Oct 06, 2006 at 04:10:56PM -0400, Crisses wrote:
>>> A short-term workaround might be to eliminate and/or/xor from
>>> complex conditional expressions.  Try the following in local/
>>> config.php:
>>>
>>>    $CondExprOps = '&&|\\|\\||[!()]';
>>>
>>> Then (:if expr ... :) will separate things only on
>>> &&, ||, !, and parens.
>>
>> WOW -- that broke things real nice ;)
>
> I'm surprised -- it shouldn't have broken anything.  The normal
> setting for $CondExprOps is
>
>     SDV($CondExprOps, 'and|x?or|&&|\\|\\||[!()]');
>
> so all the above should've done is remove the words and, xor, or
> from the set of matching conditions.

I think that FASTData is what broke.  And I'm wondering if this is  
going to have a bugfix or if I have to check everything -- the skin,  
the recipies I'm using, etc. to see if they're breaking because of that.

But FASTData definitely broke when I changed it.  So it's not that  
PmWiki did, it's that my application of PmWiki & add-ons & custom  
code had.

>> I'd have to scrub through FASTData etc. and
>> see what's wrong, or maybe it's my custom code somewhere... -- but
>> the problem isn't that it's parsing "and" -- it's that it's
>> evaluating the variables BEFORE changing "and" to && in the code.
>> Why not take if statements and search/replace the shorthand with &&
>> before parsing the page variables?
>
> PmWiki doesn't "change 'and' to &&" anywhere -- PHP understands
> the 'and' operator natively.  So, if you have:
>
>     (:if expr equal 1 2 and equal 3 3 :)
>
> then the statement that gets evaluated by PHP is *literally*
> '0 and 1', not '0 && 1'.

I understand that.

But PmWiki is having a problem with parsing conditionals containing  
variable values that contain "and" -- which means you may ALSO have  
problems with "or".  That's a pretty bad bug if you ask me -- since I  
would be quite likely to evaluate sentences -- other people might  
also.  Think of a page named "Ebony and Ivory" (EbonyAndIvory) -- is  
that a problem?  etc.

So, I was thinking if you change the "and" to && and "or" to || just  
before parsing the variables in the statement.  When evaluating the  
statement itself, you can remove parse the statement knowing that and  
or or are not going to be there, so that the statement is evaluated  
correctly.

So -- if anything sends:
     (:if expr equal "Ebony and Ivory" "Ebony and Ivory" and equal 3  
3 :)
it becomes
     (:if expr equal "Ebony and Ivory" "Ebony and Ivory" && equal 3 3 :)
before the variable values are even an issue...later when you make  
sure your quotes are in the right places, there should be no problems  
from "ands" or "ors", because you can change how you quote the  
statement with confidence, knowing any occurrences of "and" and "or"  
are string not directives.


Hopefully that made sense -- I've almost lost my thinking card for  
the night.

Crisses






More information about the pmwiki-users mailing list