php.net |  support |  documentation |  report a bug |  advanced search |  search howto |  statistics |  random bug |  login
Bug #7619 serialize() works not correct with cascaded objects in some circumstances
Submitted: 2000-11-03 08:13 UTC Modified: 2000-12-03 19:09 UTC
From: i088 at informatik dot fh-wuerzburg dot de Assigned:
Status: Closed Package: Variables related
PHP Version: 4.0.3pl1 OS: Win9x / Linux
Private report: No CVE-ID: None
View Add Comment Developer Edit
Welcome! If you don't have a Git account, you can't do anything here.
You can add a comment by following this link or if you reported this bug, you can edit this bug over here.
(description)
Block user comment
Status: Assign to:
Package:
Bug Type:
Summary:
From: i088 at informatik dot fh-wuerzburg dot de
New email:
PHP Version: OS:

 

 [2000-11-03 08:13 UTC] i088 at informatik dot fh-wuerzburg dot de
serialize() works not correct with cascaded objects in some circumstances  (on PHP 3.0.1x this worked correct !!) :
You have an object whitch contains "normal" variables like integers, strings and also other objects. These other objects also contains integers, strings etc. and again objects:

object 1 --- variable 11
          |- variable 12
          |      :
          |- variable 1x
          |- object 2 --- variable 21
                       |- variable 22
                       |      :
                       |- variable 2x
                       |- object 3 --- variable 31
                                    |      :
                                    |- variable 3x

Under some circumstances the output that serialize() produces does only contain the top-level object (object 1)with its "normal" variables (variable 11 ... variable 1x). The other objects (object 2 and 3) with all there variables are lost.

Patches

Add a Patch

Pull Requests

Add a Pull Request

History

AllCommentsChangesGit/SVN commitsRelated reports
 [2000-11-05 06:31 UTC] stas@php.net
Could you please provide some short example code?
 [2000-11-29 06:37 UTC] sniper@php.net
No feedback. 
 [2000-11-29 16:13 UTC] i088 at informatik dot fh-wuerzburg dot de
Here the script:
------------------------cut here----------------------------
<html>
<head>
<title>Serialize-Test</title>
</head>
<body>
<?php
  class MetaClass
  {
    var $id;
    var $MainClassObject;
  }

  class MainClass
  {
    var $id;
    var $SubClassObjectArray;
  }
  
  class SubClass
  {
    var $id;
    var $Item;
  }

  function MainClass_addSubClassObject(&$MainClassReference, $SubClassObject)
  {
    $MainClassReference->SubClassObjectArray[]=$SubClassObject;
  }


  $myMetaClass=new MetaClass;
  $myMetaClass->id=uniqid("");
  
  $myMainClass=new MainClass;
  $myMainClass->id=uniqid("");
  
  $myMetaClass->MainClassObject=$myMainClass;

  $mySubClass1=new SubClass;
  $mySubClass1->id=uniqid("");
  $mySubClass1->Item="SubClass 1";
  
  MainClass_addSubClassObject($myMetaClass->MainClassObject, $mySubClass1);

  $mySubClass2=new SubClass;
  $mySubClass2->id=uniqid("");
  $mySubClass2->Item="SubClass 2";

  MainClass_addSubClassObject($myMetaClass->MainClassObject, $mySubClass2);

  $myoldMainClass=$myMetaClass->MainClassObject;
  $myoldSubClass=reset($myoldMainClass->SubClassObjectArray);
  while ($myoldSubClass)
  {
    print $myoldSubClass->id."----".$myoldSubClass->Item."<br>\n";
    $myoldSubClass=next($myoldMainClass->SubClassObjectArray);
  }
  print "<br>\n";

  $serialized_data=serialize($myMetaClass);
  print $serialized_data."<br>\n";
  print "<br>\n";
  $unserialized_data=unserialize($serialized_data);

  $mynewMainClass=$unserialized_data->MainClassObject;
  $mynewSubClass=reset($mynewMainClass->SubClassObjectArray);
  while ($mynewSubClass)
  {
    print $mynewSubClass->id."----".$mynewSubClass->Item."<br>\n";
    $mynewSubClass=next($mynewMainClass->SubClassObjectArray);
  }
?>
</body>
</html>
------------------------cut here----------------------------

 [2000-11-29 18:17 UTC] sniper@php.net
Could you please try latest snapshot from http://snaps.php.net/ ?
This example code of yours works for me just fine (Linux).

--Jani
 [2000-12-03 19:09 UTC] sniper@php.net
User feedback:
-----------

now I'v got the latest snapshot and it seems that the serialize-bug is
fixed. All my scripts seems to work just fine now (with
Linux/Apache/PHP4.0.4-DEV_DSO). I could not try anything with Win9x,
because I don't have MSVC++ to compile PHP under Windows OS. If anyone
have a compiled version for Windows as ISAPI ".dll" please send it to me
and I'll try.


 
PHP Copyright © 2001-2019 The PHP Group
All rights reserved.
Last updated: Thu Sep 19 05:01:29 2019 UTC