You are here: Foswiki>Tasks Web>Item10691 (29 Jul 2012, GeorgeClark)Edit Attach

Item10691: IF statement causes error on some systems

pencil
Priority: Normal
Current State: No Action Required
Released In: n/a
Target Release: n/a
Applies To: Engine
Component: IfStatement
Branches:
Reported By: ArthurClemens
Waiting For:
Last Change By: GeorgeClark
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
 

ItemTemplate edit

Summary IF statement causes error on some systems
ReportedBy ArthurClemens
Codebase 1.1.3
SVN Range
AppliesTo Engine
Component IfStatement
Priority Normal
CurrentState No Action Required
WaitingFor
Checkins
TargetRelease n/a
ReleasedIn n/a
CheckinsOnBranches
trunkCheckins
Release01x01Checkins
Topic revision: r5 - 29 Jul 2012, GeorgeClark
The copyright of the content on this website is held by the contributing authors, except where stated elsewhere. See Copyright Statement. Creative Commons License    Legal Imprint    Privacy Policy