Skip to content

Commit 7c08232

Browse files
committed
Merge branch 'PHP-5.3' into PHP-5.4
* PHP-5.3: Bug #52861: unset fails with ArrayObject and deep arrays
2 parents 52d1add + 61099f8 commit 7c08232

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
@@ -29,6 +29,8 @@ PHP NEWS
2929
(patch by kriss@krizalys.com, Laruence)
3030
. Fixed bug #64106 (Segfault on SplFixedArray[][x] = y when extended).
3131
(Nikita Popov)
32+
. Fixed bug #52861 (unset fails with ArrayObject and deep arrays).
33+
(Mike Willbanks)
3234

3335
- SNMP:
3436
. Fixed bug #64124 (IPv6 malformed). (Boris Lytochkin)

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)