|
From: Justin F. <je...@ey...> - 2001-07-13 03:17:05
|
Alex:
The Subject is a rather meaningless statement, but here
I am back again with the problem that I explained the
other day, and for which I didn't get too much sympathy for.
I will have to give you a simple example of the "problem"
with BC, using your code, not mine, so to speak.
I will use your "Hello World" disto. I will use this
to prove that something is "rotten". What I think is
that it may have to do with the Zend mechanization.
So, this is easy, just drop the following into the
HelloWorld.php module, in the context evident outside
my comments.
[== snip, snip ==]
echo "</pre>\n<!-- end HelloWorld test module output
-->\n";
#=========== jef experiment =====================
#== set some warnings, two ways... ==
global $Page;
$this->setWarning("Called inside class with \$this");
$Page->modules['content'][2]->setWarning("SET BY INDEX");
if($this->HaveWarning || true) { // make true for
experiment
printf("<h4>WARNINGS (%d)</h4>\n",
count($this->WarningStack));
echo "<pre>\n";
for($i=0; $i < count($this->WarningStack); $i++)
{
printf("%d: %s\n",
$i+1,$this->WarningStack[$i]);
}
echo "</pre>\n";
} else {
echo " ";
}
}
function setWarning($msg="Unknown warning") {
$this->HaveWarning = true;
array_push($this->WarningStack,$msg);
printf("setWarning called...with [%s]. Now %d warnings on
stack.<br>\n",
$msg,count($this->WarningStack));
}
var $WarningStack = array();
#====================================================
// }}}
// {{{ Vars
[== snip, snip ==]
NOW, my friend, render the bloody thing. Do you understand
what you see? You will see that, somehow, there are two
copies of WarningStack somewhere, or Zend does not do dereferencing
correctly with this suggested construct to communicate between
modules of
$Page->modules['content'][2]->do_or_call_something
In Page, you are actually "storing" the instantiated classes
inside the Page Class in $Page->modules. Considering what
little I know about Zend, I do know that Zend makes copies of
the vars, but only references the methods after instantiation.
IF I PUT THE STACK GLOBAL, EVERYTHING WORKS. Using a stack
inside a class that is instantiated in Page, it does not
work. I did not confuse this example by putting my "tag
identification" of a module, but believe me, that also
"does not work".
I think this problem may be more sinister than you think,
and if I am not all wet here, it has grave ramifications.
I think it would be "fixed" by having the instantiations
of the modules in a global array, and not inside the Page class
itself. But I will let you mull this over.
I have been trying to chase down this "bug" in my code for
several days. It is just something else, in my opinion,
that Zend is doing, and for which BC is assuming a behaviour
that does not correspond to reality. You are going to see
what is APPARENTLY TWO COPIES OF VARS (WarningStack), viz:
setWarning called...with [Called inside class with $this]. Now 1
warnings on stack.
setWarning called...with [SET BY INDEX]. Now 5 warnings on stack.
_jef
--
Justin Farnsworth
Eye Integrated Communications
321 South Evans - Suite 203
Greenville, NC 27858 | Tel: (252) 353-0722
|