Bug #81228 [NEW]: print_r incorrectly linked to pass by reference loop

From: Date: Tue, 06 Jul 2021 19:25:34 +0000
Subject: Bug #81228 [NEW]: print_r incorrectly linked to pass by reference loop
Groups: php.bugs 
Request: Send a blank email to php-bugs+get-234842@lists.php.net to get a copy of this message
From: manuel at m-arzberger dot de Operating system: Ubuntu 20.04 PHP version: 7.4.21 Package: *General Issues Bug Type: Bug Bug description:print_r incorrectly linked to pass by reference loop Description: ------------ I'm using PHP 7.4.21 on Ubuntu 20.04 When you loop through an array the first time with pass by reference and then do it again without passing by reference, print_r will return unexpected values. The last item of the array will not be displayed, but the second to last. The array shouldn't be linked in any way to the pass be reference loop at the point. Test script: --------------- <?php $array = array('one', 'two', 'three', 'four'); foreach($array as &$value) { } foreach($array as $value) { } print_r($array); Expected result: ---------------- Array ( [0] => one [1] => two [2] => three [3] => four ) Actual result: -------------- Array ( [0] => one [1] => two [2] => three [3] => three ) -- Edit bug report at https://bugs.php.net/bug.php?id=81228&edit=1 -- Fix committed: https://bugs.php.net/fix.php?id=81228&r=fixed Fixed in release: https://bugs.php.net/fix.php?id=81228&r=alreadyfixed Need backtrace: https://bugs.php.net/fix.php?id=81228&r=needtrace Need Reproduce Script: https://bugs.php.net/fix.php?id=81228&r=needscript Try newer version: https://bugs.php.net/fix.php?id=81228&r=oldversion Not developer issue: https://bugs.php.net/fix.php?id=81228&r=support Expected behavior: https://bugs.php.net/fix.php?id=81228&r=notwrong Not enough info: https://bugs.php.net/fix.php?id=81228&r=notenoughinfo Submitted twice: https://bugs.php.net/fix.php?id=81228&r=submittedtwice register_globals: https://bugs.php.net/fix.php?id=81228&r=globals PHP version support discontinued: https://bugs.php.net/fix.php?id=81228&r=phptooold Daylight Savings: https://bugs.php.net/fix.php?id=81228&r=dst IIS Stability: https://bugs.php.net/fix.php?id=81228&r=isapi Install GNU Sed: https://bugs.php.net/fix.php?id=81228&r=gnused Floating point limitations: https://bugs.php.net/fix.php?id=81228&r=float No Zend Extensions: https://bugs.php.net/fix.php?id=81228&r=nozend MySQL Configuration Error: https://bugs.php.net/fix.php?id=81228&r=mysqlcfg

« previous php.bugs (#234842) next »