com php-src: Fixed bug #70959 (ArrayObject unserialize does not restore protected fields): NEWS Zend/zend_API.c ext/spl/tests/bug 70959.phpt
| From: | Xinchen Hui | Date: | Mon, 23 Nov 2015 15:15:33 +0000 |
| Subject: | com php-src: Fixed bug #70959 (ArrayObject unserialize does not restore protected fields): NEWS Zend/zend_API.c ext/spl/tests/bug 70959.phpt | ||
| Groups: | php.cvs | ||
| Request: | Send a blank email to php-cvs+get-89974@lists.php.net to get a copy of this message | ||
Commit: 7e9f416218165f7329358e0432c6373d664c5ed7
Author: Xinchen Hui <laruence@gmail.com> Mon, 23 Nov 2015 23:15:33 +0800
Parents: 801e46d8c0a869d60e0af9aa0909d6df2cfc7958
Branches: PHP-7.0 master
Link: http://git.php.net/?p=php-src.git;a=commitdiff;h=7e9f416218165f7329358e0432c6373d664c5ed7
Log:
Fixed bug #70959 (ArrayObject unserialize does not restore protected fields)
Bugs:
https://bugs.php.net/70959
Changed paths:
M NEWS
M Zend/zend_API.c
A ext/spl/tests/bug70959.phpt
Diff:
diff --git a/NEWS b/NEWS
index 8a0441d..dc29b7d 100644
--- a/NEWS
+++ b/NEWS
@@ -21,13 +21,18 @@ PHP NEWS
(Laruence)
- OCI8:
- . Fixed LOB implementation size_t/zend_long mismatch reported by gcov. (Senthil)
+ . Fixed LOB implementation size_t/zend_long mismatch reported
+ by gcov. (Senthil)
. Fixed memory leak with LOBs. (Senthil)
- SOAP:
. Fixed bug #70900 (SoapClient systematic out of memory error). (Dmitry)
. Fixed bug #70940 (Segfault in soap / type_to_string). (Remi)
+- SPL:
+ . Fixed bug #70959 (ArrayObject unserialize does not restore protected
+ fields). (Laruence)
+
- Standard:
. Fixed bug (count on symbol tables). (Laruence)
. Fixed bug #70910 (extract() breaks variable references). (Laruence)
diff --git a/Zend/zend_API.c b/Zend/zend_API.c
index 5a488f7..0e6d89f 100644
--- a/Zend/zend_API.c
+++ b/Zend/zend_API.c
@@ -1219,8 +1219,20 @@ ZEND_API void object_properties_load(zend_object *object, HashTable
*properties)
zend_property_info *property_info;
ZEND_HASH_FOREACH_KEY_VAL(properties, h, key, prop) {
- if(key) {
- property_info = zend_get_property_info(object->ce, key, 1);
+ if (key) {
+ if (ZSTR_VAL(key)[0] == '\0') {
+ const char *class_name, *prop_name;
+ size_t prop_name_len;
+ if (zend_unmangle_property_name_ex(key, &class_name, &prop_name, &prop_name_len) ==
SUCCESS) {
+ zend_string *pname = zend_string_init(prop_name, prop_name_len, 0);
+ property_info = zend_get_property_info(object->ce, pname, 1);
+ zend_string_release(pname);
+ } else {
+ property_info = ZEND_WRONG_PROPERTY_INFO;
+ }
+ } else {
+ property_info = zend_get_property_info(object->ce, key, 1);
+ }
if (property_info != ZEND_WRONG_PROPERTY_INFO &&
property_info &&
(property_info->flags & ZEND_ACC_STATIC) == 0) {
diff --git a/ext/spl/tests/bug70959.phpt b/ext/spl/tests/bug70959.phpt
new file mode 100644
index 0000000..3fd5007
--- /dev/null
+++ b/ext/spl/tests/bug70959.phpt
@@ -0,0 +1,24 @@
+--TEST--
+Bug #70959 (ArrayObject unserialize does not restore protected fields)
+--FILE--
+<?php
+class testObject extends ArrayObject {
+ protected $test;
+
+ public function getTest() {
+ return $this->test;
+ }
+
+ public function setTest($test) {
+ $this->test = $test;
+ }
+}
+
+$obj = new testObject();
+$obj->setTest('test');
+var_dump($obj->getTest());
+$obj2 = unserialize(serialize($obj));
+var_dump($obj2->getTest());
+--EXPECTF--
+string(4) "test"
+string(4) "test"