From: chase at circleofmoms dot com
Operating system: ubuntu 8.04
PHP version: 5.2.9
PHP Bug Type: Class/Object related
Bug description: this pointer is not passed by reference correctly
Description:
------------
When you pass the $this pointer by reference and change data for the
object it points to, that data is not correctly updated.
Reproduce code:
---------------
function changeAddress(&$oldThing) {
$oldThing = new Thing();
}
class Thing {
var $data;
public function updateData($newData) {
ThingChanger::changeData($this,$newData);
var_dump($this);
var_dump($this->data);
}
}
class ThingChanger {
public static function changeData(&$thingToChange,$newData) {
changeAddress($thingToChange);
$thingToChange->data = $newData;
}
}
$thing = new Thing();
$thing->data = "foo";
$thing->updateData("bar");
Expected result:
----------------
object(Thing)#2 (1) {
["data"]=>
string(3) "bar"
}
string(3) "bar"
Actual result:
--------------
object(Thing)#2 (1) {
["data"]=>
string(3) "bar"
}
string(3) "foo"
--
Edit bug report at http://bugs.php.net/?id=48483&edit=1
--
Try a CVS snapshot (PHP 5.2):
http://bugs.php.net/fix.php?id=48483&r=trysnapshot52
Try a CVS snapshot (PHP 5.3):
http://bugs.php.net/fix.php?id=48483&r=trysnapshot53
Try a CVS snapshot (PHP 6.0):
http://bugs.php.net/fix.php?id=48483&r=trysnapshot60
Fixed in CVS:
http://bugs.php.net/fix.php?id=48483&r=fixedcvs
Fixed in CVS and need be documented:
http://bugs.php.net/fix.php?id=48483&r=needdocs
Fixed in release:
http://bugs.php.net/fix.php?id=48483&r=alreadyfixed
Need backtrace:
http://bugs.php.net/fix.php?id=48483&r=needtrace
Need Reproduce Script:
http://bugs.php.net/fix.php?id=48483&r=needscript
Try newer version:
http://bugs.php.net/fix.php?id=48483&r=oldversion
Not developer issue:
http://bugs.php.net/fix.php?id=48483&r=support
Expected behavior:
http://bugs.php.net/fix.php?id=48483&r=notwrong
Not enough info:
http://bugs.php.net/fix.php?id=48483&r=notenoughinfo
Submitted twice:
http://bugs.php.net/fix.php?id=48483&r=submittedtwice
register_globals:
http://bugs.php.net/fix.php?id=48483&r=globals
PHP 4 support discontinued: http://bugs.php.net/fix.php?id=48483&r=php4
Daylight Savings: http://bugs.php.net/fix.php?id=48483&r=dst
IIS Stability:
http://bugs.php.net/fix.php?id=48483&r=isapi
Install GNU Sed:
http://bugs.php.net/fix.php?id=48483&r=gnused
Floating point limitations:
http://bugs.php.net/fix.php?id=48483&r=float
No Zend Extensions:
http://bugs.php.net/fix.php?id=48483&r=nozend
MySQL Configuration Error:
http://bugs.php.net/fix.php?id=48483&r=mysqlcfg