tracker issue : CF-3316776

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

arrayFindNoCase() returns false negatives

| View in Tracker

Status/Resolution/Reason: Closed/Fixed/

Reporter/Name(from Bugbase): Adam Cameron / Adam Cameron (Adam Cameron)

Created: 08/23/2012

Components: Language, General

Versions: 10.0

Failure Type:

Found In Build/Fixed In Build: Final /

Priority/Frequency: Major / Some users will encounter

Locale/System: English / Win All

Vote Count: 0

Listed in the version 2016.0.0.297996 Issues Fixed doc
Verification notes: verified_fixed on August 28, 2019 using build 2016.0.01.298513
Description
Problem Description:
arrayContains() is supposed to be case sensitive, but when looking-up a struct, the look-up is case insensitive

Steps to Reproduce:
<h1>Control</h1>
<p>This demonstrates that the function works with same-case</p>
<cfset arrayToSearch = [["value"]]>
<cfset arrayToFind = ["value"]>

<cfdump var="#arrayToSearch#" label="arrayToSearch">
<cfdump var="#arrayToFind#" label="arrayToFind">

<cfoutput>
Was it found: #arrayFindNoCase(arrayToSearch, arrayToFind)#<br />
</cfoutput>
<hr />

<cfset arrayToSearch = [new Object("value")]>
<cfset objectToFind = new Object("value")>

<cfdump var="#arrayToSearch#" label="arrayToSearch">
<cfdump var="#objectToFind#" label="objectToFind">

<cfoutput>
Was it found: #arrayFindNoCase(arrayToSearch, objectToFind)#<br />
</cfoutput>
<hr />

<h1>Test</h1>
<p>This demonstrates that the function fails on different casing</p>
<cfset arrayToSearch = [["value"]]>
<cfset arrayToFind = ["VALUE"]>

<cfdump var="#arrayToSearch#" label="arrayToSearch">
<cfdump var="#arrayToFind#" label="arrayToFind">

<cfoutput>
Was it found: #arrayFindNoCase(arrayToSearch, arrayToFind)#<br />
</cfoutput>
<hr />

<cfset arrayToSearch = [new Object("value")]>
<cfset objectToFind = new Object("VALUE")>

<cfdump var="#arrayToSearch#" label="arrayToSearch">
<cfdump var="#objectToFind#" label="objectToFind">

<cfoutput>
Was it found: #arrayFindNoCase(arrayToSearch, objectToFind)#<br />
</cfoutput>
<hr />


Actual Result:
The mismatched-case versions are not found

Expected Result:
The mismatched-case versions should be found

Any Workarounds:
Doesn't matter: it should work properly.

----------------------------- Additional Watson Details -----------------------------

Watson Bug ID:	3316776

External Customer Info:
External Company:  
External Customer Name: Adam Cameron.
External Customer Email:  
External Test Config: My Hardware and Environment details:

Attachments:

Comments:

Sorry, here's Object.cfc (it's used in the test code above. component { public Object function init(value){ variables.value = arguments.value; this.value = variables.value; return this; } }
Comment by External U.
18394 | August 23, 2012 03:59:27 PM GMT
arrayFindNocase will find only the element of the array. If passes searched object is not same to its element (in the case of arrayFindNoCase([["a"],] [A]) ), it should work as expected. Its seems the current behavior is correct and as expected.
Comment by Awdhesh K.
18395 | October 08, 2013 06:26:02 AM GMT
Please read further follow-up: http://cfmlblog.adamcameron.me/2013/10/follow-up-to-not-bug-status-from-adobe.html
Comment by External U.
18396 | October 22, 2013 07:01:43 AM GMT
It looks like that the documentation for this function needs some clarity. Frank, could you please make the appropriate changes.
Comment by Rupesh K.
18397 | October 25, 2013 08:56:48 AM GMT
Modified the doc: https://learn.adobe.com/wiki/display/coldfusionen/ArrayFindNoCase
Comment by Frank J.
18398 | January 17, 2014 12:19:31 AM GMT
Thanks for updating the docs, Frank. And for fixing the glitch in the code example (you can delete my comment now if you like). But this is not "fixed". It's fundamentally wrong that a function that indicates in its name is a NOCASE version of a function doesn't actually behave that way. You can document it out yer arse, it doesn't make the function right. What you need to do is to remove the ability to pass this function anything other than a string, because *it simply doesn't work as described* if you pass it anything else. -- Adam
Comment by External U.
18399 | January 17, 2014 04:39:59 AM GMT
ArrayFindNoCase now accepts only strings, numbers or boolean values as a second parameter.
Comment by Immanuel N.
18400 | July 03, 2015 04:29:30 AM GMT
Hi Adobe, I've verified this is fixed in CF2016 Update 1 (build 2016.0.01.298513), however I've filed CF-4205066 to fix/restore the removed/broken functionality. Thanks!, -Aaron
Comment by Aaron N.
31228 | August 28, 2019 09:15:54 AM GMT