In PHP 4.2 and below, a lot of people have been using the undocumented feature (or un-patched bug) where you could assign a value to the object itself:
$this = $foo
This non-feature has been patched in PHP5, thus you no longer can use it. In fact, running the same script on a PHP5 server will end up with a FATAL ERROR.
To fix your script to be compatible with PHP5 (and backwards compatible with 4.2) you can replace that line of code with:
foreach (get_object_vars($foo) as $key => $value)$this->$key = $value;
