PHP 4.0 Bug #8224 Updated: serialize() fails on arrays of objects

From: Date: Wed, 13 Dec 2000 13:21:57 +0000
Subject: PHP 4.0 Bug #8224 Updated: serialize() fails on arrays of objects
Groups: php.dev 
Request: Send a blank email to php-dev+get-41172@lists.php.net to get a copy of this message
ID: 8224 Updated by: jmoore Reported By: stefan.andreatta@uibk.ac.at Old-Status: Open Status: Closed Bug Type: Variables related Assigned To: Comments: The serialize bugs have been fixed in CVS. Please upgrade to 4.0.4 when it is avaible (you can get last RC *very stable* from ftp.phpuk.org) James Previous Comments: --------------------------------------------------------------------------- [2000-12-13 07:08:19] stefan.andreatta@uibk.ac.at If an array of objects is serialized/unserialized the array looses those elements (objects) for which a method has been called before serialization. This bug occurs in version 4.0.3pl1, but disappears when the php4ts.dll is exchanged for version 4.0.2 (no other changes to the installation required). This bug could be linked to #7619. Unfortunately I can't compile a Windows .dll at the moment, so I can't check with the CVS. The following samples script defines a simple class with one property and one method. Then an array is created containing two instances of this class. After calling the object's method for element[1] the array is serialized/unserialized. After that it contains only 1 element. -- script ---------------------------------------------- <?php class TestClass { function TestClass ($a) { $this->property = $a; } function getProperty () { return $this->property; } } //create instance $testArr[] = new TestClass("content 1"); $testArr[] = new TestClass("content 2"); $testArr[1]->getProperty(); $unser = unserialize(serialize($testInst)); echo "Before Serialization:"; echo "<br>number of elements: " . count($testArr); echo "<br>property of element[0]: " . $testArr[0]->property; echo "<br>property of element[1]: " . $testArr[1]->property; echo "<br><br>After Serialization:"; echo "<br>number of elements: " . count($unser); echo "<br>property of element[0]: " . $unser[0]->property; echo "<br>property of element[1]: " . $unser[1]->property; ?> -- end of script ---------------------------------------- --------------------------------------------------------------------------- Full Bug description available at: http://bugs.php.net/?id=8224

« previous php.dev (#41172) next »