ID: 26765 Updated by: [EMAIL PROTECTED] -Summary: Unserialize serialized object does not return object Reported By: alex_mailbox53 at yahoo dot com -Status: Open +Status: Critical Bug Type: Zend Engine 2 problem -Operating System: Gentoo Linux +Operating System: * -PHP Version: 5.0.0b3 (beta3) +PHP Version: 5CVS New Comment:
I played around and tested what happens with PHP 4..this has nothing to do with serialization, following works fine in PHP 4, in PHP 5 it causes several memleaks and the resulting object is not quite correct: <?php class SFTemplate { var $content; var $parent; function SFTemplate() { $this->content = new SFTemplateContent($this); } } class SFTemplateContent { var $template; var $items = array(); function SFTemplateContent($tpl) { $this->template = $tpl; } function add($item) { $this->items[] = $item; $item->parent = $this->template; } } $t = new SFTemplate(); $t->content->add(new SFTemplate()); var_dump($t); ?> Previous Comments: ------------------------------------------------------------------------ [2004-01-02 07:15:15] alex_mailbox53 at yahoo dot com Description: ------------ The following code displays only one serialized object, but should display two: class SFTemplate { public $content; public $parent; function __construct() { $this->content = new SFTemplateContent($this); } } class SFTemplateContent { protected $template; protected $items = array(); function __construct($tpl) { $this->template = $tpl; } function add($item) { $this->items[] = $item; $item->parent = $this->template; } } $t = new SFTemplate(); $t->content->add(new SFTemplate()); print_r(unserialize(serialize($t))); print '<hr>'; $t->content->add(new SFTemplate()); print_r(unserialize(serialize($t))); Adding more objects to SFTemplateContent object prevents object from deserialization. With 1 object in items array it works ok. Expected result: ---------------- two dumps of deserialized objects Actual result: -------------- one dump ------------------------------------------------------------------------ -- Edit this bug report at http://bugs.php.net/?id=26765&edit=1