-
Bug
-
Resolution: Unresolved
-
Low
-
None
-
5.5.1, 5.6.5, 5.7.3, 5.9.4
-
1
-
Severity 3 - Minor
-
Summary
Boolean parameters in user macros ignore default values
Environment
- Confluence 5.5.1 and above
Steps to Reproduce
- Create a user macro with the following Code:
## @param debug:title=Debug Mode|type=boolean|default=false ## Print default set #if($paramdebug) BOOLEAN VARIABLE IS TRUE #end #if(!$paramdebug) BOOLEAN VARIABLE IS FALSE #end
- Add it to a page
Expected Results
'BOOLEAN VARIABLE IS FALSE' is printed on the page
Actual Results
The default set is ignored and 'BOOLEAN VARIABLE IS TRUE' is printed instead
Notes
This seems to be related to the following bug: CONF-23704. Although the issue for string variables was fixed in that ticket, booleans still seem to be affected. I've also tested the default being set for boolean variables in Confluence 5.4.3, and the default is not ignored and was actually acknowledged so the changes made might be related.
I just discovered earlier today when trying to find a workaround. Booleans in user macros were actually evaluating as true/null in earlier versions, but now evaluate as true/false. So the classic construct used below (which should work per Velocity docs), is actually only testing not_null/null:
So the result is that it worked in early versions, but now always evaluates as not_null. To obtain correct behavior, need to test Booleans explicitly.
So not sure why Velocity code is not working as documented, but this change causes any old code to not work properly.