ID: 39202
User updated by: cpriest at warpmail dot net
Reported By: cpriest at warpmail dot net
-Status: Feedback
+Status: Open
Bug Type: Arrays related
Operating System: Apache 2.0.55
PHP Version: 5.1.6
New Comment:
Expected:
------------------------------------------
Array
(
[Test] => myClassA Object
(
[Name] => Object 3
)
[Test2] => myClassA Object
(
[Name] => Object 2
)
)
Array
(
[Test] => myClassA Object
(
[Name] => Object 3
)
[Test2] => myClassA Object
(
[Name] => Object 2
)
)
Actual:
--------------------------------------------
Array
(
[Test] => myClassA Object
(
[Name] => Object 1
)
[Test2] => myClassA Object
(
[Name] => Object 2
)
)
Array
(
[Test] => myClassA Object
(
[Name] => Object 3
)
[Test2] => myClassA Object
(
[Name] => Object 2
)
)
Previous Comments:
------------------------------------------------------------------------
[2006-10-19 21:11:57] [EMAIL PROTECTED]
Can't reproduce.
After the first print_r() I see "Object 1" (because the object haven't
been changed yet), after ther second call I get "Object 3", which is
expected too.
Hint: when we say "expected and actual results" we usually mean
"copy/paste what you see and also attach what you expected to see", not
a "I expect to see ..".
------------------------------------------------------------------------
[2006-10-19 20:56:01] cpriest at warpmail dot net
Description:
------------
References in temporary tables de-reference their references upon
crossing function boundaries
Reproduce code:
---------------
<?php
class myClassA {
public $Name = '';
function __construct($Name) { $this->Name = $Name; }
}
global $tblData;
$tblData = array(
'Test' => new myClassA('Object 1'),
'Test2' => new myClassA('Object 2'),
);
function getReferenced() {
global $tblData;
$tblData2 = array(
'Test' => &$tblData['Test'],
'Test2' => &$tblData['Test2'],
);
return $tblData2;
}
echo '<plaintext>';
print_r($tblData);
$tblData2 = getReferenced();
$tblData2['Test']->Name = 'Object 3';
print_r($tblData2);
?>
Expected result:
----------------
I expect there to be only two objects at the end of the call, one with
a Name of 'Object 3' and one with a Name of 'Object 2'
Actual result:
--------------
Three objects exist, 'Object 1', 'Object 2', and 'Object 3'
------------------------------------------------------------------------
--
Edit this bug report at http://bugs.php.net/?id=39202&edit=1