php.net |  support |  documentation |  report a bug |  advanced search |  search howto |  statistics |  random bug |  login
Bug #31449 Comparison of class with recursive references causes fatal
Submitted: 2005-01-08 05:31 UTC Modified: 2005-05-18 10:41 UTC
Votes:13
Avg. Score:4.7 ± 0.6
Reproduced:10 of 10 (100.0%)
Same Version:5 (50.0%)
Same OS:5 (50.0%)
From: marcus at lastcraft dot com Assigned: andi (profile)
Status: Not a bug Package: Class/Object related
PHP Version: 5CVS-2005-03-06 OS: *
Private report: No CVE-ID: None
View Add Comment Developer Edit
Welcome! If you don't have a Git account, you can't do anything here.
You can add a comment by following this link or if you reported this bug, you can edit this bug over here.
(description)
Block user comment
Status: Assign to:
Package:
Bug Type:
Summary:
From: marcus at lastcraft dot com
New email:
PHP Version: OS:

 

 [2005-01-08 05:31 UTC] marcus at lastcraft dot com
Description:
------------
Hi...

The script below causes a fatal error. This is just the simplest example I could find of a whole class of these problems. Makes comparing any object problematical.

yours, Marcus

Reproduce code:
---------------
<?php
    class Recursive {
        private $me;

        function __construct() {
            $this->me = $this;
        }
    }

    new Recursive() != new Recursive();
?>

Expected result:
----------------
Nothing as the comparison is not output.

Actual result:
--------------
Fatal error with nesting too deep.

Patches

Add a Patch

Pull Requests

Add a Pull Request

History

AllCommentsChangesGit/SVN commitsRelated reports
 [2005-05-18 10:41 UTC] stas@php.net
Thank you for taking the time to write to us, but this is not
a bug. Please double-check the documentation available at
http://www.php.net/manual/ and the instructions on how to report
a bug at http://bugs.php.net/how-to-report.php

I don't think it's a bug. You can not compare these objects since they contain circular references, so comparison process  descends to the endless loop. You may want to use custom method to compare objects - bit-comparison of objects is generally not the best idea.
 
PHP Copyright © 2001-2024 The PHP Group
All rights reserved.
Last updated: Fri Apr 19 10:01:28 2024 UTC