Edit report at https://bugs.php.net/bug.php?id=64146&edit=1
ID: 64146
User updated by: slusarz at curecanti dot org
Reported by: slusarz at curecanti dot org
Summary: serialize incorrectly saving objects when they are
cloned
-Status: Feedback
+Status: Open
Type: Bug
Package: Variables related
Operating System: Linux
PHP Version: 5.4.11
Block user comment: N
Private report: N
New Comment:
Strange... Since that is the link github provides when you click on "share".
Anyway, try this instead:
https://gist.github.com/slusarz/4709613
Previous Comments:
------------------------------------------------------------------------
[2013-02-07 16:05:15] [email protected]
the link says: 4709613 hasn't created any public gists yet.
------------------------------------------------------------------------
[2013-02-04 21:11:57] slusarz at curecanti dot org
Description:
------------
When using clone in a Serializable serialize() method, the first object is
correctly cloned/saved. However, all subsequent calls to serialize() in the
same script access will have incorrect serialized representations of the cloned
object.
Using var_dump, it appears that clone is reusing the same object ID when the
object is cloned.
I can verify that removing the 'clone' keyword in the test script causes the
script to run correctly.
Test script:
---------------
https://gist.github.com/4709613
Expected result:
----------------
See gist for expected value.
For the record, the serialized value of the A object is as follows:
O:1:"A":1:{s:1:"a";a:2:{i:0;C:1:"B":24:{O:1:"C":1:{s:1:"c";i:1;}}i:1;C:1:"B":4:{r:4;}}}
Actual result:
--------------
See gist for actual value.
FWIW, running with --enable-debug produces this message:
[Mon Feb 4 14:11:17 2013] Script: '/tmp/test.php'
/disk2/src/php-5.4.11/Zend/zend_vm_execute.h(624) : Freeing 0x7FD6C9C94D78 (32
bytes), script=/tmp/test.php
=== Total 1 memory leaks detected ===
------------------------------------------------------------------------
--
Edit this bug report at https://bugs.php.net/bug.php?id=64146&edit=1