tracker issue : CF-4076193

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

Properties with default values not accessible outside init function

| View in Tracker

Status/Resolution/Reason: Closed/Fixed/

Reporter/Name(from Bugbase): Geoffrey Demoulin / Geoffrey Demoulin (Geoffrey Demoulin)

Created: 10/19/2015

Components: CFComponent

Versions: 11.0

Failure Type:

Found In Build/Fixed In Build: CF11_Final /

Priority/Frequency: Major / All users will encounter

Locale/System: English / Windows 8.1/64bit

Vote Count: 4

Listed in the version 2016.0.0.297996 Issues Fixed doc
Verification notes: verified_fixed on July 27, 2017 using build 2016.0.01.298513
Bug 3352745 has been marked as fixed but still happens when createObject() is called instead of the new() operator. Please see my comments as well as Aaron's on Bug 3352745.

Following description copied from Bug 3352745 with minor modifications:

Problem Description: When creating a component with accessors="true" and a property with a default value the variables struct does not contain the property in any method withing the component unless you set them explicitly in the init function.

Steps to Reproduce:
MyTest.cfc:
component accessors="true" {

property name="privateVarOne" default="privateVarOne default";

function init() {
return this;
}

public void function newMethod() {
var myVar = variables.privateVarOne;
writedump(var="success");
}
}

test.cfm:
<cfset test = createObject("Component", "MyTest").init() />
<cfset test.newMethod() />

Actual Result:
Element PRIVATEVARONE is undefined in VARIABLES.

Expected Result:
success

Any Workarounds:
With a dump in-between it suddenly magically works:
<cfset test = createObject("Component", "MyTest").init() />
<cfdump var="#test#" format="html">
<cfset test.newMethod() />


Explicit setting of variables.privateVarOne in the init function also works (without the dump)

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

Watson Bug ID:	4076193

External Customer Info:
External Company:  
External Customer Name: Geoffrey Demoulin
External Customer Email:

Attachments:

Comments:

+1 - I've also confirmed this by changing "o = new MyCFC();" to "o = createObject("component", "MyCFC");" in the code I posted to ticket CF-3352745 on 12:18:43 PM GMT+00:00 Aug 14, 2015.
Vote by External U.
5527 | October 21, 2015 02:46:08 PM GMT
Fix should be included in an upcoming CF11 update since this really should've been fixed as part of CF-3352745. Thanks!, -Aaron
Comment by External U.
5520 | December 05, 2015 12:57:24 AM GMT
Are we going to see a fix for CF10? I have been waiting patiently for this to be fixed. Most of my code uses createObject. I thought this was finally fixed. :-(
Comment by External U.
5521 | January 11, 2016 10:25:55 PM GMT
Most of my code uses createObject. I need a CF10 fix. cfproperty is useless without this being fixed.
Vote by External U.
5528 | January 11, 2016 10:29:06 PM GMT
[subscribe] As this seems to be a fix for CF-3352745 (which was logged against CF10), it stands to reason THIS should be fixed in 10 too.
Comment by External U.
5522 | January 12, 2016 04:40:48 AM GMT
Adobe can you please pay attention to your clients asking you questions?
Comment by Adam C.
5523 | April 06, 2017 11:58:33 AM GMT
Wanted it easy. Thought, I define a lot of properties. Have some implicit setters called in a loop and use all properties as Variables. Didn't work when component is instantiated with CreateObject.
Vote by Bernhard D.
5529 | April 20, 2017 05:05:39 PM GMT
Subscribe
Comment by Matthew C.
5524 | April 20, 2017 07:00:55 PM GMT
According to my observations it seems fixed for CreateObject() in Coldfusion 2016
Comment by Bernhard D.
5525 | April 21, 2017 07:34:38 AM GMT
Verified this is fixed in CF2016 Update 1 (build 2016.0.01.298513). Thanks!, -Aaron
Comment by Aaron N.
5526 | July 27, 2017 06:38:04 AM GMT