Skip to content

Commit 207d0ee

Browse files
committed
Merge branch 'PHP-5.4' into PHP-5.5
* PHP-5.4: Bug #52861: unset fails with ArrayObject and deep arrays
2 parents 7a3933a + 7c08232 commit 207d0ee

File tree

2 files changed

+23
-1
lines changed

2 files changed

+23
-1
lines changed

ext/spl/spl_array.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -402,7 +402,7 @@ static zval *spl_array_read_dimension_ex(int check_inherited, zval *object, zval
402402
/* When in a write context,
403403
* ZE has to be fooled into thinking this is in a reference set
404404
* by separating (if necessary) and returning as an is_ref=1 zval (even if refcount == 1) */
405-
if ((type == BP_VAR_W || type == BP_VAR_RW) && !Z_ISREF_PP(ret)) {
405+
if ((type == BP_VAR_W || type == BP_VAR_RW || type == BP_VAR_UNSET) && !Z_ISREF_PP(ret)) {
406406
if (Z_REFCOUNT_PP(ret) > 1) {
407407
zval *newval;
408408

ext/spl/tests/bug52861.phpt

Lines changed: 22 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,22 @@
1+
--TEST--
2+
Bug #52861 (unset failes with ArrayObject and deep arrays)
3+
--FILE--
4+
<?php
5+
$arrayObject = new ArrayObject(array('foo' => array('bar' => array('baz' => 'boo'))));
6+
7+
unset($arrayObject['foo']['bar']['baz']);
8+
print_r($arrayObject->getArrayCopy());
9+
?>
10+
--EXPECT--
11+
Array
12+
(
13+
[foo] => Array
14+
(
15+
[bar] => Array
16+
(
17+
)
18+
19+
)
20+
21+
)
22+

0 commit comments

Comments
 (0)