com php-src: Fixed bug #67582: NEWS ext/spl/spl_observer.c ext/spl/tests/bug67582.phpt
| From: | Nikita Popov | Date: | Sun, 20 Mar 2016 16:46:12 +0000 |
| Subject: | com php-src: Fixed bug #67582: NEWS ext/spl/spl_observer.c ext/spl/tests/bug67582.phpt | ||
| Groups: | php.cvs | ||
| Request: | Send a blank email to php-cvs+get-91427@lists.php.net to get a copy of this message | ||
Commit: cc3cdd00578006a5684e6dfaf81532a13326b9fe
Author: Nikita Popov <nikic@php.net> Sun, 20 Mar 2016 17:46:12 +0100
Parents: b8c9c92d447292f46bb977594908cea64c61d0d5
Branches: PHP-5.6 PHP-7.0 master
Link: http://git.php.net/?p=php-src.git;a=commitdiff;h=cc3cdd00578006a5684e6dfaf81532a13326b9fe
Log:
Fixed bug #67582
Bugs:
https://bugs.php.net/67582
Changed paths:
M NEWS
M ext/spl/spl_observer.c
A ext/spl/tests/bug67582.phpt
Diff:
diff --git a/NEWS b/NEWS
index c2cca34..cf7edaf 100644
--- a/NEWS
+++ b/NEWS
@@ -16,6 +16,10 @@ PHP NEWS
. Fixed bug #71820 (pg_fetch_object binds parameters before
call constructor). (Anatol)
+- SPL:
+ . Fixed bug #67582 (Cloned SplObjectStorage with overwritten getHash fails
+ offsetExists()). (Nikita)
+
- Standard:
. Fixed bug #71840 (Unserialize accepts wrongly data). (Ryat, Laruence)
diff --git a/ext/spl/spl_observer.c b/ext/spl/spl_observer.c
index 08cf66a..fb0b29f 100644
--- a/ext/spl/spl_observer.c
+++ b/ext/spl/spl_observer.c
@@ -275,11 +275,6 @@ static zend_object_value spl_object_storage_new_ex(zend_class_entry
*class_type,
retval.handle = zend_objects_store_put(intern,
(zend_objects_store_dtor_t)zend_objects_destroy_object, (zend_objects_free_object_storage_t)
spl_SplOjectStorage_free_storage, NULL TSRMLS_CC);
retval.handlers = &spl_handler_SplObjectStorage;
- if (orig) {
- spl_SplObjectStorage *other = (spl_SplObjectStorage*)zend_object_store_get_object(orig
TSRMLS_CC);
- spl_object_storage_addall(intern, orig, other TSRMLS_CC);
- }
-
while (parent) {
if (parent == spl_ce_SplObjectStorage) {
if (class_type != spl_ce_SplObjectStorage) {
@@ -294,6 +289,11 @@ static zend_object_value spl_object_storage_new_ex(zend_class_entry
*class_type,
parent = parent->parent;
}
+ if (orig) {
+ spl_SplObjectStorage *other = (spl_SplObjectStorage*)zend_object_store_get_object(orig
TSRMLS_CC);
+ spl_object_storage_addall(intern, orig, other TSRMLS_CC);
+ }
+
return retval;
}
/* }}} */
diff --git a/ext/spl/tests/bug67582.phpt b/ext/spl/tests/bug67582.phpt
new file mode 100644
index 0000000..b22f615
--- /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)