tracker issue : CF-3040372

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

Bug 80552:Use of "LOCAL" inside a cffunction is broken

| View in Tracker

Status/Resolution/Reason: Closed/Fixed/

Reporter/Name(from Bugbase): Sami Hoda / Sami Hoda (samihoda2)

Created: 11/02/2009

Components: Language, CF Component

Versions: 9.0

Failure Type: Unspecified

Found In Build/Fixed In Build: 0000 / 258574

Priority/Frequency: Normal / Most users will encounter

Locale/System: English / Platforms All

Vote Count: 6

Problem:

Use of "LOCAL" inside a cffunction is broken. Certain use cases, such as pulling values from other functions and setting that to local, as many frameworks do, is broken. See: http://www.bytestopshere.com/post.cfm/major-flaw-in-cf9-may-break-codeTHIS IS A SEVERE ISSUE. WILL DELAY UPGRADES, AND BREAK NUMEROUS PROJECTS. SEE COMMENTS AS WELL IN BLOG ENTRY. 
Method:

Use of "LOCAL" inside a cffunction is broken. Certain use cases, such as pulling values from other functions and setting that to local, as many frameworks do, is broken. See: http://www.bytestopshere.com/post.cfm/major-flaw-in-cf9-may-break-codeTHIS IS A SEVERE ISSUE. WILL DELAY UPGRADES, AND BREAK NUMEROUS PROJECTS. SEE COMMENTS AS WELL IN BLOG ENTRY. 

<!--- local.cfc --->
<cfcomponent>
 
	<cffunction name="doSomething" returntype="any" access="public" output="false" >
		<cfset var local = getProperties() >
		<cfset local.strVersion = SERVER.ColdFusion.ProductVersion >
		<cfset local.strLevel = SERVER.ColdFusion.ProductLevel >
		<cfreturn local >
	</cffunction>
 
	<cffunction name="getProperties" returntype="struct" access="private" output="false">
		<cflog text="in getProperties()">
		<cfset var local = structNew() >
		<cfset local.firstName = "John" >
		<cfset local.lastName = "Doe" >
		<cfreturn local >
	</cffunction>
 
</cfcomponent>



<!--- local.cfm --->
<cfset test = createObject("component","local")>
<cfset result = test.doSomething()>
<cfdump var = "#result#">
Result:

No error message!

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

Watson Bug ID:	3040372

External Customer Info:
External Company:  
External Customer Name: Sami Hoda
External Customer Email: 46E545A3445FFD1F992015D5
External Test Config: 11/02/2009

Attachments:

Comments:

This is a bug that needs to be fixed, it amazes me how Adobe use the backward compat issue to not have Dump(); and Abort(); as script because it would break existing code. And yet here is a typical example where Adobe have gone against that rule, so if this was discussed as a known issue that needed work around why was it so important that backward compatability was an issue for Dump() and Abort(). One really has to wonder sometimes why Adobes left ahdn never knows what its right hand is doing.
Vote by External U.
22573 | November 11, 2011 12:40:04 AM GMT
This is definitely something that needs to be addressed, as I have seen this bug myself. Although I don't know if the solution is to fix it; the solution might be to throw an error when local is set. A compatibility checker in CFAdmin to check for the setting of local in a function, as well as a way to correct this code, such as setting local to _local, is strongly suggested. A tech note is DEFINITELY needed ASAP. This must be changed on any application planning to upgrade to CF9.
Vote by External U.
22574 | November 11, 2011 12:40:06 AM GMT
This bug has been voted..
Vote by External U.
22575 | November 11, 2011 12:40:07 AM GMT
This bug has been voted..
Vote by External U.
22576 | November 11, 2011 12:40:08 AM GMT
On/Off option in CFADMIN? Some way of merging the result of <cfset var local = someFunction() /> back into local?
Vote by External U.
22577 | November 11, 2011 12:40:09 AM GMT
This bug has been voted..
Vote by External U.
22578 | November 11, 2011 12:40:11 AM GMT