tracker issue : CF-4207473

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

Unexpected result when setting inline struct inside function call that's inside a CFIF/CFELSE that's inside a CFOUTPUT query loop

| View in Tracker

Status/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 } )#

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:


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.



Here's a CFFiddle of the issue in action:
Comment by Kevin K.
33248 | March 09, 2020 04:12:56 PM GMT
I helped Kevin see the value of creating a reproducible case on cffiddle. It is a rather convoluted set of circumstances that reflect when the "wrong" value will or will not appear. Hopefully someone from Adobe (or otherwise) can dig in and figure out what's amiss. It seems from my own brief digging to be a problem in the struct passed in as an arg to the function. This struct and its use in the function will be more clear in the fiddle link he has added as a comment.
Vote by Charlie A.
33249 | March 09, 2020 04:29:59 PM GMT