com php-src: Fixed bug #71617: NEWS Zend/zend_API.c ext/s pl/tests/bug71617.phpt
| From: | Nikita Popov | Date: | Sun, 21 Feb 2016 12:00:37 +0000 |
| Subject: | com php-src: Fixed bug #71617: NEWS Zend/zend_API.c ext/s pl/tests/bug71617.phpt | ||
| Groups: | php.cvs | ||
| Request: | Send a blank email to php-cvs+get-91119@lists.php.net to get a copy of this message | ||
Commit: 0bd64b50b88d243cf337e0c5dbea20e4ba809117
Author: Nikita Popov <nikic@php.net> Sun, 21 Feb 2016 12:59:57 +0100
Parents: 2ecc0c10850f087727932348e786ec09e4825109
Branches: PHP-7.0 master
Link: http://git.php.net/?p=php-src.git;a=commitdiff;h=0bd64b50b88d243cf337e0c5dbea20e4ba809117
Log:
Fixed bug #71617
Bugs:
https://bugs.php.net/71617
Changed paths:
M NEWS
M Zend/zend_API..c
A ext/spl/tests/bug71617.phpt
Diff:
diff --git a/NEWS b/NEWS
index 8ae5659..0cd6c4b 100644
--- a/NEWS
+++ b/NEWS
@@ -15,6 +15,10 @@ PHP NEWS
- phpdbg:
. Fixed crash when advancing (except step) inside an internal function. (Bob)
+- SPL:
+ . Fixed bug #71617 (private properties lost when unserializing ArrayObject).
+ (Nikita)
+
?? Mar 2016 PHP 7.0.4
- Core:
diff --git a/Zend/zend_API.c b/Zend/zend_API.c
index 2238bcb..a7d19f9 100644
--- a/Zend/zend_API.c
+++ b/Zend/zend_API.c
@@ -1226,8 +1226,15 @@ ZEND_API void object_properties_load(zend_object *object, HashTable
*properties)
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);
+ zend_class_entry *prev_scope = EG(scope);
+ if (class_name && class_name[0] != '*') {
+ zend_string *cname = zend_string_init(class_name, strlen(class_name), 0);
+ EG(scope) = zend_lookup_class(cname);
+ zend_string_release(cname);
+ }
property_info = zend_get_property_info(object->ce, pname, 1);
zend_string_release(pname);
+ EG(scope) = prev_scope;
} else {
property_info = ZEND_WRONG_PROPERTY_INFO;
}
diff --git a/ext/spl/tests/bug71617.phpt b/ext/spl/tests/bug71617.phpt
new file mode 100644
index 0000000..412f83f
--- /dev/null
+++ b/ext/spl/tests/bug71617.phpt
@@ -0,0 +1,50 @@
+--TEST--
+Bug #71617: private properties lost when unserializing ArrayObject
+--FILE--
+<?php
+
+class Test extends ArrayObject
+{
+
+ private $name = null;
+
+ public function __construct(array $input)
+ {
+ parent::__construct($input, ArrayObject::ARRAY_AS_PROPS);
+ }
+
+ public function setName($name)
+ {
+ $this->name = $name;
+ return $this;
+ }
+
+ public function getName()
+ {
+ return $this->name;
+ }
+}
+
+$test = new Test(['a' => 'a', 'b' => 'b']);
+$test->setName('ok');
+
+$ser = serialize($test);
+$unSer = unserialize($ser);
+
+var_dump($unSer->getName());
+var_dump($unSer);
+
+?>
+--EXPECT--
+string(2) "ok"
+object(Test)#2 (2) {
+ ["name":"Test":private]=>
+ string(2) "ok"
+ ["storage":"ArrayObject":private]=>
+ array(2) {
+ ["a"]=>
+ string(1) "a"
+ ["b"]=>
+ string(1) "b"
+ }
+}