note 116605 added to class.splobjectstorage
| From: | m dot drewek at smf dot de | Date: | Wed, 28 Jan 2015 08:49:24 +0000 |
| Subject: | note 116605 added to class.splobjectstorage | ||
| Groups: | php.notes | ||
| Request: | Send a blank email to php-notes+get-201543@lists.php.net to get a copy of this message | ||
Please note that SplObjectStorage has a Bug introduced with 5.4.0, breaking object lookup in cloned
instances of derived classes that overwrite getHash().
This is a confirmed Bug: https://bugs.php.net/bug.php?id=67582
Example:
<?php
class MyObjectStorage extends SplObjectStorage {
// Overwrite getHash() with just some (working) test-method
public function getHash($object) { return get_class($object); }
}
class TestObject {}
$list = new MyObjectStorage(); // No issues if using "new SplObjectStorage()"
$list->attach(new TestObject());
foreach($list as $x) var_dump($list->offsetExists($x)); // TRUE
$list2 = clone $list;
foreach($list2 as $x) var_dump($list2->offsetExists($x)); // FALSE
?>
----
Server IP: 72.52.91.14
Probable Submitter: 80.254.148.67 (proxied: 195.124.18.5)
----
Manual Page -- http://php.net/manual/en/class.splobjectstorage.php
Edit -- https://master.php.net/note/edit/116605
Del: integrated -- https://master.php.net/note/delete/116605/integrated
Del: useless -- https://master.php.net/note/delete/116605/useless
Del: bad code -- https://master.php.net/note/delete/116605/bad+code
Del: spam -- https://master.php.net/note/delete/116605/spam
Del: non-english -- https://master.php.net/note/delete/116605/non-english
Del: in docs -- https://master.php.net/note/delete/116605/in+docs
Del: other reasons-- https://master.php.net/note/delete/116605
Reject -- https://master.php.net/note/reject/116605
Search -- https://master.php.net/manage/user-notes.php