summaryrefslogtreecommitdiff
path: root/ext/spl
diff options
context:
space:
mode:
authorNikita Popov <nikic@php.net>2016-03-20 17:48:06 +0100
committerNikita Popov <nikic@php.net>2016-03-20 17:48:06 +0100
commit12f2665df829eac53e2036e335b40cf391ff8652 (patch)
tree7e5aaf6a5a19415a7a416ff6aa36b02f80a5d66c /ext/spl
parenta175aa9dcaed5e295d015ff73c663e06c2335155 (diff)
parentcc3cdd00578006a5684e6dfaf81532a13326b9fe (diff)
downloadphp-git-12f2665df829eac53e2036e335b40cf391ff8652.tar.gz
Merge branch 'PHP-5.6' into PHP-7.0
Conflicts: ext/spl/spl_observer.c
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 76b98a51d0..c189205879 100644
--- a/ext/spl/spl_observer.c
+++ b/ext/spl/spl_observer.c
@@ -230,11 +230,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) {
@@ -249,6 +244,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)