tracker issue : CF-3810965

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

arrayFilter() /filter() callback needs to be passed element, index and array

| View in Tracker

Status/Resolution/Reason: Closed/Fixed/

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

Created: 08/23/2014

Components: Language

Versions: 11.0

Failure Type: Usability Issue

Found In Build/Fixed In Build: CF11_Final / CF11 Update5

Priority/Frequency: Normal / Most users will encounter

Locale/System: English / Platforms All

Vote Count: 2

Listed in the version Issues Fixed doc
SSIA: arrayFilter() currently only passes the element to the callback. It also needs to pass the index and they array.

Please don't close this as "as designed" (as will be your wont). I know that. My point is: your design is wrong & needs fixing. And having done that, so does the implementation.

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

Watson Bug ID:	3810965


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



NB:Railo implements this correctly, so please make sure you match its behaviour when you fix this.
Comment by External U.
11262 | August 23, 2014 08:33:14 AM GMT
+1 - consistency in the closure BIFs and member functions please
Vote by External U.
11270 | November 14, 2014 03:09:06 PM GMT
+1 "Make it so, number one." - Jean Lucky Picard, STTNG
Vote by External U.
11271 | November 15, 2014 12:23:32 AM GMT
The following code snippet for listFilter should work as part of this fix:(Reference bug# CF-3845963) <cfscript> list = "2|4"; list.listfilter( function(){ writeDump(arguments); return true; }, "|", true); </cfscript> Expected: should dump the following: index, list, delimiter, and includeEmptyFields (Comment added from ex-user id:nawani)
Comment by Adobe D.
11263 | November 21, 2014 12:56:13 AM GMT
Updated the callback function of ArrayFilter to 'function(item, [,index, array])' Updated the callback function of ListFIlter to 'function(item, [,index, list, delimiter, includeEmptyFields])' Updated the callback function of StructFilter to 'function(key, value, [, struct])'
Comment by Nikhil S.
11264 | November 21, 2014 03:40:08 AM GMT
You say you've mixed the arrayFilter() BIF... have you also fixed Array filter() method?
Comment by External U.
11265 | February 15, 2015 11:47:10 PM GMT
Yes, both of them should work.
Comment by Nikhil S.
11266 | February 16, 2015 12:00:55 AM GMT
Cool, thanks.
Comment by External U.
11267 | February 16, 2015 12:09:59 AM GMT
The fix for this bug is available in the pre-release build of ColdFusion 11 Update 5
Comment by CFwatson U.
11268 | February 20, 2015 09:26:30 AM GMT
Confirmed fixed, cheers.
Comment by External U.
11269 | February 21, 2015 08:02:31 PM GMT