|  support |  documentation |  report a bug |  advanced search |  search howto |  statistics |  random bug |  login
Bug #47671 Cloning of SplObjectStorage is undefined
Submitted: 2009-03-16 11:42 UTC Modified: 2009-03-19 02:45 UTC
Avg. Score:4.5 ± 0.5
Reproduced:2 of 2 (100.0%)
Same Version:2 (100.0%)
Same OS:1 (50.0%)
From: robert at typo3 dot org Assigned: colder (profile)
Status: Closed Package: SPL related
PHP Version: 5.3.0beta1 OS: Mac OS 10.5.6
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.
Block user comment
Status: Assign to:
Bug Type:
From: robert at typo3 dot org
New email:
PHP Version: OS:


 [2009-03-16 11:42 UTC] robert at typo3 dot org
After cloning an instance of SplObjectStorage the number of objects 
which can be retrieved with count() is very high and foreach() causes a 

Reproduce code:
class Foo {}

$storageA = new \SplObjectStorage();
$storageA->attach(new \Foo);
$storageA->attach(new \Foo);

echo ("Count storage A: " . count($storageA));
foreach ($storageA as $object) {
	echo ' x ';

$storageB = clone $storageA;
echo ("Count storage B: " . count($storageB));
foreach ($storageB as $object) {
	echo ' x ';

Expected result:
Count storage A: 2 x x Count storage B: 2 x x

Actual result:
Count storage A: 2 x x Count storage B: 1953394499


Add a Patch

Pull Requests

Add a Pull Request


AllCommentsChangesGit/SVN commitsRelated reports
 [2009-03-19 02:45 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-2024 The PHP Group
All rights reserved.
Last updated: Tue Apr 16 11:01:29 2024 UTC