Bug #69758 [NEW]: Item added to array not being removed by array_pop/shift
| From: | gsherwood at squiz dot net | Date: | Fri, 05 Jun 2015 00:11:39 +0000 |
| Subject: | Bug #69758 [NEW]: Item added to array not being removed by array_pop/shift | ||
| Groups: | php.bugs | ||
| Request: | Send a blank email to php-bugs+get-193127@lists.php.net to get a copy of this message | ||
From: gsherwood at squiz dot net
Operating system: NA
PHP version: master-Git-2015-06-04 (Git)
Package: *General Issues
Bug Type: Bug
Bug description:Item added to array not being removed by array_pop/shift
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 bug report at https://bugs.php.net/bug.php?id=69758&edit=1
--
Try a snapshot (PHP 5.4): https://bugs.php.net/fix.php?id=69758&r=trysnapshot54
Try a snapshot (PHP 5.5): https://bugs.php.net/fix.php?id=69758&r=trysnapshot55
Try a snapshot (trunk): https://bugs.php.net/fix.php?id=69758&r=trysnapshottrunk
Fixed in SVN: https://bugs.php.net/fix.php?id=69758&r=fixed
Fixed in release: https://bugs.php.net/fix.php?id=69758&r=alreadyfixed
Need backtrace: https://bugs.php.net/fix.php?id=69758&r=needtrace
Need Reproduce Script: https://bugs.php.net/fix.php?id=69758&r=needscript
Try newer version: https://bugs.php.net/fix.php?id=69758&r=oldversion
Not developer issue: https://bugs.php.net/fix.php?id=69758&r=support
Expected behavior: https://bugs.php.net/fix.php?id=69758&r=notwrong
Not enough info: https://bugs.php.net/fix.php?id=69758&r=notenoughinfo
Submitted twice: https://bugs.php.net/fix.php?id=69758&r=submittedtwice
register_globals: https://bugs.php.net/fix.php?id=69758&r=globals
PHP 4 support discontinued: https://bugs.php.net/fix.php?id=69758&r=php4
Daylight Savings: https://bugs.php.net/fix.php?id=69758&r=dst
IIS Stability: https://bugs.php.net/fix.php?id=69758&r=isapi
Install GNU Sed: https://bugs.php.net/fix.php?id=69758&r=gnused
Floating point limitations: https://bugs.php.net/fix.php?id=69758&r=float
No Zend Extensions: https://bugs.php.net/fix.php?id=69758&r=nozend
MySQL Configuration Error: https://bugs.php.net/fix.php?id=69758&r=mysqlcfg