# === on objects fails with recursion! WTH?

- Thread: https://externals.io/message/19884
- Original archive: https://news-web.php.net/php.internals/19884
- Started by Amin Azez on 2005-11-01T14:52:30+00:00
- Messages: 5
- Reply by email to internals@lists.php.net
- More for agents: search with https://externals.io/search.md?q={query} · JSON API at https://externals.io/api · documentation at https://externals.io/llms.txt

---

## #19884 — Amin Azez — 2005-11-01T14:52:30+00:00

URL: https://externals.io/message/19884#19884

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

---

## #19885 — Wez Furlong — 2005-11-01T15:23:39+00:00

URL: https://externals.io/message/19884#19885 · In reply to: #19884

I proposed a patch to fix this a while back (at least a year ago).

--Wez.


> 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

---

## #19886 — Jochem Maas — 2005-11-01T15:41:23+00:00

URL: https://externals.io/message/19884#19886 · In reply to: #19885

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:
> I proposed a patch to fix this a while back (at least a year ago).
> 
> --Wez.
> 
> 
> 
> > […]

---

## #19887 — Amin Azez — 2005-11-01T15:43:13+00:00

URL: https://externals.io/message/19884#19887 · In reply to: #19885

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.
> 
> 
> 
> > […]

---

## #19888 — Wez Furlong — 2005-11-01T15:50:51+00:00

URL: https://externals.io/message/19884#19888 · In reply to: #19887

You'll need to search the mailing list archives.

--Wez.


> Wez Furlong wrote:
> > […]
>
> 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
>
> > […]
