tracker issue : CF-4204120

select a category, or use search below
(searches all categories and all time range)
Title:

ColdFusion incorrectly executes custom functions named queryExecute()

| View in Tracker

Status/Resolution/Reason: To Test//Fixed

Reporter/Name(from Bugbase): Dan S. / ()

Created: 03/26/2019

Components: Functions

Versions: 2016,2018

Failure Type: Incorrectly functioning

Found In Build/Fixed In Build: All builds of CF2016 and 2018 /

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:

This definitely appears to be a compilation issue. Check out the following CFFiddle example: https://cffiddle.org/app/file?filepath=6101c3e0-17dc-4f5e-bd77-be9200bf309d/25e705e3-b507-404c-b16f-eecbfe1a6585/9bee1f84-5a4c-4080-b154-0448c7583860.cfm The code for the template is just: <cfscript> public void function test() output=false { var results = QueryManager.queryExecute(); } </cfscript> When you try to execute the template with the above code, you'll see a stack trace something like this in the coldfusion-error.log: java.lang.NullPointerException at coldfusion.compiler.Treewalker.postorder(Treewalker.java:97) at coldfusion.compiler.Treewalker.postorder(Treewalker.java:27) at coldfusion.compiler.Treewalker.postorder(Treewalker.java:27) at coldfusion.compiler.Treewalker.postorder(Treewalker.java:27) at coldfusion.compiler.NeoTranslator.parseAndTransform(NeoTranslator.java:475) at coldfusion.compiler.NeoTranslator.translateJava(NeoTranslator.java:407) at coldfusion.compiler.NeoTranslator.translateJava(NeoTranslator.java:160) at coldfusion.runtime.TemplateClassLoader$TemplateCache$1.fetch(TemplateClassLoader.java:480) at coldfusion.util.LruCache.get(LruCache.java:180) at coldfusion.runtime.TemplateClassLoader$TemplateCache.fetchSerial(TemplateClassLoader.java:400) at coldfusion.util.AbstractCache.fetch(AbstractCache.java:58) at coldfusion.util.SoftCache.get_statsOff(SoftCache.java:133) at coldfusion.util.SoftCache.get(SoftCache.java:81) at coldfusion.runtime.TemplateClassLoader.findClass(TemplateClassLoader.java:655) at coldfusion.filter.PathFilter.invoke(PathFilter.java:138) at coldfusion.filter.ExceptionFilter.invoke(ExceptionFilter.java:94) at coldfusion.filter.ClientScopePersistenceFilter.invoke(ClientScopePersistenceFilter.java:28) at coldfusion.filter.BrowserFilter.invoke(BrowserFilter.java:38) at coldfusion.filter.NoCacheFilter.invoke(NoCacheFilter.java:60) at coldfusion.filter.GlobalsFilter.invoke(GlobalsFilter.java:38) at coldfusion.filter.DatasourceFilter.invoke(DatasourceFilter.java:22) at coldfusion.xml.rpc.CFCServlet.invoke(CFCServlet.java:156) at coldfusion.xml.rpc.CFCServlet.doGet(CFCServlet.java:298) at javax.servlet.http.HttpServlet.service(HttpServlet.java:635) at javax.servlet.http.HttpServlet.service(HttpServlet.java:742) at coldfusion.bootstrap.BootstrapServlet.service(BootstrapServlet.java:89) at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:231) at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:166) at coldfusion.monitor.event.MonitoringServletFilter.doFilter(MonitoringServletFilter.java:42) at coldfusion.bootstrap.BootstrapFilter.doFilter(BootstrapFilter.java:46) at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:193) at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:166) at org.apache.tomcat.websocket.server.WsFilter.doFilter(WsFilter.java:52) at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:193) at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:166) at org.apache.catalina.core.StandardWrapperValve.invoke(StandardWrapperValve.java:199) at org.apache.catalina.core.StandardContextValve.invoke(StandardContextValve.java:96) at org.apache.catalina.authenticator.AuthenticatorBase.invoke(AuthenticatorBase.java:493) at org.apache.catalina.core.StandardHostValve.invoke(StandardHostValve.java:140) at org.apache.catalina.valves.ErrorReportValve.invoke(ErrorReportValve.java:81) at org.apache.catalina.core.StandardEngineValve.invoke(StandardEngineValve.java:87) at org.apache.catalina.connector.CoyoteAdapter.service(CoyoteAdapter.java:355) at org.apache.coyote.ajp.AjpProcessor.service(AjpProcessor.java:510) at org.apache.coyote.AbstractProcessorLight.process(AbstractProcessorLight.java:66) at org.apache.coyote.AbstractProtocol$ConnectionHandler.process(AbstractProtocol.java:800) at org.apache.tomcat.util.net.NioEndpoint$SocketProcessor.doRun(NioEndpoint.java:1471) at org.apache.tomcat.util.net.SocketProcessorBase.run(SocketProcessorBase.java:49) at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1149) at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:624) at org.apache.tomcat.util.threads.TaskThread$WrappingRunnable.run(TaskThread.java:61) at java.lang.Thread.run(Thread.java:748) ColdFusion should not be alter code to a custom method named "queryExecute()".
Comment by Dan S.
30577 | March 27, 2019 08:58:24 PM GMT
You mentioned this has been fixed. When is the fix expected? What versions of ColdFusion will be receiving a patch?
Comment by Dan S.
30581 | March 28, 2019 02:17:59 PM GMT
Hi Dan, The fix will be available in the next update of CF 2016 & CF 2018 .  Thanks, Suchika
Comment by Suchika S.
30583 | March 29, 2019 09:10:05 AM GMT
Suchika, Thank you for the update!
Comment by Dan S.
30584 | March 29, 2019 11:27:44 AM GMT