|
php.net | support | documentation | report a bug | advanced search | search howto | statistics | random bug | login |
PatchesPull RequestsHistoryAllCommentsChangesGit/SVN commits
[2005-09-19 18:29 UTC] iliaa@php.net
[2005-09-19 19:14 UTC] truth at proposaltech dot com
|
|||||||||||||||||||||||||||
Copyright © 2001-2025 The PHP GroupAll rights reserved. |
Last updated: Sun Nov 30 22:00:01 2025 UTC |
Description: ------------ Based on the discussion on internals that led to the creation of php 4.4 (and based on the release notes for php 4.4), I would expect the only difference in running the following code under 4.3 and 4.4 to be the generation of a notice under 4.4. The code is bad, but it does not rely on corrupting memory. (BTW, this actually doesn't affect me personally because I immediately cleaned up our company's code for every 4.4 notice. I'm just helping isolate the BC break that frustrated a recent internals poster. Unless they are relying on memory corruption, users should be able to hide the notices and get the same behavior with 4.4 as 4.3. (There were posts from Zeev among others supporting this position.)) I hope this is easy to fix. The concept is easy. Whenever the code attempts to set a variable by reference, the variable should be unset as a first step. In the example, $y should be disconnected from $x because of the "$y =& ...". Yes, the reference shouldn't actually work, but that doesn't change the fact that the code clearly indicates that the connection between $y and $x should be broken. If I sound defensive, it's because Derick has already posted on internals that the new behavior is "correct". Please check with other engine gurus before jumping to any conclusions of bogusness. I think a fix to this BC break will save many hours for many, many php developers. (The example is silly, but you can get subtle cases of that problem in loops that are a nightmare to find.) Thanks! - Todd Reproduce code: --------------- <?php function f() { return 3; } $x = 5; $y =& $x; $y =& f(); var_dump($x); ?> Expected result: ---------------- $x should end up 5 because the "$y=&..." should disconnect $y from $x even though the new connection can't be made. Actual result: -------------- Under 4.3, $x ends up 5, but under 4.4, $x ends up 3.