In lib/TWiki.pm the code for handling the URLPARAM variable has this line to deal with a default=".." parameter in the variable:
$value = $params->{default} || '';
However, when default="0", $params->{default} will evaluate to false and the empty string will be used, instead of the string "0".
A trivial patch is attached.
--
TWiki:Main/KoenMartens - 03 Aug 2007
I thought I had got rid of this problem everywhere. I guess not.
Confirmed and elevated to Urgent. Requires a unit testcase, which the patch does not include.
CC
It's a bit naff that you can't pass an empty value without the default muscling in, but that's life
CC
Well ok, i'll do a unit test. I just went through the whole she-bang of installing a test environment and running some existing unit tests.. But: it seems there is
no unit test for URLPARAM yet. Meaning i will have to write it from scratch, which i might not get correct without some documentation about what the function is actually supposed to do.. Anyway, i'll try to extract what i can from the code..
--
TWiki:Main.KoenMartens - 05 Aug 2007
Koen, you're a hero! I have slowly been adding unit tests for each of the TWiki variables, but it's a long task for one person working on their own; reverse engineering tests onto existing code is never easy.
You can base your URLPARAM test on one of the other Fn_ tests, for example
Fn_IF.pm
. Take a copy, create Fn_URLPARAM.pm, delete the IF tests and add your own. Don't forget that all the tests are checked in to
twikiplugins/UnitTestContrib/test/unit
.
I changed the status back to "BeingWorkedOn" until the test is ready.
CC
BLUSH
Ok, I attached a new patch (URLPARAM.diff) that includes the unit test. It is my first unit test, so please be gentle with me
It is a good thing you made me write the unit test, as i caught a couple of other 'evaluate to false' bugs in the URLPARAM code. I also used the
VarURLPARAM documentation to see what desired behaviour is.
I think there is an endless variation of tests that could/should be performed, so I hope i've included a representative selection of them in the unit test.
--
TWiki:Main.KoenMartens - 06 Aug 2007
Thanks for that.... committed
CC