Hello fellow developers,
I am working on upgrading our core, based on xwiki 1.5.4 to xwiki 3.2. Quite a jump.
Among the least jump, velocity seems to have jumped from version 1.5 to version 1.7.
Nonetheless, this seems to cause a surprising effect: while macros could redefine the
value of parameters they were passed, and that change was honoured after the macro, they
cannot anymore.
The following script:
#macro(redefine $var)
#set($var="redefined")
#end
#set($x="original")
x is $x
#redefine($x)
x is $x
gives the following output in a new core:
x is original
x is original
and the following in our old core:
x is original
x is redefined
This has all sorts of consequences including such macros as the navigation not receiving
the result of normalizelink...
Did I miss an optional parameter of velocity to revert to the old method?
Hi Paul,
Yes, this is something known, and there are workarounds to the change,
but there's no easy way of reverting to the old behavior. The way we
used macros wasn't something (at least some of) the Velocity developers
expected to actually happen, and they didn't want to support the old way
macros were evaluated, so this change had to happen.
Here you can see the problem explained in more details, along with some
solutions: