Issues
CFQUERY using attributeCollection fails when inside CFFINALLY
Description
Environment
relates to
Details
Assignee
Michael OffnerMichael OffnerReporter
dan.switzer@givainc.comdan.switzer@givainc.comPriority
NewNew Issue warning screen
Before you create a new Issue, please post to the mailing list first https://dev.lucee.org
Once the issue has been verified, one of the Lucee team will ask you to file an issue
Affects versions
Details
Details
Assignee
Reporter
Priority
New Issue warning screen
Before you create a new Issue, please post to the mailing list first https://dev.lucee.org
Once the issue has been verified, one of the Lucee team will ask you to file an issue
Affects versions
Activity
Zac Spitzer1 June 2022 at 07:00
disabled test case merged
https://github.com/lucee/Lucee/commit/3647a5ac3c34d963e2d64b1c878d57b529d61c3a
Pothys - MitrahSoft2 February 2022 at 10:06
I added a testcase to this ticket
Pull Request: https://github.com/lucee/Lucee/pull/1554
Pothys - MitrahSoft28 January 2022 at 13:35
@Zac Spitzer In the script, when the try block is empty or has the commented lines only it works
https://trycf.com/gist/3ceeb1d489b266a3ae6f47b0644a477f/lucee5?theme=monokai
Zac Spitzer28 January 2022 at 11:47
@Adam Cameron mentioned on slack, this does however work in cfscript
Pothys - MitrahSoft28 January 2022 at 11:35
I've checked this ticket and confirmed the issue happened on the lucee latest version 5.3.9.59-SNAPSHOT too. Tag with attributeCollection in the finally block doesn't work as expected and it losses the attribute values from attributeCollection.
Also In finally block using an empty struct as attributeCollection doesn't throw the required attribute error even if the tag has required attributes.
<cftry>
<cffinally>
<cfset attrs = {}>
<cfdirectory attributeCollection="#attrs#">
</cffinally>
</cftry>
It didn't throws required attribute error instead it throws NPE(considers the directory value as null and action values as list).
lucee.runtime.exp.NativeException: java.lang.NullPointerException
at lucee.runtime.tag.Directory.actionList(Directory.java:444)
at lucee.runtime.tag.Directory.doStartTag(Directory.java:380)
at test.testcases.ldev3847.test_cfm$cf$e.call(/test/testcases/LDEV3847/test.cfm:39)
But below one throws error as expected
<cfdirectory action="create">
I'm running into a very weird issue with
<cfquery />
when theattributeCollection
is used to propagate it's attributes when the code is inside a<cffinally />
block. When run, the code ends up throwing an exception like:Attribute [datasource] is required when attribute [dbtype] is not [query] and no default datasource is defined on line XXX
I've put together an example of this on TryCF:
https://www.trycf.com/gist/736058f17b9841bb53bf7e2fc198d4d7/lucee5?theme=monokai
<cfscript> x = queryNew("a,b,c", "varchar,varchar,varchar", [[1, 2, 3], [4, 5, 6], [7, 8, 9]]); attrs = {name="y", dbtype="query"}; </cfscript> <cftry> <cfset z = "" /> <cffinally> <cfquery attributeCollection="#attrs#"> select * from x where a > 2 </cfquery> </cffinally> </cftry> <cfdump var="#y#" />
While this code is use QoQs, the same code with a
datasource
defined also throws an error. It's just easier to show off using QoQ since TryCF doesn't support database connections.If you change this code to move the
<cfquery />
block outside the<cffinally />
block, the code executes as you'd expect.