tracker issue : CF-3594435

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

Positional arguments are reordered when passed through argumentCollection

| View in Tracker

Status/Resolution/Reason: Closed/Withdrawn/NotABug

Reporter/Name(from Bugbase): Ronald Hopper / Ronald Hopper (RonHopper)

Created: 07/12/2013

Components: Core Runtime

Versions: 10.0

Failure Type:

Found In Build/Fixed In Build: Final /

Priority/Frequency: Major / All users will encounter

Locale/System: English / Win 2008 Server R2 64 bit

Vote Count: 1

Problem Description:
When passing a function's arguments struct through to another function using argumentCollection, the ordered arguments appear to be randomly scrambled.

Steps to Reproduce:
<cffunction name="foo">
  <cfdump var="#arguments#">
  <cfset bar(argumentCollection=arguments)>
</cffunction>

<cffunction name="bar">
  <cfdump var="#arguments#">
</cffunction>

<cfset foo("alpha", "bravo", "charlie")>


Actual Result:
The two dumps yield different results.
struct
1	 alpha
2	 bravo
3	 charlie
struct
1	 charlie
2	 bravo
3	 alpha

Expected Result:
The two dumps should be identical.
struct
1	 alpha
2	 bravo
3	 charlie
struct
1	 alpha
2	 bravo
3	 charlie

Any Workarounds:
Unknown.

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

Watson Bug ID:	3594435

External Customer Info:
External Company:  
External Customer Name: RonHopper
External Customer Email:  
External Test Config: My Hardware and Environment details:

System Information

Server Details

Server Product	 ColdFusion

Version	 10,0,11,285437

Tomcat Version	 7.0.23.0

Edition	 Enterprise  

Serial Number	 118550018169890656561861  

Operating System	 Windows Server 2008 R2  

OS Version	 6.1  

Update Level	 /C:/ColdFusion10/cfusion/lib/updates/chf10000011.jar  

Adobe Driver Version	 4.1 (Build 0001)  

JVM Details

Java Version	 1.7.0_15  

Java Vendor	 Oracle Corporation  

Java Vendor URL	http://java.oracle.com/

Java Home	 C:\ColdFusion10\jre  

Java File Encoding	 Cp1252  

Java Default Locale	 en_US  

File Separator	 \  

Path Separator	 ;  

Line Separator	 Chr(13)

User Name	 FLRMFG-MWS-AP60$  

User Home	 C:\  

User Dir	 C:\ColdFusion10\cfusion\bin  

Java VM Specification Version	 1.7  

Java VM Specification Vendor	 Oracle Corporation  

Java VM Specification Name	 Java Virtual Machine Specification  

Java VM Version	 23.7-b01  

Java VM Vendor	 Oracle Corporation  

Java VM Name	 Java HotSpot(TM) 64-Bit Server VM  

Java Specification Version	 1.7  

Java Specification Vendor	 Oracle Corporation  

Java Specification Name	 Java Platform API Specification  

Java Class Version	 51.0

Attachments:

Comments:

I am upgrading an app from CF8 to CF10 which makes heavy use of the argument collections like this. I would certainly expect the order of arguments to be preserved when passed through argumentCollection, and I do not know any simple work around.
Comment by External U.
14979 | July 12, 2013 01:11:39 PM GMT
I found an even simpler test: <cffunction name="foo"> <cfdump var="#arguments#"> </cffunction> <cfset foo(argumentCollection={ "1": "alpha", "2": "bravo", "3": "charlie" })> Just passing an argument collection with numeric keys causes scrambling of the keys.
Comment by External U.
14980 | July 12, 2013 01:21:05 PM GMT
This is kinda expected behaviour. argumentCollections are not arrays, and don't preserve ordering (yes, this is the issue, I know), but this is by design. There is no guarantee of ordering here. The shortfall is that an argumentCollection *should* be able to be passed as an array. If arguments are passed to a function as an array (ie: ordered, not named), then "arguments" should preserve that thenceforth. This is a change req, not a bug though. -- Adam
Comment by External U.
14981 | July 12, 2013 03:17:40 PM GMT
+1 to make argumentCollection work with ordered as well as unordered arguments. -- Adam
Vote by External U.
14984 | July 12, 2013 03:19:40 PM GMT
+1 to Adam. This is not a bug since argumentCollection does not guarantee any order. It is just a struct and will give you value for a given key.
Comment by Rupesh K.
14982 | July 15, 2013 04:54:31 AM GMT
OK, if it is "just a struct and will give you value for a given key," then why does it not preserve keys that happen to be numeric? <cffunction name="foo"> <cfdump var="#arguments#"> </cffunction> <cfset myStruct = {"1": "alpha", "2": "bravo", "3": "charlie" }> <cfset foo(argumentCollection=myStruct)> In this case, I am not passing an array, but a struct. The keys are not preserved across the argumentCollection call. Seems like a bug,
Comment by External U.
14983 | July 15, 2013 01:37:50 PM GMT