summaryrefslogtreecommitdiff
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
parenta175aa9dcaed5e295d015ff73c663e06c2335155 (diff)
parentcc3cdd00578006a5684e6dfaf81532a13326b9fe (diff)
downloadphp-git-12f2665df829eac53e2036e335b40cf391ff8652.tar.gz
Merge branch 'PHP-5.6' into PHP-7.0
Conflicts: ext/spl/spl_observer.c
-rw-r--r--NEWS2
-rw-r--r--ext/spl/spl_observer.c10
-rw-r--r--ext/spl/tests/bug67582.phpt24
3 files changed, 31 insertions, 5 deletions
diff --git a/NEWS b/NEWS
index 0cccc6abe7..f7d1c7d93d 100644
--- a/NEWS
+++ b/NEWS
@@ -27,6 +27,8 @@ PHP NEWS
. Fixed bug #71838 (Deserializing serialized SPLObjectStorage-Object can't
access properties in PHP). (Nikita)
. Fixed bug #52339 (SPL autoloader breaks class_exists()). (Nikita)
+ . Fixed bug #67582 (Cloned SplObjectStorage with overwritten getHash fails
+ offsetExists()). (Nikita)
- Standard:
. Fixed bug #71837 (Wrong arrays behaviour). (Laruence)
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)