Item10691: IF statement causes error on some systems
Priority: Normal
Current State: No Action Required
Released In: n/a
Target Release: n/a
See also
Support.Question848. Apparently BlogAddOn fails on some systems with:
Excess operators (and) in 'BlogPostForm AND fields[name='Tags'].value=~'\btest\b' ' at ' '
It also fails on foswiki.org, see for instance:
http://foswiki.org/Blog.BlogPost?tag=test
But it works fine on my machine. What is wrong with the syntax?
The full
SEARCH statement is:
%SEARCH{
type="query"
"BlogPostForm%IF{"defined pcategory and $pcategory!=''" then=" AND fields[name='Category'].value='%pcategory%'"}%%IF{"defined ptag and $ptag!=''" then="%FORMAT{
type="string"
"%ptag%"
format=" AND fields[name='Tags'].value=~'\b$item\b' "
}%"}%%IF{"defined pauthor and $pauthor!=''" then=" AND fields[name='Author'].value=~'\b%pauthor%\b'"}%"
web="%WEB%"
zeroresults="<div class='blogPostAddOnItem'>%MAKETEXT{"No posts found"}%</div>"
nosummary="on"
nosearch="on"
nototal="on"
excludetopic="*Template"
casesensitive="on"
format="%INCLUDE{
"%TOPIC%"
section="blogPostAddOnItem"
}%"
header="<div class='blogAddOnList'>"
footer="</div>"
order="%psort%"
reverse="%IF{"$psortdirection='descending'" then="on" else="off"}%"
pagesize="%ppagesize%"
pager="on"
}%
--
ArthurClemens - 29 Apr 2011
We were using
fields[name='Blah'] =~ '\bsomething\b'
as a long-form of
Blah =~ '\bsomething\b'
temporarily because of a bug in Foswiki 1.1.2 that was fixed in 1.1.3.
Does the expression work if you use the shortcut?
There's something strange going on with OP_match and
VarIF, but I guess you already knew that, hence filing the bug...
--
PaulHarvey - 29 Apr 2011
No luck. I have changed the line to
AND (Tags =~ '\b$item\b')
but that results in
Error was: Excess operators (=) in '(BlogPostForm) AND (Tags =~ '\btest\b') ' at ' '
Just
~
does work, but I need the regex expression.
--
ArthurClemens - 29 Apr 2011
I think this is due to the
OP_match
not set in
$Foswiki::cfg{Operators}{Query}
. If a system is migrated, the setting is missed. This was addressed by a checker. This can probably be closed.
--
GeorgeClark - 29 Jul 2012