Bug #70682 [Com]: extract() removes any references to array
| From: | marc at phpbb dot com | Date: | Sat, 10 Oct 2015 14:59:13 +0000 |
| Subject: | Bug #70682 [Com]: extract() removes any references to array | ||
| References: | 1 | Groups: | php.bugs |
| Request: | Send a blank email to php-bugs+get-196513@lists.php.net to get a copy of this message | ||
Edit report at https://bugs.php.net/bug.php?id=70682&edit=1
ID: 70682
Comment by: marc at phpbb dot com
Reported by: marc at phpbb dot com
Summary: extract() removes any references to array
Status: Open
Type: Bug
Package: Arrays related
Operating System: Ubuntu Linux
PHP Version: 7.0Git-2015-10-09 (Git)
Block user comment: N
Private report: N
New Comment:
Based on a build I compiled myself using the up-to-date git branch, the ticket mentioned in the
initial post seems to be unrelated to the current issue. I was also able to reproduce it on
7.0.0-beta1.
Previous Comments:
------------------------------------------------------------------------
[2015-10-09 21:00:57] marc at phpbb dot com
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 this bug report at https://bugs.php.net/bug.php?id=70682&edit=1