Edit report at https://bugs.php.net/bug.php?id=64146&edit=1

 ID:                 64146
 Patch added by:     m...@php.net
 Reported by:        slusarz at curecanti dot org
 Summary:            serialize incorrectly saving objects when they are
                     cloned
 Status:             Verified
 Type:               Bug
 Package:            Variables related
 Operating System:   Linux
 PHP Version:        5.4.11
 Block user comment: N
 Private report:     N

 New Comment:

The following patch has been added/updated:

Patch Name: zend_objects_get_address
Revision:   1360277847
URL:        
https://bugs.php.net/patch-display.php?bug=64146&patch=zend_objects_get_address&revision=1360277847


Previous Comments:
------------------------------------------------------------------------
[2013-02-07 21:35:26] m...@php.net

Obviously a flaw in the way an object is identified in the engine/in the 
serializer.

Since the cloned objects only live for the time of serialization, both have the 
same object handle and will be identified as the *same*. 

Not sure why unserialize barfs on it, though.

------------------------------------------------------------------------
[2013-02-07 19:37:35] ni...@php.net

@slusarz: Github changed the Gist URLs to include the owner's name too. I guess 
they didn't consider users having number-names while doing that ^^

------------------------------------------------------------------------
[2013-02-07 17:18:06] slusarz at curecanti dot org

Strange... Since that is the link github provides when you click on "share".

Anyway, try this instead:

https://gist.github.com/slusarz/4709613

------------------------------------------------------------------------
[2013-02-07 16:05:15] larue...@php.net

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

Reply via email to