php.net |  support |  documentation |  report a bug |  advanced search |  search howto |  statistics |  random bug |  login
Bug #8676 Bad serialization of objects with references
Submitted: 2001-01-12 11:15 UTC Modified: 2001-06-20 11:17 UTC
From: arnaud dot bienvenu at generasound dot com Assigned: sas (profile)
Status: Closed Package: Session related
PHP Version: 4.0.5 OS: Linux
Private report: No CVE-ID: None
 [2001-01-12 11:15 UTC] arnaud dot bienvenu at generasound dot com
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>";
}
?>

Patches

Add a Patch

Pull Requests

Add a Pull Request

History

AllCommentsChangesGit/SVN commitsRelated reports
 [2001-05-22 21:29 UTC] sbergmann@php.net
Could you please give some feedback if this problem persists with a recent version (CVS, snapshot, 4.0.5 release) of PHP? Thanks!
 [2001-05-23 10:35 UTC] arnaud dot bienvenu at generasound dot com
Yes, the bug is still in 4.0.5. I put it back online on http://www.generasound.com/test/bug.php
You can see it in action provided your browser accepts cookies (go there and click reload).
 [2001-06-14 23:35 UTC] sniper@php.net
There are a lot of duplicate reports on this one.

 [2001-06-20 11:15 UTC] thies@php.net
fixed in CVS
 [2001-06-20 11:17 UTC] thies@php.net
forgot to close
 
PHP Copyright © 2001-2024 The PHP Group
All rights reserved.
Last updated: Thu Apr 18 19:01:30 2024 UTC