Bug #70910 [Asn->Csd]: extract() breaks variable references

From: Date: Sat, 14 Nov 2015 09:16:54 +0000
Subject: Bug #70910 [Asn->Csd]: extract() breaks variable references
References: 1  Groups: php.bugs 
Request: Send a blank email to php-bugs+get-197251@lists.php.net to get a copy of this message
Edit report at https://bugs.php.net/bug.php?id=70910&edit=1 ID: 70910 Updated by: laruence@php.net Reported by: php at maisqi dot com Summary: extract() breaks variable references -Status: Assigned +Status: Closed Type: Bug Package: Scripting Engine problem Operating System: Windows 8 PHP Version: 7.0.0RC7 Assigned To: laruence Block user comment: N Private report: N New Comment: The fix for this bug has been committed. Snapshots of the sources are packaged every three hours; this change will be in the next snapshot. You can grab the snapshot at http://snaps.php.net/. For Windows: http://windows.php.net/snapshots/ Thank you for the report, and for helping us make PHP better. Previous Comments: ------------------------------------------------------------------------ [2015-11-14 03:40:48] laruence@php.net okey, I fixed it, make it be consistent with 5.6's behavior thanks ------------------------------------------------------------------------ [2015-11-14 03:40:31] laruence@php.net Automatic comment on behalf of laruence@gmail.com Revision: http://git.php.net/?p=php-src.git;a=commit;h=fce44a5a131f4d897ed9472fcf9a05efdbaa4d03 Log: Fixed bug #70910 (extract() breaks variable references) ------------------------------------------------------------------------ [2015-11-13 19:13:32] php at maisqi dot com I agree with nikic. It should do the same as doing it manually. ------------------------------------------------------------------------ [2015-11-13 16:24:30] nikic@php.net @laruence: My intuition would say that extract() without EXTR_REFS should behave the same was as manually doing the assignments, i.e.: extract(['a' => 'b', 'c' => 'd']); // should be the same as writing $a = 'b'; $c = 'd'; So in this case the equivalent code without extract() would be: $var = 'original value'; $ref =& $var; $var = 'new value'; In which case the result that PHP 5.6 provides is correct. If EXTR_REFS is specified then all assignments should happen with =&, which breaks references. In this case the current behavior matches the previous one already. ------------------------------------------------------------------------ [2015-11-13 15:39:21] laruence@php.net actually, I think previously behavior seems bug... current behavior is more reasonable, "it overwrite the old value". ------------------------------------------------------------------------ The remainder of the comments for this report are too long. To view the rest of the comments, please view the bug report online at https://bugs.php.net/bug.php?id=70910 -- Edit this bug report at https://bugs.php.net/bug.php?id=70910&edit=1

« previous php.bugs (#197251) next »