Difference in CALLER scope assignment between ACF and Lucee
I just noticed a small difference in the way ACF and Lucee treat `CALLER` scope assignment, specifically with regard to how keys with dots work. Assuming that I have this line in a ColdFusion custom tag:
In ACF, that will store foo into the url scope.
In Lucee, that will store url.foo into the variables scope.
Small but interesting difference. I wrote it up here: https://www.bennadel.com/blog/3995-divergent-caller-scope-assignment-behavior-in-adobe-coldfusion-and-lucee-cfml-5-3-7-48.htm
I've checked this ticket and confirmed the issue happened on lucee latest version 184.108.40.206-SNAPSHOT also. Custom tag assigns the values to URL scope using caller was stored in variables scope instead of URL. Seems ACF works fine. Above mentioned workaround for this issue, using cfparam and setvariable() to assign value are works fine. I added a testcase for this ticket.
Pull Request: https://github.com/lucee/Lucee/pull/1220
Over on twitter, mentioned that you could probably use setVariable() for this as well. As in:
Which, I think, does the same thing that the <cfparam> approach does, but with a more semantic invocation (note that I have not tested this)
Actually, I did just try changing:
… using dot-notation instead of bracket-notation, and it seems to work consistently in both ACF and Lucee. So, at least that’s maybe a valid work-around. Though, of course, that means using the <cfparam> tag to set values into the caller scope instead of using direct assignment.
As per my discussion with , one such use-case for this might be if you wanted to create a custom implementation of the cfparam tag. Imagine a ColdFusion custom tag that looked like this, using the <cfparam> tag under the hood to perform the assignment, but wrapping its invocation in a try/catch block with custom error handling:
Then, I could consume this ColdFusion custom tag as such:
In ACF, this generates:
url.foo => “woot woot!”
And in Lucee, this generates:
variables[ 'url.foo' ] => “woot woot!”