Status/Resolution/Reason: Closed/Fixed/Fixed
Reporter/Name(from Bugbase): Dan S. / ()
Created: 03/26/2019
Components: Language, Functions
Versions: 2016,2018
Failure Type: Incorrectly functioning
Found In Build/Fixed In Build: All builds of CF2016 and 2018 / CF2016U11,CF2018U4
Priority/Frequency: Normal / Some users will encounter
Locale/System: ALL / CentOS 7.3
Vote Count: 0
Problem Description:
In ColdFusion 2016 and 2018 there appears to be a bug in the compilation of code that has a custom function or method named "queryExecute". This works fine in CF11.
The problem is that the left hand assignment of code ends up getting passed as the last argument to the function.
So, if you have a line that looks like:
getPeople = QueryUtil.queryExecute("select * from people");
The method "queryExecute" will receive the value of "getPeople" as a second argument.
I'm guessing this is a compilation issue due to something in ACF implementation of queryExecute() and it needing to know the left-hand assignment variable name. However, it should never be altering a custom method/function that has the same name.
Steps to Reproduce:
https://cffiddle.org/app/file?filepath=4d1e16f3-6d74-4ba5-8a3d-7a9f476ae6c4/a1946893-a8a6-4221-b572-10f24816a8e2/d8ac3206-fc85-44c9-b6ca-56ddbc89617d.cfm
{code:java}
<cfscript>
helper = {};
helper["queryExecute"] = function (string sql, any queryParams, any queryOptions){
//writeDump(arguments);
return arguments;
};
// NOTE: helper.queryExecute(); will generate a compilation error
x = helper.queryExecute("select * from people");
writeDump(x);
y = helper.queryExecute("select * from people where id = ?", [1]);
writeDump(y);
z = helper.queryExecute("select * from people where id = ?", [1], {datsource="test"});
writeDump(z);
</cfscript>
{code}
Actual Result:
struct
QUERYOPTIONS: undefined
QUERYPARAMS: x
SQL: select * from people
struct
QUERYOPTIONS: y
QUERYPARAMS:
[array]
1) 1
SQL: select * from people where id = ?
struct
4: z
QUERYOPTIONS:
[struct]
DATSOURCE: test
QUERYPARAMS:
[array]
1) 1
SQL: select * from people where id = ?
Expected Result:
The variable assignment should not be passed to as an argument to the function/method.
Any Workarounds:
The only workaround is to either rename your function/method or try to create a reference to the function w/a different name.
Attachments:
Comments: