php.net |  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
Votes:3
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
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: doublecompile at gmail dot com
New email:
PHP Version: OS:

 

 [2006-12-14 22:12 UTC] 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

Patches

Add a Patch

Pull Requests

Add a Pull Request

History

AllCommentsChangesGit/SVN commitsRelated reports
 [2006-12-16 12:31 UTC] helly@php.net
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] helly@php.net
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] helly@php.net
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
http://snaps.php.net/.
 
Thank you for the report, and for helping us make PHP better.


 
PHP Copyright © 2001-2024 The PHP Group
All rights reserved.
Last updated: Fri Apr 26 10:01:31 2024 UTC