tracker issue : CF-3993718

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

[ANeff] Bug for: per-App mappings unusable in pseudo-constructor

| View in Tracker

Status/Resolution/Reason: Closed/Withdrawn/AsDesigned

Reporter/Name(from Bugbase): Aaron Neff / Aaron Neff (Aaron Neff)

Created: 05/23/2015

Components: CFComponent

Versions: 11.0

Failure Type:

Found In Build/Fixed In Build: CF11_Final /

Priority/Frequency: Major / Some users will encounter

Locale/System: ALL / Platforms All

Vote Count: 0

Adobe, here is the ticket as requested:

per-App mappings are unusable in Application.cfc's pseudo-constructor

repro:

Application.cfc
---------------
component {
  THIS.name = "ticket_mapping";
  THIS.mappings['/mymapping'] = "c:\foo";
  writeOutput(expandPath('/mymapping'));
  void function onRequest() {
    writeOutput(expandPath('/mymapping'));
  }
}

actual output: C:\path\to\site\mymappingC:\foo
expected output: C:\fooC:\foo

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

Watson Bug ID:	3993718

External Customer Info:
External Company:  
External Customer Name: Aaron
External Customer Email:  
External Test Config: Verified on CF11 Update 5.

Attachments:

Comments:

I dunno whether this is a bug is it? This this-scoped variables are just settings, they don't actually create the mappings. And CF has to instantiate the object (and the pseudo-constructor is therefore run) before it can get the settings, and then create the mappings. You're kinda expecting the code to run inside out, I think. I realise this is not completely obvious until one stops to think about it. At the very least the docs should be updated to explain this. And maybe the way app-based mappings should be augmented by a createAppMappings() function which one can explicitly call to create a mapping? I can't see why this shouldn't be possible? -- Adam
Comment by External U.
7324 | May 23, 2015 09:54:50 AM GMT
This is not a bug. This behavior is by design. Adam stated it correctly that CF has to insantiate the object before it gets the mappings defined in psuedo-constructor . Let me know if you have any other concerns. Thanks!
Comment by Suchika S.
7325 | June 05, 2015 02:52:48 AM GMT
Hi Adam and Suchika, You're right! I've confirmed the same w/ THIS.datasource and THIS.timeout and added the following note to https://wikidocs.adobe.com/wiki/display/coldfusionen/Defining+the+application+and+its+event+handlers+in+Application.cfc: "These application-wide settings and variables take effect after the Application.cfc initialization code has ran." Does that note sound okay? The createAppMappings() idea is a good one and would be useful, but *I* am okay w/o it now that I realize what's going on =) And, of course, I'm okay w/ this ticket being Closed/NotABug/AsDesigned. And thanks very much Adam for that enlightenment. I guess I never tested this fully nor thought it thru properly. Thanks!, -Aaron
Comment by External U.
7326 | September 02, 2015 01:37:45 AM GMT
Closing the bug as per the discussion below. Thanks, Suchika
Comment by Suchika S.
7327 | September 21, 2015 01:55:34 AM GMT