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

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

 New Comment:

This bug has been fixed in SVN.

Snapshots of the sources are packaged every three hours; this change
will be in the next snapshot. You can grab the snapshot at
http://snaps.php.net/.

 For Windows:

http://windows.php.net/snapshots/
 
Thank you for the report, and for helping us make PHP better.




Previous Comments:
------------------------------------------------------------------------
[2011-07-31 12:27:47] fel...@php.net

Automatic comment from SVN on behalf of felipe
Revision: http://svn.php.net/viewvc/?view=revision&revision=313991
Log: - Fixed bug #55326 (Trait method copying misindentifies serialization 
callbacks)
  patch by: Gustavo Lopes (cataphract@php)

------------------------------------------------------------------------
[2011-07-31 03:17:32] cataphr...@php.net

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

------------------------------------------------------------------------
[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