summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorXinchen Hui <laruence@gmail.com>2015-11-23 07:08:47 -0800
committerXinchen Hui <laruence@gmail.com>2015-11-23 07:08:47 -0800
commitf8bf1f33a53d1aaaa1109cb986544635aaa63f66 (patch)
treee3ebe4012b71da6af9be37efab5011013e9d3f22
parent801e46d8c0a869d60e0af9aa0909d6df2cfc7958 (diff)
downloadphp-git-f8bf1f33a53d1aaaa1109cb986544635aaa63f66.tar.gz
Fixed bug #70959 (ArrayObject unserialize does not restore protected fields)
-rw-r--r--NEWS7
-rw-r--r--Zend/zend_API.c16
-rw-r--r--ext/spl/tests/bug70959.phpt24
3 files changed, 44 insertions, 3 deletions
diff --git a/NEWS b/NEWS
index 8a0441d78c..dc29b7d41b 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 5a488f7e9d..0e6d89fc8a 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 0000000000..3fd500736d
--- /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"