Sorry if I'm late in noticing this - but something odd has happened with listToArray. I was reviewing SVN commits at work today when I noticed a coworker checked in a file where he stated that he had to modify a listToArray call because of "some change" to listToArray in ColdFusion 9. Now - I knew that listToArray changed in CF9. The reference shows that the multiCharacterDelimiter argument was added in CF9. However, in both CF8 and 9, the 3rd argument, includeEmptyFields, defaults to false.
So, given the following string:
<cfset str = ", A , B , , , 0">
<cfset arr = listToArray(str)>
<cfdump var="#arr#">
I'd expect an array with 3 items: A, B ,0. However, in ColdFusion 8, the array contains A, B, 2 empty elements, and 0. I then noticed something. The list items weren't empty - they had a space. Technically, that's content. Now practically I can see why it is treated as empty content, but this was a surprising change since - for the most part - Adobe treats backwards compatability as something close to the Prime Directive. Personally I think CF8 is doing the right thing.
I can say that when ignoreEmptyFields is set to true, both CF8 and 9 return the exact same array.
Archived Comments
Halle-frickin-lujia. I, for one, welcome our new finally-working-right-screw-compatibility listToArray overlords.
I rewrote my own listToArray workaround for more projects than I want to think about. I have yet to work on a project where the old "silently drop empty elements" mis-feature would have been useful. If some later commenter would care to enlighten me as to why the old way was A Good Thing, I'd be happy to listen.
Interesting... I agree CF8's behaviour makes the most sense. So CF9 should be doing the same both for the sake of "most sense" and "backwards compat".
Maybe there's a fix on the horizon though... I see there's an issue covering this in the bug tracker - http://cfbugs.adobe.com/cfb... - which is marked as verified & closed. Whilst there's no way to interpret what "closed" means, hopefully it's closed because it's been fixed in 9.0.1, which - according to the Adobe bods who were in London for Scotch on the Rocks recently - is due out in the latter part of this year.
--
Adam
I can confirm - fixed in 901. (Just asked permission to 'leak' this so please don't consider it a NDA breach. ;)
Oh. Ack. Arg. I misread your post. I retract my celebration.
I didn't realize they'd fixed it in CF8, then reverted the fix in CF9.
sane: arrayLen(listToArray("1, ,3")) eq 3
Silently eliminating elements is scary nuts.
I love the way you digg deep in the ColdFusion core and explain functions that I just take for granted. Thanks for the heads-up.
@Ray If you can "leak" 9.0.1 details do you have any permission to "leak" 9.0.1 release time frame? ;-D (can't hurt to ask can it?)
CF901 will be released on a day that ends with "y".
Yes! Awesome intel. Thanks ray.
*Ray - You get capital R.
A day that ends in "y"? Aw, shucks, I was hoping for tomorrow.
James,
It's even better news...today ends in a Y!
Thanks for the heads-up Ray.
FYI, you reference "includeEmptyFields" in your first paragraph and "ignoreEmptyFields" in your last. Was that intentional?
It's definitely includeEmptyFields. Pardon the brain fart. :)