From:             jesse at mactechs dot com
Operating system: Irrelevant
PHP version:      4.3.4
PHP Bug Type:     Class/Object related
Bug description:  comparing (recursive) referenced objects fails

Description:
------------
Recursive object reference comparisons fail in PHP4.x.



Alternative to my "exptected result" below, I would 

settle for one of a couple of things.  One would be a 

boolean comparison function that returns true if two 

references point to the same data, or another could be 

simply a boolean function that returns true if two 

objects are the same (with recursing to all the values).



I'm aware the Zend Engine 2/PHP5 identity operator works 

in the fashion I'd like now, but I'd still consider this 

a bug for Zend Engine/PHP4.

Reproduce code:
---------------
// key failing element here is B::is_ref



class A {

  var $a_ref;

  function set_ref (&$obj) {

    $this->a_ref =& $obj; } }

class B {

  var $b_ref;

  function set_ref (&$obj) {

    $this->b_ref =& $obj; }

  function is_ref (&$obj) {

    if ($obj === $this->b_ref)

      return true; } }



$a = new A; $b = new B;

$a->set_ref ($b); $b->set_ref ($a);



var_dump ($b->is_ref ($a));

Expected result:
----------------
I would expect that "if ($obj === $this->b_ref)" would 

return true if they (the two object references being 

compared) referenced the same object, and 

false if they didnt.  Please see my description, as 

well.

Actual result:
--------------
"

Fatal error: Nesting level too deep - recursive 

dependency? in /path-to/test.php on line 12

"

-- 
Edit bug report at http://bugs.php.net/?id=27707&edit=1
-- 
Try a CVS snapshot (php4):  http://bugs.php.net/fix.php?id=27707&r=trysnapshot4
Try a CVS snapshot (php5):  http://bugs.php.net/fix.php?id=27707&r=trysnapshot5
Fixed in CVS:               http://bugs.php.net/fix.php?id=27707&r=fixedcvs
Fixed in release:           http://bugs.php.net/fix.php?id=27707&r=alreadyfixed
Need backtrace:             http://bugs.php.net/fix.php?id=27707&r=needtrace
Need Reproduce Script:      http://bugs.php.net/fix.php?id=27707&r=needscript
Try newer version:          http://bugs.php.net/fix.php?id=27707&r=oldversion
Not developer issue:        http://bugs.php.net/fix.php?id=27707&r=support
Expected behavior:          http://bugs.php.net/fix.php?id=27707&r=notwrong
Not enough info:            http://bugs.php.net/fix.php?id=27707&r=notenoughinfo
Submitted twice:            http://bugs.php.net/fix.php?id=27707&r=submittedtwice
register_globals:           http://bugs.php.net/fix.php?id=27707&r=globals
PHP 3 support discontinued: http://bugs.php.net/fix.php?id=27707&r=php3
Daylight Savings:           http://bugs.php.net/fix.php?id=27707&r=dst
IIS Stability:              http://bugs.php.net/fix.php?id=27707&r=isapi
Install GNU Sed:            http://bugs.php.net/fix.php?id=27707&r=gnused
Floating point limitations: http://bugs.php.net/fix.php?id=27707&r=float

Reply via email to