Skip to content

Commit 58e6a0a

Browse files
committed
Merge branch 'PHP-7.3' into PHP-7.4
* PHP-7.3: Fixed bug #79477
2 parents 8c5faf7 + 79a36ff commit 58e6a0a

File tree

3 files changed

+22
-1
lines changed

3 files changed

+22
-1
lines changed

NEWS

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,7 @@ PHP NEWS
55

66
- Core:
77
. Fixed bug #78434 (Generator yields no items after valid() call). (Nikita)
8+
. Fixed bug #79477 (casting object into array creates references). (Nikita)
89

910
- DOM:
1011
. Fixed bug #78221 (DOMNode::normalize() doesn't remove empty text nodes).

Zend/tests/bug79477.phpt

Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,20 @@
1+
--TEST--
2+
Bug #79477: casting object into array creates references
3+
--FILE--
4+
<?php
5+
6+
class Test {
7+
public $prop = 'default value';
8+
}
9+
10+
$obj = new Test;
11+
$obj->{1} = null;
12+
13+
$arr = (array) $obj;
14+
$arr['prop'] = 'new value';
15+
16+
echo $obj->prop, "\n";
17+
18+
?>
19+
--EXPECT--
20+
default value

Zend/zend_hash.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2805,7 +2805,7 @@ ZEND_API HashTable* ZEND_FASTCALL zend_proptable_to_symtable(HashTable *ht, zend
28052805
{
28062806
HashTable *new_ht = zend_new_array(zend_hash_num_elements(ht));
28072807

2808-
ZEND_HASH_FOREACH_KEY_VAL(ht, num_key, str_key, zv) {
2808+
ZEND_HASH_FOREACH_KEY_VAL_IND(ht, num_key, str_key, zv) {
28092809
do {
28102810
if (Z_OPT_REFCOUNTED_P(zv)) {
28112811
if (Z_ISREF_P(zv) && Z_REFCOUNT_P(zv) == 1) {

0 commit comments

Comments
 (0)