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
--
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]]").
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