File tree Expand file tree Collapse file tree 3 files changed +36
-0
lines changed Expand file tree Collapse file tree 3 files changed +36
-0
lines changed Original file line number Diff line number Diff line change 2
2
|||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
3
3
?? ??? ????, PHP 8.2.0alpha2
4
4
5
+ - Core:
6
+ . Fixed bug GH-8655 (Casting an object to array does not unwrap refcount=1
7
+ references). (Nicolas Grekas)
5
8
6
9
09 Jun 2022, PHP 8.2.0alpha1
7
10
Original file line number Diff line number Diff line change
1
+ --TEST--
2
+ Bug GH-8655 (zval reference is not released when targetting a declared property)
3
+ --FILE--
4
+ <?php
5
+ class Foo
6
+ {
7
+ public $ foo ;
8
+ }
9
+
10
+ function hydrate ($ properties , $ object )
11
+ {
12
+ foreach ($ properties as $ name => &$ value ) {
13
+ $ object ->$ name = &$ value ;
14
+ }
15
+ };
16
+
17
+ $ object = new Foo ;
18
+
19
+ hydrate (['foo ' => 123 ], $ object );
20
+
21
+ $ arrayCast = (array ) $ object ;
22
+
23
+ $ object ->foo = 234 ;
24
+ var_dump (ReflectionReference::fromArrayElement ($ arrayCast , 'foo ' ));
25
+ echo $ arrayCast ['foo ' ];
26
+ ?>
27
+ --EXPECT--
28
+ NULL
29
+ 123
Original file line number Diff line number Diff line change @@ -111,6 +111,10 @@ ZEND_API HashTable *zend_std_build_object_properties_array(zend_object *zobj) /*
111
111
continue ;
112
112
}
113
113
114
+ if (Z_ISREF_P (prop ) && Z_REFCOUNT_P (prop ) == 1 ) {
115
+ prop = Z_REFVAL_P (prop );
116
+ }
117
+
114
118
Z_TRY_ADDREF_P (prop );
115
119
_zend_hash_append (ht , prop_info -> name , prop );
116
120
}
You can’t perform that action at this time.
0 commit comments