tracker issue : CF-3418667

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

regsitering a CFC.cbFunc in another CFC and using it uses the wrong variables-scope

| View in Tracker

Status/Resolution/Reason: Closed/Withdrawn/

Reporter/Name(from Bugbase): Martin Baur / Martin Baur (tinu8805)

Created: 12/09/2012

Components: Language, CF Component

Versions: 9.0.1

Failure Type:

Found In Build/Fixed In Build: 9.0.1 /

Priority/Frequency: Major / All users will encounter

Locale/System: English / Win 2008 Server R2

Vote Count: 0

Problem Description:

a cfc method used as a callback function from another cfc uses the variables scope of chte calling cfc instead of the callee.

Problem occurs the same way in CF 10 wher function coudl be used as a type declarator


Steps to Reproduce:

component  MCU {
  variables.mcu.clock = 0;
 //  more of variables.mcu.*

  Init () {
//    Create all targets, call each target’s registerMCUListener to let them know whom to call back.
               variables.mcu.targets[i] = CreateObject ("component", "target").Init ();
               variables.mcu.targets[i].registerMCUListener (cbFromTarget);
  }



   private numeric function cbFromTarget (struct msg) {

writedump (var=#variables#);  // This shows the variables scope of TARGET, expected MCU  <<<<<<<<

      variables.mcu.events.list[variables.mcu.events.ptr] = {
                                                                clock = variables.mcu.clock,
                                                                msg = arguments.msg
                                                             };
      return 0;
   }
}
---


---
component TARGET {
  variables.tg.clock = 0;
  // more of variables.tg.*


   public void function registerMCUListener (any mculistener) {
      /*
       * register the mcu listener function to notify of any events
       */
      variables.tg.mcu.listener = arguments.mculistener;
   }

   private void function ToMCU (struct msg) {
      /*
       * register the mcu listener function to notify of any events
       */
      if (isCustomFunction (variables.tg.mcu.listener)) {
         variables.tg.mcu.listener (msg);
      }
   }
}
---


Idea: The cbFunc registers the message in the MCU’s variables scope 

But it does not. The marked variables.mcu.clock is throwing an error because mcu.clock does not exist in the variables scope.

Observation: CF is using the variables scope of TARGET instead of MCU therefore no clock.

I confirmed that by dumping the variables scope just before that line marked with <<<<<<<<<



Actual Result:

line marked with <<<<<<<< shows the variables of TARGET

Expected Result:

variables of MCU


Any Workarounds:

None, because BOTH cfcs use cb to communicate with each other and other cfcs

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

Watson Bug ID:	3418667

Deployment Phase:	Release Candidate

External Customer Info:
External Company:  
External Customer Name: tinu8805
External Customer Email:  
External Test Config: My Hardware and Environment details:

Attachments:

  1. December 17, 2013 00:00:00: 1_bug3418667.cfm
  2. December 17, 2013 00:00:00: 2_MCU.cfc
  3. December 17, 2013 00:00:00: 3_target.cfc

Comments:

Hi, From the given snippet,I tried to reproduce the bug but I wasnt able to Can you please take a look at the snippet and let me know if I missed anything. Thanks Viny (Comment added from ex-user id:vnigam)
Comment by Adobe D.
16995 | December 17, 2013 05:08:48 AM GMT
As there is no response from customer, and its close it a year now that this bug is waiting for info from customer. Closing this bug as Cannot reproduce. If you have a repro case, you can attach to the bug. We can re-open this bug.
Comment by HariKrishna K.
16996 | December 03, 2014 12:20:48 AM GMT