php.net |  support |  documentation |  report a bug |  advanced search |  search howto |  statistics |  random bug |  login
Bug #70250 extract() turns array elements to references
Submitted: 2015-08-12 16:58 UTC Modified: 2015-08-12 17:02 UTC
Votes:1
Avg. Score:3.0 ± 0.0
Reproduced:1 of 1 (100.0%)
Same Version:1 (100.0%)
Same OS:1 (100.0%)
From: bugs dot php dot net at ss dot st dot tc Assigned:
Status: Closed Package: Arrays related
PHP Version: 7.0Git-2015-08-12 (Git) OS: Gentoo Linux
Private report: No CVE-ID: None
Welcome back! If you're the original bug submitter, here's where you can edit the bug or add additional notes.
If you forgot your password, you can retrieve your password here.
Password:
Status:
Package:
Bug Type:
Summary:
From: bugs dot php dot net at ss dot st dot tc
New email:
PHP Version: OS:

 

 [2015-08-12 16:58 UTC] bugs dot php dot net at ss dot st dot tc
Description:
------------
extract() turns array elements back to references after they were once referenced and despite the reference was removed.
Tested on PHP 5.6.12 (works as expected), 7.0b3 (buggy) and git rev 2366a070c8 (buggy).


Test script:
---------------
<?php

$array = ['key' => 'value'];

// create a reference to an element of the array
$ref = & $array['key'];

// make sure array element is a reference
var_dump($array);

// remove the $ref reference
unset($ref);

// make sure array elements are no longer references
var_dump($array);

extract($array);

// make sure array elements are still no references
var_dump($array);


Expected result:
----------------
array(1) {
  ["key"]=>
  &string(5) "value"
}
array(1) {
  ["key"]=>
  string(5) "value"
}
array(1) {
  ["key"]=>
  string(5) "value"
}


Actual result:
--------------
array(1) {
  ["key"]=>
  &string(5) "value"
}
array(1) {
  ["key"]=>
  string(5) "value"
}
array(1) {
  ["key"]=>
  &string(5) "value"   <=== reference again
}


Patches

Pull Requests

History

AllCommentsChangesGit/SVN commitsRelated reports
 [2015-08-12 17:02 UTC] bugs dot php dot net at ss dot st dot tc
-Summary: extract() turns array array elements to references +Summary: extract() turns array elements to references
 [2015-08-12 17:02 UTC] bugs dot php dot net at ss dot st dot tc
(fixed typo in bug "Summary" field)
 [2015-08-13 05:38 UTC] laruence@php.net
Automatic comment on behalf of laruence
Revision: http://git.php.net/?p=php-src.git;a=commit;h=dc5c6ab774ff4f52675a663cb241896ca5d804cf
Log: Fixed bug #70250 (extract() turns array elements to references)
 [2015-08-13 05:38 UTC] laruence@php.net
-Status: Open +Status: Closed
 [2015-08-18 16:24 UTC] ab@php.net
Automatic comment on behalf of laruence
Revision: http://git.php.net/?p=php-src.git;a=commit;h=dc5c6ab774ff4f52675a663cb241896ca5d804cf
Log: Fixed bug #70250 (extract() turns array elements to references)
 [2016-07-20 11:37 UTC] davey@php.net
Automatic comment on behalf of laruence
Revision: http://git.php.net/?p=php-src.git;a=commit;h=dc5c6ab774ff4f52675a663cb241896ca5d804cf
Log: Fixed bug #70250 (extract() turns array elements to references)
 
PHP Copyright © 2001-2024 The PHP Group
All rights reserved.
Last updated: Fri Oct 04 08:01:28 2024 UTC