|  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
Status: Closed Package: SPL related
PHP Version: 5.3.0beta1 OS: Mac OS 10.5.6
Private report: No CVE-ID:
 [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-2015 The PHP Group
All rights reserved.
Last updated: Tue Oct 13 18:01:32 2015 UTC