ID: 39944
Updated by: [EMAIL PROTECTED]
Reported By: ap at tellusion dot com
-Status: Assigned
+Status: Closed
Bug Type: Variables related
Operating System: Linux Red Hat EL
PHP Version: 5CVS-2006-12-25 (snap)
Assigned To: dmitry
New Comment:
Fixed in CVS HEAD and PHP_5_2
Previous Comments:
------------------------------------------------------------------------
[2006-12-25 13:39:29] ap at tellusion dot com
Got some more isolation info on 5.1.x
the bug first appeared in 5.1.2 and is present in all 5.1 & 5.2
releases since then.
ap.
------------------------------------------------------------------------
[2006-12-25 11:32:13] ap at tellusion dot com
Just to add, my expected output for reftest-array.php is:
arrTheArray = Array
(
[0] => xx1
[1] => xx2
[2] => xx3
[3] => xx4
[4] => xx5
)
Neither PHP5.2 or PHP5.0.4 completely succeed.
------------------------------------------------------------------------
[2006-12-25 11:19:35] ap at tellusion dot com
Test scripts are here...
http://www.tellusion.com/reftest.tar
------------------------------------------------------------------------
[2006-12-25 11:14:29] ap at tellusion dot com
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 this bug report at http://bugs.php.net/?id=39944&edit=1