Bug #61967 [Com]: unset array item in array_walk_recursive cause inconsistent array
| From: | mhitza at gmail dot com | Date: | Mon, 29 Jul 2013 21:00:12 +0000 |
| Subject: | Bug #61967 [Com]: unset array item in array_walk_recursive cause inconsistent array | ||
| References: | 1 | Groups: | php.bugs |
| Request: | Send a blank email to php-bugs+get-180546@lists.php.net to get a copy of this message | ||
Edit report at https://bugs.php.net/bug.php?id=61967&edit=1
ID: 61967
Comment by: mhitza at gmail dot com
Reported by: laruence@php.net
Summary: unset array item in array_walk_recursive cause
inconsistent array
Status: Assigned
Type: Bug
Package: Arrays related
PHP Version: 5.3.12
Assigned To: laruence
Block user comment: N
Private report: N
New Comment:
Can be safely closed as it doesn't cause any problems on 5.5
Previous Comments:
------------------------------------------------------------------------
[2012-05-07 02:57:48] laruence@php.net
and if someone can make a patch earlier than me, the patch will be appreciated.
------------------------------------------------------------------------
[2012-05-07 02:33:51] laruence@php.net
Description:
------------
when you unset the array which you are iterating. array inconsistent will be
reported.
I am looking into it, but sadly it is a little difficult to be fixed. since we
also allow change the item in the iterator function.
thanks
Test script:
---------------
<?php
$arr = array(
range(1, 10),
range(1, 10),
range(1, 10),
range(1, 10),
range(1, 10),
);
array_walk_recursive($arr,
function (&$value, $key) use(&$arr) {
unset($arr[$key]);
});
Expected result:
----------------
nothing wrong
Actual result:
--------------
Zend/zend_hash.c(1085) : ht=0x25f5b78 is inconsistent
------------------------------------------------------------------------
--
Edit this bug report at https://bugs.php.net/bug.php?id=61967&edit=1