Edit report at https://bugs.php.net/bug.php?id=63926&edit=1
ID: 63926 Updated by: [email protected] Reported by: lgynove at 163 dot com -Summary: n/a +Summary: Internal pointer reset on separation Status: Not a bug Type: Bug Package: Reflection related Operating System: windows xp PHP Version: 5.4.10 Block user comment: N Private report: N New Comment: This is a corner case. When you do the write in the array, you're forcing a separation of the variable array. Because it's separated, its internal pointer is reset. This is a simpler test case: <?php function force_sep(&$v) {} $a = array(1); next($a); var_dump(current($a)); $b = $a; //refcount == 2 force_sep($a); var_dump(current($a)); Output: bool(false) int(1) //internal pointer was reset! The call to force_sep is actually unnecessary because current() takes its parameter by reference, forcing a separation on its own. The fix here would be to reproduce the array internal pointer of the old zval in the new zval upon separation, but that has a performance cost that I don't think is warranted. Previous Comments: ------------------------------------------------------------------------ [2013-01-07 10:30:54] [email protected] Thank you for taking the time to write to us, but this is not a bug. Please double-check the documentation available at http://www.php.net/manual/ and the instructions on how to report a bug at http://bugs.php.net/how-to-report.php ------------------------------------------------------------------------ [2013-01-07 08:53:12] lgynove at 163 dot com Description: ------------ n/a Test script: --------------- $array = array(1); while(list($k, $v) = each($array)) { foreach($array as $v2) { $array[$k] = 2; echo $array[$k]; } } Expected result: ---------------- 2 Actual result: -------------- 2222222222222222222222222222222222222222222222222222222222222222222222222222222222222222222222222222222222222222222222222222222222222222222222222222222222222222222222222222222222222222222222222222222222222222222222222222222222222222222222222222222222222222222222222222222222222222222222222222222222222222222222222222222222222222222222222222222222222222222222222222222222222222222222222222222222222222222222222222222222222222222222222222222222222222222222222222222222222222222222222222222222222222222222222222222222222222222222222222222222222222222222222222222222222222222222222222222222222222222222222222222222222222222222222222222222222222222222222222222222222222222222222222222222222222222222222222222222222222222222222222222222222222222222222222222222222222222222222222222222222222222222222222222222222222222222222222222222222222 Endless cycle ------------------------------------------------------------------------ -- Edit this bug report at https://bugs.php.net/bug.php?id=63926&edit=1
