Skip to content

Commit bc59b04

Browse files
committed
Fix bug #81163 indirect vars in __sleep
1 parent 99e7c5c commit bc59b04

File tree

3 files changed

+25
-1
lines changed

3 files changed

+25
-1
lines changed

NEWS

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,8 @@ PHP NEWS
55
- Core:
66
. Fixed bug #81145 (copy() and stream_copy_to_stream() fail for +4GB files).
77
(cmb, Nikita)
8+
. Fixed bug #81163 (incorrect handling of indirect vars in __sleep).
9+
(krakjoe)
810

911
- Intl:
1012
. Fixed bug #72809 (Locale::lookup() wrong result with canonicalize option).
Lines changed: 22 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,22 @@
1+
--TEST--
2+
Test __sleep returns non-array
3+
--FILE--
4+
<?php
5+
class foo
6+
{
7+
private $private = 'private';
8+
}
9+
10+
class bar extends foo
11+
{
12+
public function __sleep()
13+
{
14+
return (new bar());
15+
}
16+
}
17+
18+
serialize(new bar());
19+
?>
20+
--EXPECTF--
21+
Notice: serialize(): "private" returned as member variable from __sleep() but does not exist in %s on line %d
22+

ext/standard/var.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -825,7 +825,7 @@ static int php_var_serialize_get_sleep_props(
825825
zend_hash_init(ht, zend_hash_num_elements(sleep_retval), NULL, ZVAL_PTR_DTOR, 0);
826826
/* TODO: Rewrite this by fetching the property info instead of trying out different
827827
* name manglings? */
828-
ZEND_HASH_FOREACH_VAL(sleep_retval, name_val) {
828+
ZEND_HASH_FOREACH_VAL_IND(sleep_retval, name_val) {
829829
zend_string *name, *tmp_name, *priv_name, *prot_name;
830830

831831
ZVAL_DEREF(name_val);

0 commit comments

Comments
 (0)