tracker issue : CF-3825537

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

ColdFusion messes up default property values

| View in Tracker

Status/Resolution/Reason: Closed/Withdrawn/Duplicate

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

Created: 09/16/2014

Components: Language, CF Component

Versions: 11.0

Failure Type:

Found In Build/Fixed In Build: CF11_Final /

Priority/Frequency: Major / Some users will encounter

Locale/System: English / Platforms All

Vote Count: 1

Duplicate ID:	CF-3352745

See: http://blog.adamcameron.me/2014/09/cfml-weirdness-with-properties.html

When defaulted by not yet actively *set*, a given property is not exposed in the variables scope. Only after it is defaulted does it show up.

{code}
// Test.cfc
component accessors=true {

	property type="numeric" name="score" default=3;

	public function getPropertyMetadata(){
		return getMetadata().properties;
	}

	public function dumpScore(message){
		writeOutput("#message#:<br>");
		writeOutput("Exists in variables scope: #structKeyExists(variables, "score")#<br>");
		writeOutput("Exists in this scope: #structKeyExists(this, "score")#<br>");
		writeOutput("<hr>");
	}

}
{code}

{code}
<cfscript>
// testTest.cfm

test = new Test();

test.dumpScore("Initial state");

score = test.getScore();
writeOutput("Score is: #score#<br>");
test.dumpScore("After get()");

test.setScore(44);
writeOutput("Score is: #test.getScore()#<br>");
test.dumpScore("After set()");
</cfscript>
{code}

-- 
Adam

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

Watson Bug ID:	3825537

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

Attachments:

Comments:

+1 ......................
Vote by External U.
10879 | November 24, 2014 04:43:55 AM GMT