=== on objects fails with recursion! WTH?

php.internals

Amin Azez

20 years ago
if ($object1===$object2) does a recursive check! "Fatal error: Nesting level too deep - recursive dependency?" Whats going on? I've go lots of object references all highly recursive and I just sometimes need to check if two objects are the same object i.e. they have the same storage address; I don't need to (and can't afford the time) to recursively check every field. Is there a ==== instead that REALLY does what it seems === is trying to fake, presumably to cover up all the object copying that is normally going on but that I've managed to avoid? Sam

Wez Furlong

20 years ago
I proposed a patch to fix this a while back (at least a year ago). --Wez. On 11/1/05, Amin Azez <azez@ufomechanic.net> wrote:

Jochem Maas

20 years ago
this is a php4-only problem right? (or is the little test below insufficient to test the stated problem?) THIS: ---------------------- php -r ' class A { public $b; function __construct(B $b) { $this->b = $b; $b->setA($this); } } class B { public $a; function setA(A $a) { $this->a = $a; } } $y = new B; $x = new A($y); $z = $x; $clone = clone $x; var_dump(($x === $z), ($x === $clone), ($x == $z), ($x == $clone)); ' RETURNS (php5.0.4): ---------------------- bool(true) bool(false) bool(true) bool(true) Wez Furlong wrote:

Amin Azez

20 years ago
Wez Furlong wrote:
> I proposed a patch to fix this a while back (at least a year ago).
I'm trying to file it as a bug, but bugs.php.net seems to be down, probably busy recusrively comparing objects or something. Could you post it (or a URL) please so I can patch. Had you already filed this as a bug report? Sadly searches on === reveal nothing. Sam

Wez Furlong

20 years ago
You'll need to search the mailing list archives. --Wez. On 11/1/05, Amin Azez <azez@ufomechanic.net> wrote: