tracker issue : CF-4204120

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

ColdFusion incorrectly executes custom functions named queryExecute()

| View in Tracker

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:

helper = {};
helper["queryExecute"] = function (string sql, any queryParams, any queryOptions){
    return arguments;

// NOTE: helper.queryExecute(); will generate a compilation error
x = helper.queryExecute("select * from people");
y = helper.queryExecute("select * from people where id = ?", [1]);
z = helper.queryExecute("select * from people where id = ?", [1], {datsource="test"});

Actual Result:

SQL: select * from people

	1) 1 
SQL: select * from people where id = ?

4: z
	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.



This definitely appears to be a compilation issue. Check out the following CFFiddle example: 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( at coldfusion.compiler.Treewalker.postorder( at coldfusion.compiler.Treewalker.postorder( at coldfusion.compiler.Treewalker.postorder( at coldfusion.compiler.NeoTranslator.parseAndTransform( at coldfusion.compiler.NeoTranslator.translateJava( at coldfusion.compiler.NeoTranslator.translateJava( at coldfusion.runtime.TemplateClassLoader$TemplateCache$1.fetch( at coldfusion.util.LruCache.get( at coldfusion.runtime.TemplateClassLoader$TemplateCache.fetchSerial( at coldfusion.util.AbstractCache.fetch( at coldfusion.util.SoftCache.get_statsOff( at coldfusion.util.SoftCache.get( at coldfusion.runtime.TemplateClassLoader.findClass( at coldfusion.filter.PathFilter.invoke( at coldfusion.filter.ExceptionFilter.invoke( at coldfusion.filter.ClientScopePersistenceFilter.invoke( at coldfusion.filter.BrowserFilter.invoke( at coldfusion.filter.NoCacheFilter.invoke( at coldfusion.filter.GlobalsFilter.invoke( at coldfusion.filter.DatasourceFilter.invoke( at coldfusion.xml.rpc.CFCServlet.invoke( at coldfusion.xml.rpc.CFCServlet.doGet( at javax.servlet.http.HttpServlet.service( at javax.servlet.http.HttpServlet.service( at coldfusion.bootstrap.BootstrapServlet.service( at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter( at org.apache.catalina.core.ApplicationFilterChain.doFilter( at coldfusion.monitor.event.MonitoringServletFilter.doFilter( at coldfusion.bootstrap.BootstrapFilter.doFilter( at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter( at org.apache.catalina.core.ApplicationFilterChain.doFilter( at org.apache.tomcat.websocket.server.WsFilter.doFilter( at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter( at org.apache.catalina.core.ApplicationFilterChain.doFilter( at org.apache.catalina.core.StandardWrapperValve.invoke( at org.apache.catalina.core.StandardContextValve.invoke( at org.apache.catalina.authenticator.AuthenticatorBase.invoke( at org.apache.catalina.core.StandardHostValve.invoke( at org.apache.catalina.valves.ErrorReportValve.invoke( at org.apache.catalina.core.StandardEngineValve.invoke( at org.apache.catalina.connector.CoyoteAdapter.service( at org.apache.coyote.ajp.AjpProcessor.service( at org.apache.coyote.AbstractProcessorLight.process( at org.apache.coyote.AbstractProtocol$ConnectionHandler.process( at$SocketProcessor.doRun( at at java.util.concurrent.ThreadPoolExecutor.runWorker( at java.util.concurrent.ThreadPoolExecutor$ at org.apache.tomcat.util.threads.TaskThread$ at 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