#29098 [Opn->Fbk]: "new" operator crashes script

From: Date: Sun, 11 Jul 2004 21:07:34 +0000
Subject: #29098 [Opn->Fbk]: "new" operator crashes script
References: 1  Groups: php.bugs 
Request: Send a blank email to php-bugs+get-62067@lists.php.net to get a copy of this message
ID: 29098 Updated by: curt@php.net Reported By: antonr at game dot permonline dot ru -Status: Open +Status: Feedback Bug Type: Reproducible crash Operating System: WinXP Pro SP1 PHP Version: 5CVS-2004-07-11 (dev) New Comment: How do you mean possibly? My output with script given: PHP Fatal error: Call to a member function setParent() on a non-object in test.php on line 7 ParentClass::__destruct()<br> Previous Comments: ------------------------------------------------------------------------ [2004-07-11 20:35:32] antonr at game dot permonline dot ru Description: ------------ When "new" operator appears without "=" operator, it is possibly crashes php Reproduce code: --------------- <?php class ParentClass { private $child; public function __construct($child) { echo "ParentClass::__construct()<br>\n"; $this->child = $child; $child->setParent($this); } public function __destruct() { echo "ParentClass::__destruct()<br>\n"; unset($this->child); } } class ChildClass { private $parent; public function setParent($parent) { echo "ChildClass::setParent()<br>\n"; $this->parent = $parent; } public function __destruct() { echo "ChildClass::__destruct()<br>\n"; unset($this->parent); } } new ParentClass(new ChildClass()); ?> Expected result: ---------------- ParentClass::__construct() ChildClass::setParent() and possibly ChildClass::__destruct() ParentClass::__destruct() Actual result: -------------- php crashes ------------------------------------------------------------------------ -- Edit this bug report at http://bugs.php.net/?id=29098&edit=1

« previous php.bugs (#62067) next »