object referencing problem

[email protected] ("Teemu Pentinsaari") Wed, 3 Apr 2002 18:57:33 +0300
Newsgroups php.lang
Message-ID <[email protected]>
hi,

I have a problem.....

I have a modular framework application where I use class constructor to load
proper modules ( classes ).
First class calls second class constructor and gives it's own $this as a
parameter.

class a {
  var $_mods = array();
  function a(){
    new b( &$this );
  }
}

Second class calls bunch of modules, assignes them to a class a's member
$_mods and gives those modules $that ( a::this ) as a parameter. Don't ask
me why, too complex to explain :)

class b {
  function b( &$that ){ // <-- a::this
    $that->_mods["mod1"] = new mod1(&$that);
    $that->_mods["mod2"] = new mod2(&$that);
  }
}

Today I found that this kind of approach somehow results 2 php prosecces to
execute same code at the same time in one http-request . I did some mail
sending and got very confused when mail got doubbled even when I added
die("aaaargh") right after mail() function call. I logged timestamps and
pids into file and found out that there were 2 entries with one click with
different pids.

I know, this kind of code will most propably misbehave and act unpredictable
in many ways.

Any ideas what makes process to be duplicated ?


Teemu

php 4.0.2 / 4.1.2
Apache 1.3.12
OS: Solaris something