Skip to content

Commit 60a2809

Browse files
committed
Merge branch 'PHP-5.3' into PHP-5.4
2 parents 8e9805b + 4f860a4 commit 60a2809

File tree

2 files changed

+29
-3
lines changed

2 files changed

+29
-3
lines changed
Lines changed: 24 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,24 @@
1+
--TEST--
2+
Bug #35895 (__sleep and private property)
3+
--FILE--
4+
<?php
5+
class Parents {
6+
private $parents;
7+
public function __sleep() {
8+
return array("parents");
9+
}
10+
}
11+
12+
class Child extends Parents {
13+
private $child;
14+
public function __sleep() {
15+
return array_merge(array("child"), parent::__sleep());
16+
}
17+
}
18+
19+
$obj = new Child();
20+
serialize($obj);
21+
22+
?>
23+
--EXPECTF--
24+
Notice: serialize(): "parents" returned as member variable from __sleep() but does not exist in %sbug35895.php on line %d

ext/standard/var.c

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -639,6 +639,7 @@ static void php_var_serialize_class(smart_str *buf, zval *struc, zval *retval_pt
639639
HashPosition pos;
640640
int i;
641641
zval nval, *nvalp;
642+
HashTable *propers;
642643

643644
ZVAL_NULL(&nval);
644645
nvalp = &nval;
@@ -664,7 +665,8 @@ static void php_var_serialize_class(smart_str *buf, zval *struc, zval *retval_pt
664665
smart_str_appendl(buf,"N;", 2);
665666
continue;
666667
}
667-
if (zend_hash_find(Z_OBJPROP_P(struc), Z_STRVAL_PP(name), Z_STRLEN_PP(name) + 1, (void *) &d) == SUCCESS) {
668+
propers = Z_OBJPROP_P(struc);
669+
if (zend_hash_find(propers, Z_STRVAL_PP(name), Z_STRLEN_PP(name) + 1, (void *) &d) == SUCCESS) {
668670
php_var_serialize_string(buf, Z_STRVAL_PP(name), Z_STRLEN_PP(name));
669671
php_var_serialize_intern(buf, *d, var_hash TSRMLS_CC);
670672
} else {
@@ -676,15 +678,15 @@ static void php_var_serialize_class(smart_str *buf, zval *struc, zval *retval_pt
676678

677679
do {
678680
zend_mangle_property_name(&priv_name, &prop_name_length, ce->name, ce->name_length, Z_STRVAL_PP(name), Z_STRLEN_PP(name), ce->type & ZEND_INTERNAL_CLASS);
679-
if (zend_hash_find(Z_OBJPROP_P(struc), priv_name, prop_name_length + 1, (void *) &d) == SUCCESS) {
681+
if (zend_hash_find(propers, priv_name, prop_name_length + 1, (void *) &d) == SUCCESS) {
680682
php_var_serialize_string(buf, priv_name, prop_name_length);
681683
pefree(priv_name, ce->type & ZEND_INTERNAL_CLASS);
682684
php_var_serialize_intern(buf, *d, var_hash TSRMLS_CC);
683685
break;
684686
}
685687
pefree(priv_name, ce->type & ZEND_INTERNAL_CLASS);
686688
zend_mangle_property_name(&prot_name, &prop_name_length, "*", 1, Z_STRVAL_PP(name), Z_STRLEN_PP(name), ce->type & ZEND_INTERNAL_CLASS);
687-
if (zend_hash_find(Z_OBJPROP_P(struc), prot_name, prop_name_length + 1, (void *) &d) == SUCCESS) {
689+
if (zend_hash_find(propers, prot_name, prop_name_length + 1, (void *) &d) == SUCCESS) {
688690
php_var_serialize_string(buf, prot_name, prop_name_length);
689691
pefree(prot_name, ce->type & ZEND_INTERNAL_CLASS);
690692
php_var_serialize_intern(buf, *d, var_hash TSRMLS_CC);

0 commit comments

Comments
 (0)