Summary

      Boolean parameters in user macros ignore default values

      Environment

      • Confluence 5.5.1 and above

      Steps to Reproduce

      1. 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
        
      2. 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.

            [CONFSERVER-40831] Boolean parameters in user macros ignore default values

            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:

            ## @param debug:title=Debug Mode|type=boolean|default=false
             
            #if($paramdebug)
            BOOLEAN VARIABLE IS TRUE 
            #end
            #if(!$paramdebug)
            BOOLEAN VARIABLE IS FALSE
            #end
            

            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.

            ## @param debug:title=Debug Mode|type=boolean|default=false
             
            #if($paramdebug  == true)
            BOOLEAN VARIABLE IS TRUE 
            #end
            #if($paramdebug == false)
            BOOLEAN VARIABLE IS FALSE
            #end
            

            So not sure why Velocity code is not working as documented, but this change causes any old code to not work properly.

            Bill Bailey added a comment - 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: ## @param debug:title=Debug Mode|type= boolean | default = false # if ($paramdebug) BOOLEAN VARIABLE IS TRUE #end # if (!$paramdebug) BOOLEAN VARIABLE IS FALSE #end 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. ## @param debug:title=Debug Mode|type= boolean | default = false # if ($paramdebug == true ) BOOLEAN VARIABLE IS TRUE #end # if ($paramdebug == false ) BOOLEAN VARIABLE IS FALSE #end So not sure why Velocity code is not working as documented, but this change causes any old code to not work properly.

            I have upgraded my testing instance to 5.9.5. The Booleans still are not working.

            Bill Bailey added a comment - I have upgraded my testing instance to 5.9.5. The Booleans still are not working.

            This issue also impacts the user-macro module for user macros converted to plugins. Booleans fail to toggle; always evaluate as true.

            Bill Bailey added a comment - This issue also impacts the user-macro module for user macros converted to plugins. Booleans fail to toggle; always evaluate as true.

              Unassigned Unassigned
              dponzio Daniel Ponzio
              Affected customers:
              8 This affects my team
              Watchers:
              6 Start watching this issue

                Created:
                Updated: