php.net |  support |  documentation |  report a bug |  advanced search |  search howto |  statistics |  random bug |  login
Bug #2075 Self referential objects can't have more than two references to themselves
Submitted: 1999-08-16 16:14 UTC Modified: 2000-05-30 18:58 UTC
From: dom at recoil dot org Assigned:
Status: Closed Package: Scripting Engine problem
PHP Version: 4.0 Beta 2 OS: linux redhat 5.2
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: dom at recoil dot org
New email:
PHP Version: OS:

 

 [1999-08-16 16:14 UTC] dom at recoil dot org
Whenever I try to build a self referential structure, 
information is lost after two nodes in the chain.

The following code shows that the structures can never
be more than two nodes deep.

<?
class Test
{
        var $next;

        function add($next)
        {
                $this->next = $next;
                return $next;
        }

        function dump()
        {
                echo "Test!<br>";
                $this->next->dump();
        }
}

$test = new Test;
$next = $test->add(new Test);
$next = $test->add(new Test);
$next = $test->add(new Test);

$test->dump();
?>

This code causes the following error with both
php3 and php4b2:

Test!
Test!

Fatal error: Call to a member function on a non-object in /home/dom/public_html
/treetest/test.php3 on line 19

Configure line was:
 ./configure --with-mysql --with-apache=../apache_1.3.6 --enable-track-vars --with-xml


Patches

Add a Patch

Pull Requests

Add a Pull Request

History

AllCommentsChangesGit/SVN commitsRelated reports
 [1999-08-17 08:24 UTC] dom at recoil dot org
Whenever I try to build a self referential structure, 
information is lost after two nodes in the chain.

The following code shows that the structures can never
be more than two nodes deep.

<?
class Test
{
        var $next;

        function add($next)
        {
                $this->next = $next;
                return $next;
        }

        function dump()
        {
                echo "Test!<br>";
                $this->next->dump();
        }
}

$test = new Test;
$next = $test->add(new Test);
$next = $next->add(new Test);
$next = $next->add(new Test);

$test->dump();
?>

This code causes the following error with both
php3 and php4b2:

Test!
Test!

Fatal error: Call to a member function on a non-object in /home/dom/public_html
/treetest/test.php3 on line 19

Configure line was:
 ./configure --with-mysql --with-apache=../apache_1.3.6 --enable-track-vars --with-xml

 [1999-12-15 15:00 UTC] sas at cvs dot php dot net
Reclassifying
 [2000-05-30 18:58 UTC] stas at cvs dot php dot net
Not a bug. On the second pass over dump $this->next is null and thus 
$this->next call fails.
 
PHP Copyright © 2001-2024 The PHP Group
All rights reserved.
Last updated: Wed Apr 24 20:01:32 2024 UTC