From: ap at tellusion dot com Operating system: Linux Red Hat EL PHP version: 5CVS-2006-12-25 (snap) PHP Bug Type: Variables related Bug description: References broken in php 5.2
Description: ------------ The first bug is that objects are being cloned when they are clearly intended be references. The second bug is that if one assigns the reference to another variable, the first bug will disappear in some circumstances. Reproduce code: --------------- The output from each of these scripts is different between PHP 5.2 & 5.0.4. reftest-int.php an example of an integer reference not being set as expected, but after the reference is assigned to another variable, the reference can be set using the same method. reftest-array.php the same bugs, but using an array as the example. In this scenario, two attempts to add data to an array (via a reference) fails. Those two attempts are later repeated after data is successfully added to the array in a more direct fashion and one of those two repeated attempts now succeeds. reftest-object.php a demonstration of the same bug with arrays and within the context of an object. ISOLATION The faults are present in php5.2 & php5.2-200612250730 (STABLE). The faults are not present in php 5.0.4, that is, the sample code appears to run as expected on non-5.2 versions of PHP. I also suspect the fault is not present in 5.1 but I have not run the attached scripts against 5.1 (I have run an affected app though). One exception, 5.0.4 partially fails the reftest-array.php script. Specifically, it fails to insert xx2 & xx5 (is my interpretation of how the language should work in this xx2/xx5 scenario correct?). The PHP 5.0.4 machine is Linux 2.4.21-40.EL #1 The PHP 5.2 machine is Linux 2.6.9-22.0.2.ELsmp #1 SMP Expected result: ---------------- >From PHP 5.0.4 ### reftest-int.php ### intTheValue = 10 intTheValue = 10 ### reftest-array.php ### arrTheArray = Array ( [0] => xx1 [1] => xx3 [2] => xx4 ) ### reftest-object.php ### RefTest::addToArray(): arr = Array ( [0] => xx1 ) RefTest::addToArray(): arr = Array ( [0] => xx1 [1] => xx2 ) RefTest::addToArray(): arr = Array ( [0] => xx1 [1] => xx2 [2] => xx3 ) objRefTest->getArray() = Array ( [0] => xx1 [1] => xx2 [2] => xx3 ) Actual result: -------------- >From PHP 5.2 ### reftest-int.php ### intTheValue = 0 intTheValue = 10 ### reftest-array.php ### arrTheArray = Array ( [0] => xx3 [1] => xx4 ) ### reftest-object.php ### RefTest::addToArray(): arr = Array ( [0] => xx1 ) RefTest::addToArray(): arr = Array ( [0] => xx2 ) RefTest::addToArray(): arr = Array ( [0] => xx3 ) objRefTest->getArray() = Array ( ) -- Edit bug report at http://bugs.php.net/?id=39944&edit=1 -- Try a CVS snapshot (PHP 4.4): http://bugs.php.net/fix.php?id=39944&r=trysnapshot44 Try a CVS snapshot (PHP 5.2): http://bugs.php.net/fix.php?id=39944&r=trysnapshot52 Try a CVS snapshot (PHP 6.0): http://bugs.php.net/fix.php?id=39944&r=trysnapshot60 Fixed in CVS: http://bugs.php.net/fix.php?id=39944&r=fixedcvs Fixed in release: http://bugs.php.net/fix.php?id=39944&r=alreadyfixed Need backtrace: http://bugs.php.net/fix.php?id=39944&r=needtrace Need Reproduce Script: http://bugs.php.net/fix.php?id=39944&r=needscript Try newer version: http://bugs.php.net/fix.php?id=39944&r=oldversion Not developer issue: http://bugs.php.net/fix.php?id=39944&r=support Expected behavior: http://bugs.php.net/fix.php?id=39944&r=notwrong Not enough info: http://bugs.php.net/fix.php?id=39944&r=notenoughinfo Submitted twice: http://bugs.php.net/fix.php?id=39944&r=submittedtwice register_globals: http://bugs.php.net/fix.php?id=39944&r=globals PHP 3 support discontinued: http://bugs.php.net/fix.php?id=39944&r=php3 Daylight Savings: http://bugs.php.net/fix.php?id=39944&r=dst IIS Stability: http://bugs.php.net/fix.php?id=39944&r=isapi Install GNU Sed: http://bugs.php.net/fix.php?id=39944&r=gnused Floating point limitations: http://bugs.php.net/fix.php?id=39944&r=float No Zend Extensions: http://bugs.php.net/fix.php?id=39944&r=nozend MySQL Configuration Error: http://bugs.php.net/fix.php?id=39944&r=mysqlcfg