Bug #70682 [NEW]: extract() removes any references to array
| From: | marc at phpbb dot com | Date: | Fri, 09 Oct 2015 21:00:58 +0000 |
| Subject: | Bug #70682 [NEW]: extract() removes any references to array | ||
| Groups: | php.bugs | ||
| Request: | Send a blank email to php-bugs+get-196507@lists.php.net to get a copy of this message | ||
From: marc at phpbb dot com
Operating system: Ubuntu Linux
PHP version: 7.0Git-2015-10-09 (Git)
Package: Arrays related
Bug Type: Bug
Bug description:extract() removes any references to array
Description:
------------
Actual version output (php7 nightly): PHP 7.1.0-dev (cli) (built: Oct 8
2015 19:09:26) ( NTS )
The extract() function removes any references to an array. While the
supplied test script works fine on prior PHP versions like 5.5.x and
5.6.x, it does no longer work on the current PHP7 nightly.
Prior to running extract(), the variable $var and its content is a
reference to the initial array passed to the test() function. After the
call to it, this is no longer the case.
According to debug_zval_dump(), the array itself is still a reference.
The content of the array however is not.
I suspect this might have been caused by this as it seems related:
https://bugs.php.net/bug.php?id=70250
Test script:
---------------
<?php
function main()
{
$foo = array('meh' => 1);
var_dump($foo);
test($foo);
var_dump($foo);
}
function test(&$var)
{
$function = function($test) { return array('var' => $test); };
extract($function($var));
$var['bar'] = 5;
}
main();
Expected result:
----------------
array(1) {
'meh' =>
int(1)
}
array(2) {
'meh' =>
int(1)
'bar' =>
int(5)
}
Actual result:
--------------
array(1) {
["meh"]=>
int(1)
}
array(1) {
["meh"]=>
int(1)
}
--
Edit bug report at https://bugs.php.net/bug.php?id=70682&edit=1
--
Try a snapshot (PHP 5.4): https://bugs.php.net/fix.php?id=70682&r=trysnapshot54
Try a snapshot (PHP 5.5): https://bugs.php.net/fix.php?id=70682&r=trysnapshot55
Try a snapshot (trunk): https://bugs.php.net/fix.php?id=70682&r=trysnapshottrunk
Fixed in SVN: https://bugs.php.net/fix.php?id=70682&r=fixed
Fixed in release: https://bugs.php.net/fix.php?id=70682&r=alreadyfixed
Need backtrace: https://bugs.php.net/fix.php?id=70682&r=needtrace
Need Reproduce Script: https://bugs.php.net/fix.php?id=70682&r=needscript
Try newer version: https://bugs.php.net/fix.php?id=70682&r=oldversion
Not developer issue: https://bugs.php.net/fix.php?id=70682&r=support
Expected behavior: https://bugs.php.net/fix.php?id=70682&r=notwrong
Not enough info: https://bugs.php.net/fix.php?id=70682&r=notenoughinfo
Submitted twice: https://bugs.php.net/fix.php?id=70682&r=submittedtwice
register_globals: https://bugs.php.net/fix.php?id=70682&r=globals
PHP 4 support discontinued: https://bugs.php.net/fix.php?id=70682&r=php4
Daylight Savings: https://bugs.php.net/fix.php?id=70682&r=dst
IIS Stability: https://bugs.php.net/fix.php?id=70682&r=isapi
Install GNU Sed: https://bugs.php.net/fix.php?id=70682&r=gnused
Floating point limitations: https://bugs.php.net/fix.php?id=70682&r=float
No Zend Extensions: https://bugs.php.net/fix.php?id=70682&r=nozend
MySQL Configuration Error: https://bugs.php.net/fix.php?id=70682&r=mysqlcfg