• 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.

Item4434: Patch for improper replacing of "0" with "" (empty string) in URLPARAM default value

Item Form Data

AppliesTo: Component: Priority: CurrentState: WaitingFor: TargetRelease ReleasedIn
Engine URLPARAM Urgent Closed   minor  

Edit Form Data

Reported By:
Applies To:
Current State:
Waiting For:
Target Release:
Released In:


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. frown


It's a bit naff that you can't pass an empty value without the default muscling in, but that's life frown


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.



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 smile

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 smile


Summary Patch for improper replacing of "0" with "" (empty string) in URLPARAM default value
ReportedBy TWiki:Main.KoenMartens
Codebase 4.1.2
SVN Range TWiki-4.1.2, Wed, 01 Aug 2007, build 14493
AppliesTo Engine
Component URLPARAM
Priority Urgent
CurrentState Closed

Checkins TWikirev:14504 TWikirev:14511 TWikirev:14512
TargetRelease minor

Topic attachments
I Attachment History Action Size Date Who Comment
Unknown file formatdiff TWiki.pm.diff r1 manage 0.3 K 2007-08-03 - 21:49 UnknownUser Patch for bug 4434
Unknown file formatdiff URLPARAM.diff r1 manage 8.0 K 2007-08-06 - 09:23 UnknownUser Patch with unit test
Edit | Attach | Watch | Print version | History: r13 < r12 < r11 < r10 < r9 | Backlinks | Raw View |  Raw edit | More topic actions
Topic revision: r13 - 2008-01-22 - KennethLavrsen
This site is powered by the TWiki collaboration platform Powered by PerlCopyright © 2008-2022 by the contributing authors. All material on this collaboration platform is the property of the contributing authors.
Ideas, requests, problems regarding TWiki? Send feedback