Skip to content

Commit 61099f8

Browse files
Mike Willbankssmalyshev
Mike Willbanks
authored andcommitted
Bug #52861: unset fails with ArrayObject and deep arrays
When checking to make into a reference write, readwrite are checked but not unset
1 parent 1b58bd3 commit 61099f8

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
@@ -6,6 +6,8 @@ PHP NEWS
66
. Fixed bug #64264 (SPLFixedArray toArray problem). (Laruence)
77
. Fixed bug #64228 (RecursiveDirectoryIterator always assumes SKIP_DOTS).
88
(patch by kriss@krizalys.com, Laruence)
9+
. Fixed bug #52861 (unset fails with ArrayObject and deep arrays).
10+
(Mike Willbanks)
911

1012
21 Feb 2013, PHP 5.3.22
1113

ext/spl/spl_array.c

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

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)