#39836 [Opn]: SplObjectStorage empty after unserialize
| From: | helly@php.net | Date: | Sat, 16 Dec 2006 12:31:38 +0000 |
| Subject: | #39836 [Opn]: SplObjectStorage empty after unserialize | ||
| References: | 1 | Groups: | php.bugs |
| Request: | Send a blank email to php-bugs+get-106420@lists.php.net to get a copy of this message | ||
ID: 39836
Updated by: helly@php.net
Reported By: doublecompile at gmail dot com
Status: Open
Bug Type: SPL related
Operating System: *
PHP Version: 5.2.0
Assigned To: helly
New Comment:
Actually this is a feature request. Overloaded objects are typically
not serializable even though PHP in theory has everything to allow
that.
Previous Comments:
------------------------------------------------------------------------
[2006-12-14 22:12:46] doublecompile at gmail dot com
Description:
------------
I serialized a SplObjectStorage instance containing several objects.
After unserialization, the SplObjectStorage object contained nothing.
It doesn't say in the SPL documentation that SplObjectStorage cannot be
serialized.
Reproduce code:
---------------
<?php
class test { }
$storage = new SplObjectStorage();
for( $i=0; $i<5; $i++ ) {
$test = new test();
$test->example = 'testing'.$i;
$storage->attach( $test );
}
echo "Before: ".count($storage)."<br>";
$str = serialize($storage);
$storage2 = unserialize( $str );
echo "After: ".count($storage2)."<br>";
?>
Expected result:
----------------
Before: 5
After: 5
Actual result:
--------------
Before: 5
After: 0
------------------------------------------------------------------------
--
Edit this bug report at http://bugs.php.net/?id=39836&edit=1