Bug #61967 [Asn]: unset array item in array_walk_recursive cause inconsistent array

From: Date: Fri, 29 Jul 2016 22:20:43 +0000
Subject: Bug #61967 [Asn]: unset array item in array_walk_recursive cause inconsistent array
References: 1  Groups: php.bugs 
Request: Send a blank email to php-bugs+get-202706@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 Updated by: nikic@php.net 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: Fixed by https://github.com/php/php-src/commit/11e050920d3052d2b14a9cff6c4c5764d674fc46. Previous Comments: ------------------------------------------------------------------------ [2013-07-29 21:00:12] mhitza at gmail dot com Can be safely closed as it doesn't cause any problems on 5.5 ------------------------------------------------------------------------ [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

« previous php.bugs (#202706) next »