Tags:
create new tag
, view all tags

Bug: Variables Can't be set to 0

It seems that one can't set a WebPreferences variable to zero ('0'). It always evaluates to the empty string "". There's a fix in the Answer section, below.

Test case

Fix record

TWiki::Prefs::getPrefsFromTopic uses this Perl idiom when it's evaluating preference variable values:

   $value = $2 || "";

The problem is that the assignment will fall through to the empty string ("") whenever $2 is false, which, by Perl's definition of "false", means whenever $2 is undefined, the empty string, or zero (0).

The fix is to check whether or not $2 is defined, since that's the only case for which we really want to force the empty string:

   $value = defined $2 ? $2 : "";

-- TrippLilley - 15 Nov 2001

Fixed, in TWikiAlphaRelease.

Applied same fix for %VARIABLE{name="0"}% in TWiki::extractNameValuePair

-- PeterThoeny - 16 Nov 2001

Environment

TWiki version: 01 Sep 2001 release
TWiki plugins:  
Server OS: Linux 2.2.14
Web server: Apache 1.3.x
Perl version:  
Client OS: Linux 2.2.14
Web Browser: Opera, Netscape, Mozilla, Lynx (all Linux)

-- TrippLilley - 15 Nov 2001

Topic revision: r2 - 2001-11-16 - PeterThoeny
 
Twitter Delicious Facebook Digg Google Bookmarks E-mail LinkedIn Reddit StumbleUpon    
  • Download TWiki
TWiki logo Powered by Perl Hosted by OICcam.com Ideas, requests, problems regarding TWiki? Send feedback. Ask community in the support forum.
Copyright © 1999-2012 by the contributing authors. All material on this collaboration platform is the property of the contributing authors.