Bug #69758 [Opn->Csd]: Item added to array not being removed by array_pop/shift

From: Date: Fri, 05 Jun 2015 03:57:33 +0000
Subject: Bug #69758 [Opn->Csd]: Item added to array not being removed by array_pop/shift
References: 1  Groups: php.bugs 
Request: Send a blank email to php-bugs+get-193130@lists.php.net to get a copy of this message
Edit report at https://bugs.php.net/bug.php?id=69758&edit=1 ID: 69758 Updated by: laruence@php.net Reported by: gsherwood at squiz dot net Summary: Item added to array not being removed by array_pop/shift -Status: Open +Status: Closed Type: Bug Package: *General Issues Operating System: NA PHP Version: master-Git-2015-06-04 (Git) Block user comment: N Private report: N New Comment: Automatic comment on behalf of laruence Revision: http://git.php.net/?p=php-src.git;a=commit;h=497f9f2cda4e2f2281cfbde148e7408908261c63 Log: Fixed bug #69758 (Item added to array not being removed by array_pop/shift) Previous Comments: ------------------------------------------------------------------------ [2015-06-05 00:11:38] gsherwood at squiz dot net Description: ------------ My unit tests began failing on PHP7 builds about a month ago, which I tracked down to an array_pop() call not actually removing the element from the array. This works fine on earlier PHP7 builds and all PHP5 versions, so I'm reporting it as a BC break, and a possible bug report. I have a test case with output for various versions here: http://3v4l.org/mR874 PHP version information below: $ php --version PHP 7.0.0-dev (cli) (built: Jun 5 2015 08:25:20) Copyright (c) 1997-2015 The PHP Group Zend Engine v3.0.0-dev, Copyright (c) 1998-2015 Zend Technologies Test script: --------------- <?php $tokens = array(); $conditions = array(); for ($i = 0; $i <= 10; $i++) { $tokens[$i] = $conditions; // First integer must be less than 8 // and second must be 8, 9 or 10 if ($i !== 0 && $i !== 8) { continue; } // Add condition and then pop off straight away. // Can also use array_shift() here. $conditions[$i] = true; $oldCondition = array_pop($conditions); } // Conditions should be empty. print_r($conditions); Expected result: ---------------- Array ( ) Actual result: -------------- Array ( [8] => 1 ) ------------------------------------------------------------------------ -- Edit this bug report at https://bugs.php.net/bug.php?id=69758&edit=1

« previous php.bugs (#193130) next »