From: Justin F. <je...@ey...> - 2001-07-10 10:19:14
|
Alex: Now Alex, with that arcane Subject:, I hope to get your attention. I think this is important, I have been working hours on this problem, and I think I have been very careful. This problem is difficult to explain, so give me some latitude. To get your attention, your allegation that inter-module communication via the construct: $Page->modules[group][idx_in_group]->some_method_or_parm; DOES NOT WORK anymore since you changed the machinery from using Init() to having a constructor instead. But, that may be a red herring... I am afraid that I have an error somewhere that I just keep overlooking, but I don't think so. General Synopsis of problem --------------------------- 1. I have a Warning module that collects warnings from any module, on a stack, and in the page render I display them all in a "pane". 2. This Warning module is in a group 'bottom', all by itself. 3. From another module, I call a method in the Warning module to stack a warning thus: $Page->modules['bottom'][0]->setWarning($msg); to stack the warning ($msg) within the Warning module/Class on $this->WarningStack. 4. Before Init() was dropped, and the constructor used, I put the stack ($WarningStack) global. The code worked fine, any warning anywhere from any other module was collected on the stack. 5. When a constructor was introduced, I moved $WarningStack inside the Warning class as a var $WarningStack; What it seems like is that inter-module communication via your suggested construct, or the one I am also using, via a "tag", is only talking to a copy of the "real class". In the application, all warnings I collect (and from that module, verify that they are on the stack, by the same construct as above) appear to be present. What that means is if I do from the outside, so to speak: $Page->modules['bottom'][0]->showWarnings(); the stack contains all of the warnings collected. BUT, by the time the Warning module is ready to Output(), the stack $this->WarningStack ONLY HAS stacked data that it put there itself. The "outside" warnings are not present. A bit of code and output _may_ illustrate: IN Warning->Output() #== set some warnings, various ways == global $Page; $this->setWarning("Test inside class". __FILE__); $Warning->setWarning("SET BY TAG"); $Page->modules['bottom'][0]->setWarning("SET BY INDEX"); #== dump the stacks, various ways == echo "<pre>"; echo "var_dump of \$this->WarningStack\n"; var_dump($this->WarningStack); echo "var_dump of \$Page->modules[bottom][0]\n"; var_dump($Page->modules['bottom'][0]->WarningStack); echo "var_dump of & \$Page->modules[bottom][0]\n"; var_dump(& $Page->modules['bottom'][0]->WarningStack); echo "var_dump of \$Warning->WarningStack\n"; var_dump($Warning->WarningStack); echo "var_dump of & \$Warning->WarningStack\n"; var_dump(& $Warning->WarningStack); echo "</pre>"; ------------------- GIVES: =============================================== var_dump of $this->WarningStack array(2) { [0]=> string(22) "IN Warning CONSTRUCTOR" [1]=> string(73) "Test inside class/usr/local/binarycloud/build/en/user/mod/lib/Warning.php" } var_dump of $Page->modules[bottom][0] array(3) { [0]=> string(22) "IN Warning CONSTRUCTOR" [1]=> string(10) "SET BY TAG" [2]=> string(12) "SET BY INDEX" } var_dump of & $Page->modules[bottom][0] &array(3) { [0]=> string(22) "IN Warning CONSTRUCTOR" [1]=> string(10) "SET BY TAG" [2]=> string(12) "SET BY INDEX" } var_dump of $Warning->WarningStack array(3) { [0]=> string(22) "IN Warning CONSTRUCTOR" [1]=> string(10) "SET BY TAG" [2]=> string(12) "SET BY INDEX" } var_dump of & $Warning->WarningStack &array(3) { [0]=> string(22) "IN Warning CONSTRUCTOR" [1]=> string(10) "SET BY TAG" [2]=> string(12) "SET BY INDEX" } ============================================= Why? I have been "fooled in the past" thinking stuff worked, because the usual result is "correct" whether or not you talk to _any_ instantiation of that class. But, in this case, when you need only one stack, one copy, somehow I obviously have more than one stack somewhere... As Einstein once said, "Zend does not play tricks." Oy Weh, I am too tired for levity. What is going on here? Who made the copy, where is the copy, why don't I have only one stack since I moved it within the Warning class? Now, within Page, if I change: $this->modules[$_group][$pos] = new $mod['name']($mod['options']); to $this->modules[$_group][$pos] =& new $mod['name']($mod['options']); the results are the same. _a_frustrated_jef -- Justin Farnsworth Eye Integrated Communications 321 South Evans - Suite 203 Greenville, NC 27858 | Tel: (252) 353-0722 |