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

 ID:                 55326
 Patch added by:     cataphr...@php.net
 Reported by:        cataphr...@php.net
 Summary:            Trait method copying misindentifies serialization
                     callbacks
 Status:             Open
 Type:               Bug
 Package:            Scripting Engine problem
 Operating System:   Irrelevant
 PHP Version:        trunk-SVN-2011-07-31 (SVN)
 Block user comment: N
 Private report:     N

 New Comment:

The following patch has been added/updated:

Patch Name: bug55326.diff
Revision:   1312082252
URL:        
https://bugs.php.net/patch-display.php?bug=55326&patch=bug55326.diff&revision=1312082252


Previous Comments:
------------------------------------------------------------------------
[2011-07-31 03:16:48] cataphr...@php.net

Description:
------------
_ADD_MAGIC_METHOD in zend_compile.c identifies "serialize_func" and 
"unserialize_func" as magic methods and copies them to ce->serialize_func and 
ce->unserialize_func.

The correct names are "serialize" and "unserialize". These names could be 
changed, or, better yet, those two lines should be deleted because the methods 
serialize and unserialize are only relevant if the class implements 
Serializable (or, more precisely, if ce->serialize and ce->unserialize are 
zend_user_serialize and zend_user_unserialize, respectively, and in any case 
ce->serialize_func and ce->unserialize_func work only as a lazy cache.

Test script:
---------------
<?php
trait A {
function serialize_func() { return "serialize_func"; }
function serialize() { return "serialize"; }
function unserialize($foo) {}
}
class B implements Serializable { use A; }
echo serialize(new B);

Expected result:
----------------
C:1:"B":9:{serialize}

Actual result:
--------------
C:1:"B":14:{serialize_func}


------------------------------------------------------------------------



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

Reply via email to