Tags:
create new tag
view all tags

Bug: Setting option to off means on

Many TWikiVariables have Boolean flag settings which are explained in the documentation with on, e.g., $SEARCH supports casesensitive and the documentation explains what happens when the option is casesensitive="on".

While the documentation is silent as to what would happen when these options are set to off, most readers probably will infer that off is the opposite from on and, therefore, this option will be set to off. The opposite is true. on and off and any other selection have the same meaning: invoke this option. Leaving the option out of the list turns it off.

I believe this is highly misleading and leads to many user errors that take a long time to debug.

In the DakarRelease, for preference settings we have gone away from this convention that off means on; the function Prefs::_flag is used to map on, true, and yes to a Boolean 1, and off, false, and no to Boolean 0 (case-insensitive). We should apply the same conventions to TWikiVariables settings.

Test case

Environment

TWiki version: TWikiRelease02Sep2004
TWiki plugins: DefaultPlugin, EmptyPlugin, InterwikiPlugin
Server OS:  
Web server:  
Perl version:  
Client OS:  
Web Browser:  

-- ThomasWeigert - 01 Jun 2005

Impact and Available Solutions

Follow up

Not sure what you mean, here; Preference settings are TWikiVariables. or did you perhaps mean attribute values e.g. %CONFUSED{on="off" off="on"}% ?

-- CrawfordCurrie - 02 Jun 2005

I meant the things that are documented on the TWikiVariables page, such as !%SEARCH{"...." casesensitive="off"}% actually meaning that the search should be casesensitive...

-- ThomasWeigert - 02 Jun 2005

Actually, the convention you describe for preferences flags never existed. Preferences have always mapped "no" and "off" to false. I added "false" to that list, but that's the only change from Cairo.

However I agree that we should aim to be consistent, so I propose the following:


StaticMethod isTrue( $value, $default ) -> $boolean

Returns 1 if $value is true, and 0 otherwise. "true" means set to something with a Perl true value, with the special cases that "off", "false" and "no" (case insensitive) are forced to false. Leading and trailing spaces in $value are ignored.

If the value is undef, then $default is returned. If $default is not specified it is taken as 0.


The rather vile spec is needed to maintain compatibility. There are a number of cases of booleans being abused for other purposes (e.g. multiple="on" and multiple="[[$item]]"). frown

While I was there, I also documented the nozeroresults and noempty options to search, which had slipped through the net, and added a nonoise="on" parameter to SEARCH, synonymous with nosummary="on" nosearch="on" nototal="on" nozeroresults="on" noheader="on" noempty="on"

I think I found all the cases of 'on' in tags, but there are still cases of URL params.

SVN 4347

-- CrawfordCurrie - 03 Jun 2005

Merge conflict has not been resolved in the TWikiVariables 2nd half section....

-- ThomasWeigert - 03 Jun 2005

Where? It looks OK to me....

-- CrawfordCurrie - 03 Jun 2005

Look here....

-- ThomasWeigert - 04 Jun 2005

I fixed the doco in SVN 4348.... By the way, this is a great feature...

ah, that's not in the SVN repository; it's only on ntwiki. oh, sven...

-- WillNorris - 04 Jun 2005

Fix record

Discussion

Edit | Attach | Watch | Print version | History: r10 < r9 < r8 < r7 < r6 | Backlinks | Raw View | Raw edit | More topic actions
Topic revision: r10 - 2005-06-21 - SvenDowideit
 
  • Learn about TWiki  
  • Download TWiki
This site is powered by the TWiki collaboration platform Powered by Perl Hosted by OICcam.com Ideas, requests, problems regarding TWiki? Send feedback. Ask community in the support forum.
Copyright © 1999-2026 by the contributing authors. All material on this collaboration platform is the property of the contributing authors.