summaryrefslogtreecommitdiff
path: root/ext/spl
diff options
context:
space:
mode:
authorNikita Popov <nikic@php.net>2016-03-20 17:48:22 +0100
committerNikita Popov <nikic@php.net>2016-03-20 17:48:22 +0100
commitc4ccb5d5fad1eb4eaefa7f1734269d4ff989136a (patch)
treeb6f90e12581d9dea7b4cbfb8f52f9b28381fe9b5 /ext/spl
parent6d98584d0011769fef46db99158160e1dc11831b (diff)
parent12f2665df829eac53e2036e335b40cf391ff8652 (diff)
downloadphp-git-c4ccb5d5fad1eb4eaefa7f1734269d4ff989136a.tar.gz
Merge branch 'PHP-7.0'
Diffstat (limited to 'ext/spl')
-rw-r--r--ext/spl/spl_observer.c10
-rw-r--r--ext/spl/tests/bug67582.phpt24
2 files changed, 29 insertions, 5 deletions
diff --git a/ext/spl/spl_observer.c b/ext/spl/spl_observer.c
index 40de5934d0..223e252e63 100644
--- a/ext/spl/spl_observer.c
+++ b/ext/spl/spl_observer.c
@@ -243,11 +243,6 @@ static zend_object *spl_object_storage_new_ex(zend_class_entry *class_type, zval
intern->std.handlers = &spl_handler_SplObjectStorage;
- if (orig) {
- spl_SplObjectStorage *other = Z_SPLOBJSTORAGE_P(orig);
- spl_object_storage_addall(intern, orig, other);
- }
-
while (parent) {
if (parent == spl_ce_SplObjectStorage) {
if (class_type != spl_ce_SplObjectStorage) {
@@ -262,6 +257,11 @@ static zend_object *spl_object_storage_new_ex(zend_class_entry *class_type, zval
parent = parent->parent;
}
+ if (orig) {
+ spl_SplObjectStorage *other = Z_SPLOBJSTORAGE_P(orig);
+ spl_object_storage_addall(intern, orig, other);
+ }
+
return &intern->std;
}
/* }}} */
diff --git a/ext/spl/tests/bug67582.phpt b/ext/spl/tests/bug67582.phpt
new file mode 100644
index 0000000000..b22f615034
--- /dev/null
+++ b/ext/spl/tests/bug67582.phpt
@@ -0,0 +1,24 @@
+--TEST--
+Bug #67582: Cloned SplObjectStorage with overwritten getHash fails offsetExists()
+--FILE--
+<?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();
+$list->attach(new TestObject());
+
+foreach($list as $x) var_dump($list->offsetExists($x));
+
+$list2 = clone $list;
+foreach($list2 as $x) var_dump($list2->offsetExists($x));
+
+?>
+--EXPECT--
+bool(true)
+bool(true)