Bug #14266 Updated: serialize() doesn't work correcty

From: Date: Wed, 28 Nov 2001 13:43:47 +0000
Subject: Bug #14266 Updated: serialize() doesn't work correcty
References: 1  Groups: php.dev 
Request: Send a blank email to php-dev+get-71920@lists.php.net to get a copy of this message
ID: 14266 User updated by: lenar@vision.ee Reported By: lenar@vision.ee Old Status: Bogus Status: Open Bug Type: Scripting Engine problem Operating System: Debian Linux PHP Version: 4.2.0-dev New Comment: I dont' agree. Circular refferences can happen with objects (using refferences). Sometimes they are intentional. And serialize() doesn't completely ignore this. Because it spits out: O:8:"stdClass":1:{s:1:"x";O:8:"stdClass":1:{s:1:"x";R:2;}} so it knows about circular refferences. Now is there any reason why it doesn't generate instead something like this: O:8:"stdClass":1:{s:1:"x";R:1;} I would understand if it completely ignores circular references, but it doesn't. It just misbehaves. Previous Comments: ------------------------------------------------------------------------ [2001-11-28 08:41:04] jmoore@php.net Your creating a reference to itself this is not allowed. Therefore the bug is bogus, the behaviour is undefined. - James ------------------------------------------------------------------------ [2001-11-28 08:38:38] lenar@vision.ee Tested this with current cvs too. No better luck. Original and unserialized objects have different representation in memory. ------------------------------------------------------------------------ [2001-11-28 08:38:01] jmoore@php.net Circualar reference here: $x->x =& $x; These dont work as expected at all. Bogus bug report as the lang isnt designed to support this. - James ------------------------------------------------------------------------ [2001-11-28 08:32:48] lenar@vision.ee Consider following simple script. It's pretty obvious that serialize() does not work correctly (at least not as expected). <?php $x = new stdClass(); $x->x =& $x; $s = serialize($x) . "\n"; echo "test on original: "; // OK $x->a = "str"; echo $x->x->a . "\n"; $o = unserialize($s); echo "test on unserialized object: "; // not OK $o->a = "str"; echo $o->x->a . "\n"; ?> ------------------------------------------------------------------------ Edit this bug report at http://bugs.php.net/?id=14266&edit=1

« previous php.dev (#71920) next »