Bug #13800 Updated: Correct algorithm for serializing objects
| From: | sander@php.net | Date: | Tue, 23 Oct 2001 18:05:46 +0000 |
| Subject: | Bug #13800 Updated: Correct algorithm for serializing objects | ||
| References: | 1 | Groups: | php.dev |
| Request: | Send a blank email to php-dev+get-68859@lists.php.net to get a copy of this message | ||
ID: 13800
Updated by: sander
Reported By: shelby@DownloadFAST.com
Old Status: Open
Status: Closed
Bug Type: Session related
Operating System: FreeBSD 4.2
PHP Version: 4.0.6
New Comment:
Added your comments to #13236.
Previous Comments:
------------------------------------------------------------------------
[2001-10-23 13:33:53] shelby@DownloadFAST.com
The references the currently open Bug id #13236. I have confirmed this bug.
I tried to add my comments to that bug, but apparently only the creator of the bug can do that.
I don't have time to look at the PHP source code, but generally the way serialization of
objects is done (taken from C++ foundation classes I've worked with) is on write build a hash
table of object pointers/addresses as key, and a unique id (auto increment) as value. Write the id
and class on first instance, and then serialize only the id on subsequent references to same object.
Then on read serialization (unserialization), build the same hash table with the key and value
reversed roles, i.e. the key is the id, and the value is the pointer to the object.
AFAIK, this method will support cyclical references. From the number of bugs I've seen
reported about storing objects and/or references in sessions, I am guessing that PHP is not using
this general algorithm.
I've seen other object and/or referenence bugs in sessions in past releases of PHP (starting
with PHP4.0.3pl1), and haven't had time to go back and test to see what has been fixed, what
has been broken, and what has not been fixed. It gets quite confusing and arduous to track.
I add this suggestion here if it may be of assistance, as a general way to kill all these bugs.
I'd really like to see the serialization of objects and references work correctly in a general
way, as it is a very powerful tool, vs. using other bandaids such long if-else constructs or
redundant arrays to achieve the equivalent of persistant object references.
Please take my input constructively.
------------------------------------------------------------------------
Edit this bug report at http://bugs.php.net/?id=13800&edit=1