Skip to content
Browse files

Merge branch 'PHP-5.3' into PHP-5.4

* PHP-5.3:
  Bug #52861: unset fails with ArrayObject and deep arrays
  • Loading branch information...
2 parents 52d1add + 61099f8 commit 7c082325091ee7bfcf0e1e8b488b1e9fa66f0739 @smalyshev smalyshev committed
Showing with 25 additions and 1 deletion.
  1. +2 −0 NEWS
  2. +1 −1 ext/spl/spl_array.c
  3. +22 −0 ext/spl/tests/bug52861.phpt
View
2 NEWS
@@ -29,6 +29,8 @@ PHP NEWS
(patch by kriss@krizalys.com, Laruence)
. Fixed bug #64106 (Segfault on SplFixedArray[][x] = y when extended).
(Nikita Popov)
+ . Fixed bug #52861 (unset fails with ArrayObject and deep arrays).
+ (Mike Willbanks)
- SNMP:
. Fixed bug #64124 (IPv6 malformed). (Boris Lytochkin)
View
2 ext/spl/spl_array.c
@@ -402,7 +402,7 @@ static zval *spl_array_read_dimension_ex(int check_inherited, zval *object, zval
/* When in a write context,
* ZE has to be fooled into thinking this is in a reference set
* by separating (if necessary) and returning as an is_ref=1 zval (even if refcount == 1) */
- if ((type == BP_VAR_W || type == BP_VAR_RW) && !Z_ISREF_PP(ret)) {
+ if ((type == BP_VAR_W || type == BP_VAR_RW || type == BP_VAR_UNSET) && !Z_ISREF_PP(ret)) {
if (Z_REFCOUNT_PP(ret) > 1) {
zval *newval;
View
22 ext/spl/tests/bug52861.phpt
@@ -0,0 +1,22 @@
+--TEST--
+Bug #52861 (unset failes with ArrayObject and deep arrays)
+--FILE--
+<?php
+$arrayObject = new ArrayObject(array('foo' => array('bar' => array('baz' => 'boo'))));
+
+unset($arrayObject['foo']['bar']['baz']);
+print_r($arrayObject->getArrayCopy());
+?>
+--EXPECT--
+Array
+(
+ [foo] => Array
+ (
+ [bar] => Array
+ (
+ )
+
+ )
+
+)
+

0 comments on commit 7c08232

Please sign in to comment.
Something went wrong with that request. Please try again.