php.net |  support |  documentation |  report a bug |  advanced search |  search howto |  statistics |  random bug |  login
Bug #40382 Nesting/recursion runtime error
Submitted: 2007-02-07 09:35 UTC Modified: 2007-02-07 12:37 UTC
From: denis at bytezone dot com Assigned:
Status: Not a bug Package: Unknown/Other Function
PHP Version: 5.2.0 OS: windows vista
Private report: No CVE-ID: None
 [2007-02-07 09:35 UTC] denis at bytezone dot com
Description:
------------
When I create objects which contain a nested pointer back to itself, it cannot be compared with another object for equality.

Error only occurs when the two objects being compared are the same object.

Also, using === for comparison works correctly.



Reproduce code:
---------------
<?php

$thing = new Thing ();
$otherThing = new OtherThing ();

$thing->otherThing = $otherThing;
$otherThing->thing = $thing;

$thing2 = $thing;

if ($thing == $thing2)
  print "equal";
else
  print "not equal";

Class Thing
{
  public $otherThing;
}

Class OtherThing
{
  public $thing;
}
?>

Expected result:
----------------
I expect it to print 'equal'

Actual result:
--------------
Fatal error: Nesting level too deep - recursive dependency? in D:\xampp\htdocs\scraping\test.php on line 11

Patches

Pull Requests

History

AllCommentsChangesGit/SVN commitsRelated reports
 [2007-02-07 09:45 UTC] tony2001@php.net
Sorry, but your problem does not imply a bug in PHP itself.  For a
list of more appropriate places to ask for help using PHP, please
visit http://www.php.net/support.php as this bug system is not the
appropriate forum for asking support questions.  Due to the volume
of reports we can not explain in detail here why your report is not
a bug.  The support channels will be able to provide an explanation
for you.

Thank you for your interest in PHP.


 [2007-02-07 12:37 UTC] denis at bytezone dot com
Surely if the address of two objects is the same, then they are the same object. Why on earth does it even attempt to traverse the object's data?

This would be a bug in any other language.
 
PHP Copyright © 2001-2025 The PHP Group
All rights reserved.
Last updated: Sat Jul 05 17:01:34 2025 UTC