Title:
Unexpected result when setting inline struct inside function call that's inside a CFIF/CFELSE that's inside a CFOUTPUT query loop
| View in TrackerStatus/Resolution/Reason: To Fix//BugVerified
Reporter/Name(from Bugbase): Kevin K. / ()
Created: 03/09/2020
Components: Language
Versions: 2016,2018
Failure Type: Data Corruption
Found In Build/Fixed In Build: hf-2018-00007-316715 /
Priority/Frequency: Normal / Few users will encounter
Locale/System: / Win 2016
Vote Count: 1
Problem Description:
This is such a specific set of circumstances that it's difficult to isolate what the exact cause is or reduce it further. Generally speaking, if you loop through a query using CFOUTPUT and inside of that loop you have a CFIF statement and a CFELSE statement, and inside of the CFIF statement you call a function where you're passing in a struct that is defined inside of that function call, the values of the struct appear to get changed/reset to prior iterations of the query loop.
I've verified that this issue does not exist in CF10, CF11, CF2016 (updates 1-6) and have verified that this issue DOES exist in CF2016 (updates 9+) and CF2018 (update 7). All other versions/updates have been untested/unverified.
Due to the multiple conditions that are required to reproduce this, coupled with the fact that this bug hasn't been submitted previously, even though the conditions have existed for over a year, leads me to assume that very few users will encounter this.
Steps to Reproduce:
The best source is my included bug.cfm file. It demonstrates the issue and then shows how changing any ONE aspect resolves the issue.
However, here's the gist:
<cfoutput query="someQuery">
<cfif 1 eq 1>
<cfset controlValue = someQuery.someColumn />
#controlValue# should match #DisplayKeyValue( { "key" : someQuery.someColumn } )#
<cfelse>
</cfif>
</cfoutput>
Actual Result:
Within "DisplayKeyValue()", the value of "key" will not equal the controlValue in certain cases.
Expected Result:
The controlValue should match the output of the hypothetical DisplayKeyValue() function.
Any Workarounds:
Several.
1) Using CFLOOP to loop through a query instead of CFOUTPUT
2) Having no CFELSE statement in your CFIF statement
3) Have no CFIF statements at all
4) Assigning the struct to a variable outside of the function call and passing the variable in, instead.
Attachments:
Comments: