#50775 [Opn->Fbk]: Array does not serialize properly

From: Date: Sat, 16 Jan 2010 03:45:55 +0000
Subject: #50775 [Opn->Fbk]: Array does not serialize properly
References: 1  Groups: php.bugs 
Request: Send a blank email to php-bugs+get-146724@lists.php.net to get a copy of this message
ID: 50775 Updated by: rasmus@php.net Reported By: tolkad dot freenode at gmail dot com -Status: Open +Status: Feedback Bug Type: Arrays related Operating System: All PHP Version: 5.2.12 New Comment: Can you explain why you think the last var_dump() should show recursion? Looking at it, I don't see it since you are re-assigning $x there and you lose the recursive reference in doing so. Previous Comments: ------------------------------------------------------------------------ [2010-01-16 01:27:55] tolkad dot freenode at gmail dot com Description: ------------ When certain strings are unserialized they do not reserialize properly. Reproduce code: --------------- <?php $x = array(); $x[] = &$x; var_dump($x); $z = serialize($x); echo $z . "\n"; var_dump(unserialize($z)); echo "\n\n\n"; $x = unserialize("a:1:{i:0;R:1;}"); var_dump($x); $z = serialize($x); echo $z . "\n\n"; var_dump(unserialize($z)); Expected result: ---------------- array(1) { [0]=> &array(1) { [0]=> &array(1) { [0]=> *RECURSION* } } } a:1:{i:0;a:1:{i:0;R:2;}} array(1) { [0]=> &array(1) { [0]=> &array(1) { [0]=> *RECURSION* } } } array(1) { [0]=> &array(1) { [0]=> &array(1) { [0]=> *RECURSION* } } } a:1:{i:0;R:1;} array(1) { [0]=> &array(1) { [0]=> &array(1) { [0]=> *RECURSION* } } } Actual result: -------------- array(1) { [0]=> &array(1) { [0]=> &array(1) { [0]=> *RECURSION* } } } a:1:{i:0;a:1:{i:0;R:2;}} array(1) { [0]=> &array(1) { [0]=> &array(1) { [0]=> *RECURSION* } } } array(1) { [0]=> array(1) { [0]=> array(1) { [0]=> *RECURSION* } } } a:1:{i:0;a:1:{i:0;a:1:{i:0;N;}}} array(1) { [0]=> array(1) { [0]=> array(1) { [0]=> NULL } } } ------------------------------------------------------------------------ -- Edit this bug report at http://bugs.php.net/?id=50775&edit=1

« previous php.bugs (#146724) next »