#49821 [Fbk->Opn]: unserialize of references
ID: 49821
User updated by: liz2k dot b8 at gmail dot com
Reported By: liz2k dot b8 at gmail dot com
-Status: Feedback
+Status: Open
Bug Type: *Programming Data Structures
Operating System: linux
PHP Version: 5.2.11
New Comment:
I said about references in unserialize object - R and r.
If last reference of serialized object is R - then all references of
unserialized object will R. (linked by pointer (c++))
If last reference of serialized object is r - then all references of
unserialized object will r. (just refer to one object $a)
Previous Comments:
------------------------------------------------------------------------
[2009-10-12 11:21:28] sjoerd@php.net
I don't understand your answer. Please explain, preferably with a code
example, how the behavior you described causes a problem.
------------------------------------------------------------------------
[2009-10-12 07:01:18] liz2k dot b8 at gmail dot com
no - you can try serialize(&unserialize(serialize($a))).
------------------------------------------------------------------------
[2009-10-11 09:33:52] Sjoerd@php.net
Thank you for your bug report.
Is there a problem with this other than that the serialization string
is different? Do objects $a and $b have different behavior?
------------------------------------------------------------------------
[2009-10-09 14:05:22] liz2k dot b8 at gmail dot com
And one more wrong work Example:
$a = new stdClass;
$a->v2 = &$a;
$a->v1 = $a;
echo serialize($a)."\n";
$b = &unserialize(serialize($a));
echo serialize($b);
Expected result:
----------------
O:8:"stdClass":2:{s:2:"v2";R:1;s:2:"v1";r:1;}
O:8:"stdClass":2:{s:2:"v2";R:1;s:2:"v1";r:1;}
Actual result:
--------------
O:8:"stdClass":2:{s:2:"v2";R:1;s:2:"v1";r:1;}
O:8:"stdClass":2:{s:2:"v2";r:1;s:2:"v1";r:1;}
------------------------------------------------------------------------
[2009-10-09 13:05:44] liz2k dot b8 at gmail dot com
Description:
------------
function unserialize return wrong result of reference
Reproduce code:
---------------
---
From manual page: function.serialize
---
$a = new stdClass;
$a->v1 = $a;
$a->v2 = &$a;
echo serialize($a)."\n";
$b = &unserialize(serialize($a));
echo serialize($b);
Expected result:
----------------
O:8:"stdClass":2:{s:2:"v1";r:1;s:2:"v2";R:1;}
O:8:"stdClass":2:{s:2:"v1";r:1;s:2:"v2";R:1;}
Actual result:
--------------
O:8:"stdClass":2:{s:2:"v1";r:1;s:2:"v2";R:1;}
O:8:"stdClass":2:{s:2:"v1";R:1;s:2:"v2";R:1;}
------------------------------------------------------------------------
--
Edit this bug report at http://bugs.php.net/?id=49821&edit=1
Thread (7 messages)