|  support |  documentation |  report a bug |  advanced search |  search howto |  statistics |  random bug |  login
Request #39836 SplObjectStorage empty after unserialize
Submitted: 2006-12-14 22:12 UTC Modified: 2007-02-08 22:14 UTC
Avg. Score:4.7 ± 0.5
Reproduced:3 of 3 (100.0%)
Same Version:3 (100.0%)
Same OS:2 (66.7%)
From: doublecompile at gmail dot com Assigned: helly (profile)
Status: Closed Package: Feature/Change Request
PHP Version: 5.2.1 OS: *
Private report: No CVE-ID: None
 [2006-12-14 22:12 UTC] doublecompile at gmail dot com
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:

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


Add a Patch

Pull Requests

Add a Pull Request


AllCommentsChangesGit/SVN commitsRelated reports
 [2006-12-16 12:31 UTC]
Actually this is a feature request. Overloaded objects are typically not serializable even though PHP in theory has everything to allow that.
 [2006-12-16 13:56 UTC]
Works in HEAD now, except for unicode mode. Support in 5.2 might be added as well. The patch at least works.
 [2007-02-08 22:14 UTC]
This bug has been fixed in CVS.

Snapshots of the sources are packaged every three hours; this change
will be in the next snapshot. You can grab the snapshot at
Thank you for the report, and for helping us make PHP better.

PHP Copyright © 2001-2019 The PHP Group
All rights reserved.
Last updated: Sun Aug 18 23:01:26 2019 UTC