Skip to content

Instantly share code, notes, and snippets.

@JamoCA
Last active October 20, 2022 15:41
Show Gist options
  • Save JamoCA/55db04881d0c6f5aadfcf946625049a2 to your computer and use it in GitHub Desktop.
Save JamoCA/55db04881d0c6f5aadfcf946625049a2 to your computer and use it in GitHub Desktop.
Should a ColdFusion/CFML object change (by reference) when being passed as an argument/attribute collection parameter?
<cfparam name="attributes.var1" default="value1">
<cfparam name="attributes.var2" default="value2">
<!--- 20221020 Should a ColdFusion/CFML object change (by reference) when being passed as an argument/attribute collection parameter?
Using CF20201, it's inconsistent and changes w/customtag + attributecollection, but not with function + argumentcollection.
Twitter: https://twitter.com/gamesover/status/1582874779547095042
Gist: https://gist.github.com/JamoCA/55db04881d0c6f5aadfcf946625049a2
Adobe Documentation: https://helpx.adobe.com/coldfusion/developing-applications/building-blocks-of-coldfusion-applications/writing-and-calling-user-defined-functions/working-with-arguments-and-variables-in-functions.html
--->
<cfscript>
void function argumentsTest(var1="value1", var2="value2"){};
payload = ["var0":now()];
argumentsTest(argumentcollection=payload);
writedump(var=payload, label="udf arguments: should only contain 'var0'.");
writeoutput("<br>");
payload = ["var0":now()];
cf_attributesTest(attributecollection=payload);
writedump(var=payload, label="cftag attributes: should only contain 'var0'.");
</cfscript>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment