Bug #64146 [NEW]: serialize incorrectly saving objects when they are cloned
| From: | slusarz at curecanti dot org | Date: | Mon, 04 Feb 2013 21:11:58 +0000 |
| Subject: | Bug #64146 [NEW]: serialize incorrectly saving objects when they are cloned | ||
| Groups: | php.bugs | ||
| Request: | Send a blank email to php-bugs+get-176436@lists.php.net to get a copy of this message | ||
From: slusarz at curecanti dot org
Operating system: Linux
PHP version: 5.4.11
Package: Variables related
Bug Type: Bug
Bug description:serialize incorrectly saving objects when they are cloned
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 bug report at https://bugs.php.net/bug.php?id=64146&edit=1
--
Try a snapshot (PHP 5.4): https://bugs.php.net/fix.php?id=64146&r=trysnapshot54
Try a snapshot (PHP 5.3): https://bugs.php.net/fix.php?id=64146&r=trysnapshot53
Try a snapshot (trunk): https://bugs.php.net/fix.php?id=64146&r=trysnapshottrunk
Fixed in SVN: https://bugs.php.net/fix.php?id=64146&r=fixed
Fixed in release: https://bugs.php.net/fix.php?id=64146&r=alreadyfixed
Need backtrace: https://bugs.php.net/fix.php?id=64146&r=needtrace
Need Reproduce Script: https://bugs.php.net/fix.php?id=64146&r=needscript
Try newer version: https://bugs.php.net/fix.php?id=64146&r=oldversion
Not developer issue: https://bugs.php.net/fix.php?id=64146&r=support
Expected behavior: https://bugs.php.net/fix.php?id=64146&r=notwrong
Not enough info: https://bugs.php.net/fix.php?id=64146&r=notenoughinfo
Submitted twice: https://bugs.php.net/fix.php?id=64146&r=submittedtwice
register_globals: https://bugs.php.net/fix.php?id=64146&r=globals
PHP 4 support discontinued: https://bugs.php.net/fix.php?id=64146&r=php4
Daylight Savings: https://bugs.php.net/fix.php?id=64146&r=dst
IIS Stability: https://bugs.php.net/fix.php?id=64146&r=isapi
Install GNU Sed: https://bugs.php.net/fix.php?id=64146&r=gnused
Floating point limitations: https://bugs.php.net/fix.php?id=64146&r=float
No Zend Extensions: https://bugs.php.net/fix.php?id=64146&r=nozend
MySQL Configuration Error: https://bugs.php.net/fix.php?id=64146&r=mysqlcfg