php.net |  support |  documentation |  report a bug |  advanced search |  search howto |  statistics |  random bug |  login
Bug #39944 References broken in php 5.2
Submitted: 2006-12-25 11:14 UTC Modified: 2006-12-25 14:16 UTC
Votes:1
Avg. Score:5.0 ± 0.0
Reproduced:1 of 1 (100.0%)
Same Version:1 (100.0%)
Same OS:1 (100.0%)
From: ap at tellusion dot com Assigned: dmitry (profile)
Status: Closed Package: Variables related
PHP Version: 5CVS-2006-12-25 (snap) OS: Linux Red Hat EL
Private report: No CVE-ID: None
View Developer Edit
Welcome! If you don't have a Git account, you can't do anything here.
If you reported this bug, you can edit this bug over here.
(description)
Block user comment
Status: Assign to:
Package:
Bug Type:
Summary:
From: ap at tellusion dot com
New email:
PHP Version: OS:

 

 [2006-12-25 11:14 UTC] 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
(
)



Patches

Pull Requests

History

AllCommentsChangesGit/SVN commitsRelated reports
 [2006-12-25 11:19 UTC] ap at tellusion dot com
Test scripts are here...

http://www.tellusion.com/reftest.tar
 [2006-12-25 11:32 UTC] 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 13:39 UTC] 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 14:16 UTC] dmitry@php.net
Fixed in CVS HEAD and PHP_5_2
 
PHP Copyright © 2001-2024 The PHP Group
All rights reserved.
Last updated: Sun Dec 22 16:01:31 2024 UTC