PHP 4.0 Bug #7619 Updated: serialize() works not correct with cascaded objects in some circumstances

From: Date: Mon, 04 Dec 2000 00:09:24 +0000
Subject: PHP 4.0 Bug #7619 Updated: serialize() works not correct with cascaded objects in some circumstances
Groups: php.dev 
Request: Send a blank email to php-dev+get-39927@lists.php.net to get a copy of this message
ID: 7619 Updated by: sniper Reported By: i088@informatik.fh-wuerzburg.de Status: Closed Bug Type: Variables related Assigned To: Comments: 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. Previous Comments: --------------------------------------------------------------------------- [2000-11-29 18:17:53] 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-11-29 16:13:49] i088@informatik.fh-wuerzburg.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 06:37:15] sniper@php.net No feedback. --------------------------------------------------------------------------- [2000-11-05 06:31:43] stas@php.net Could you please provide some short example code? --------------------------------------------------------------------------- [2000-11-03 08:13:04] i088@informatik.fh-wuerzburg.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. --------------------------------------------------------------------------- The remainder of the comments for this report are too long. To view the rest of the comments, please view the bug report online. Full Bug description available at: http://bugs.php.net/?id=7619

« previous php.dev (#39927) next »