tracker issue : CF-3825535

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

properties should not be exposed in the this scope

| View in Tracker

Status/Resolution/Reason: Closed/Won't Fix/

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: Normal / Some users will encounter

Locale/System: English / Platforms All

Vote Count: 3

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

ColdFusion exposes properties in the this (PUBLIC) scope. It should not.

Railo gets this right, btw,

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

Watson Bug ID:	3825535

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

Attachments:

Comments:

I add my vote. This bug impacts productivity, in that it undermines encapsulation ('information-hiding'), one of the basic principles of object-oriented programming.
Vote by External U.
10888 | September 21, 2014 10:27:27 AM GMT
+1. Never understood why properties were public.
Vote by External U.
10889 | September 21, 2014 11:21:43 AM GMT
+1 ......................
Vote by External U.
10890 | November 24, 2014 04:42:35 AM GMT
Properties are not pushed or present to THIS scope. Its the cfdump that while dumping the THIS scope dumps all defined properties and calls getter to fetch the property value. If we don't set invokeImplicitAccessor is true, the getter will not be there to be called and hence dump fails to find the value. If noticed carefully, the score is not present as top level (as in the case of variable scope dump) but rather part of PROPERTIES key. If at all, we can fix the cfdump.
Comment by Awdhesh K.
10881 | December 04, 2014 04:34:59 AM GMT
Cheers Awdhesh. I kinda get what you mean, but struggling slightly to have it completely clear. Could perhaps blog something, with some demo repro code and some screen caps etc? This bugbase isn't really conducive to articulating/communicating information like this (Jira would do it fine, btw ;-)
Comment by External U.
10882 | December 04, 2014 05:18:00 AM GMT
Also can you talk me through the status of "open/totest/neverfix". What are you testing if you're never going to fix it? If you've decided you're never going to fix it, why is it open?
Comment by External U.
10883 | December 04, 2014 05:18:47 AM GMT
I note the status has changed to "closed/withdraw/notabug", but by your own admission, Awdhesh, there's at least something to be done to <cfdump> here.
Comment by External U.
10884 | December 05, 2014 01:51:05 AM GMT
When invokeImplicitAccessor is set to true in Application.cfc, properties in CFC work same as if they were in variables scope. Thats why structKeyExists(this,"score") will return true. Also cfdump tag tries to dump all details related to CFC instance and thats why we see properties being listed in cfdump for this scope. We will not be making any changes to this behavior of cfdump. (Comment added from ex-user id:sandeepp)
Comment by Adobe D.
10885 | September 25, 2015 04:47:34 AM GMT
"When invokeImplicitAccessor is set to true in Application.cfc, properties in CFC work same as if they were in variables scope. Thats why structKeyExists(this,"score") will return true. " Huh? You seem to be confusing the variables scope and the this scope here (which are two different things)? Or I'm missing something. Can you pls elaborate a bit?
Comment by External U.
10886 | September 25, 2015 04:54:29 AM GMT
Basically if invokeImplicitAccessor is set to true for following code structKeyExists return true. This gives as impression that the property defined is part of "this" scope. But what happens if because of invoking implicit accessor is allowed structKeyExists call getter for "score". This can give an impression that score property is part of this scope which in not true. component accessors=true { property type="numeric" name="score" default=3; public function dumpScore(){ writeOutput("Exists in this scope: #structKeyExists(this, "score")#<br>"); } } (Comment added from ex-user id:sandeepp)
Comment by Adobe D.
10887 | September 26, 2015 12:48:26 AM GMT