PHP 4.0 Bug #8676: Bad serialization of objects with references
| From: | arnaud dot bienvenu at generasound dot com | Date: | Fri, 12 Jan 2001 16:15:12 +0000 |
| Subject: | PHP 4.0 Bug #8676: Bad serialization of objects with references | ||
| Groups: | php.dev | ||
| Request: | Send a blank email to php-dev+get-43878@lists.php.net to get a copy of this message | ||
From: arnaud.bienvenu@generasound.com
Operating system: Linux
PHP version: 4.0.4
PHP Bug Type: *Session related
Bug description: Bad serialization of objects with references
Some complex objects won't be correctly stored into the session. This is probably a problem
with serialize/unserialize. It happens with objects structure containing some references. The code
below builds the simpliest structure I could find that pinpouts the problem.
With more complex structure, you can have all sorts of strange behaviour, including crashing PHP,
but the behaviours vary from one PHP installation to another (even with the same version and compile
flags).
<?php
/*
View this script with a browser and press reload
It will probably display "-->137645276" instead of "-->Object"
You can view it at http://www.generasound.com/test/bug.php
*/
session_start();
if (!isset($form))
{
$form = new stdClass();
$submit = new stdClass();
$upperif = new stdClass();
$upperif->Child = &$submit;
$upperif->Layout = new stdClass();
$upperif->Layout->Child = new stdClass();
$upperif->Layout->Child->Interface = &$submit;
$lowerif = new stdClass();
$form->Children[0] = &$upperif;
$form->Children[1] = &$lowerif;
$form->Layout = new stdClass();
$form->Layout->Children[1] = new stdClass();
$form->Layout->Children[1]->Interface = &$lowerif;
echo "-->".$form->Layout->Children[1]->Interface."<BR>";
session_register("form");
}
else
{
echo "-->".$form->Layout->Children[1]->Interface."<BR>";
}
?>
--
Edit Bug report at: http://bugs.php.net/?id=8676&edit=1