• Do not register here on develop.twiki.org, login with your twiki.org account.
• Use View topic Item7848 for generic doc work for TWiki-6.1.1. Use View topic Item7851 for doc work on extensions that are not part of a release. More... Close
• Anything you create or change in standard webs (Main, TWiki, Sandbox etc) will be automatically reverted on every SVN update.
Does this site look broken?. Use the LitterTray web for test cases.

Item5674: IF and Query have problems if some part of an evaluated statement is undef

Item Form Data

AppliesTo: Component: Priority: CurrentState: WaitingFor: TargetRelease ReleasedIn
Engine   Urgent Closed   patch 4.2.1, 5.0.0

Edit Form Data

Summary:
Reported By:
Codebase:
Applies To:
Component:
Priority:
Current State:
Waiting For:
Target Release:
Released In:
 

Detail

Sandbox.TestTopic0NotExist/info.rev should be undef - instead Sandbox.TestTopic0NotExist/info. evaluates to undef, and then rev is treated as a seperate literal string.

  • IF{"Sandbox.TestTopic0NotExist/info.rev = 'rev'" then="broken" else="ok"}
    • ok
  • IF{"Sandbox.TestTopic0NotExist/info.version = 'version'" then="broken" else="ok"}
    • ok

damn. it should be undef.

-- TWiki:Main.SvenDowideit - 27 May 2008

  • IF{"istopic fields[name='nonEdistantField']" then="broken" else="ok"}
    • ok

  • IF{"istopic fields[name='nonEdistantField'].value" then="broken" else="ok"}
    • ok

looks like undef eval is sodded

-- TWiki:Main.SvenDowideit - 30 May 2008

-- TWiki:Main/SvenDowideit - 01 Jun 2008

This is all a question of context. When a dot operator is evaluated, the name on the LHS is evaluated in the current context. This normally means in the context of the meta-data of the current topic, so that an expression like info.rev works relative to that meta-data. However this doesn't work when the LHS of the expression is a web name, because web names are not defined relative to the meta-data of a topic.

There are two possible solutions; first, to pass a "root context" down that can be used to evaluate web names. Second, to evaluate web names in the context of the meta-data of the current topic. Of the two, I think the second is probably best.

-- CrawfordCurrie - 28 Jul 2008

you are suggesting that without the web. the tests would succeed - and so... we test em.

  • IF{"TestTopic0NotExist/info.rev = 'rev'" then="broken" else="ok"}
    • ok
  • IF{"TestTopic0NotExist/info.version = 'version'" then="broken" else="ok"}
    • ok

-- SvenDowideit - 28 Jul 2008

The problem is that what you are trying to do is invalid syntax; perfectly understandable, but still invalid. The dot operator is defined as returning a field value. The term before a / is defined as being a string that is the name of a topic. X.Y will evaluate to the name of a topic, but only if X.Y is a field e.g. parent.name. If you want to use the web.topic name of a topic, you have to quote it:

  • IF{"'Sandbox.TestTopic0NotExist'/info.rev = 'rev'" then="broken" else="ok"}
  • IF{"'Sandbox.TestTopic0NotExist'/info.version = 'version'" then="broken" else="ok"}
  • IF{"'TestTopic0NotExist'/info.rev = 'rev'" then="broken" else="ok"}
  • IF{"'TestTopic0NotExist'/info.version = 'version'" then="broken" else="ok"}

(Note that the above tests may fail because of a second problem that I have since fixed)

I agree the doc is unclear on this point. It would be nice to be able to use web.topic syntax, but that would require excessive amounts of context information.

Upgraded to Urgent because you bugged me about it.

-- CrawfordCurrie - 28 Jul 2008

ah smile not the solution I wanted, but good enough :), mucho thanks.

BUT

what about

  • IF{"istopic fields[name='nonEdistantField']" then="broken" else="ok"}
    • ok

  • IF{"istopic fields[name='nonEdistantField'].value" then="broken" else="ok"}
    • ok

-- SvenDowideit - 30 Jul 2008

That is an unrelated problem in istopic. It is using normalizeWebTopicName which defaults the topic name to WebHome if it is not defined.

Added unit test and fixed.

-- CrawfordCurrie - 30 Jul 2008 small fix for unit tests

-- SvenDowideit - 30 Jul 2008

Cleaned "WaitingFor" field.

-- TWiki:Main.GilmarSantosJr - 10 Aug 2008

ItemTemplate
Summary IF and Query have problems if some part of an evaluated statement is undef
ReportedBy TWiki:Main.SvenDowideit
Codebase 4.2.0, 4.2.1, ~twiki4
SVN Range TWiki-5.0.0, Tue, 27 May 2008, build 16846
AppliesTo Engine
Component

Priority Urgent
CurrentState Closed
WaitingFor

Checkins TWikirev:17176 TWikirev:17177 TWikirev:17208 TWikirev:17209 TWikirev:17210 TWikirev:17211
TargetRelease patch
ReleasedIn 4.2.1, 5.0.0
Edit | Attach | Watch | Print version | History: r17 < r16 < r15 < r14 < r13 | Backlinks | Raw View | Raw edit | More topic actions
Topic revision: r17 - 2008-08-10 - GilmarSantosJr
 
This site is powered by the TWiki collaboration platform Powered by PerlCopyright © 2008-2019 by the contributing authors. All material on this collaboration platform is the property of the contributing authors.
Ideas, requests, problems regarding TWiki? Send feedback