From:             cataphract
Operating system: Irrelevant
PHP version:      trunk-SVN-2011-07-31 (SVN)
Package:          Scripting Engine problem
Bug Type:         Bug
Bug description:Trait method copying misindentifies serialization callbacks

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 bug report at https://bugs.php.net/bug.php?id=55326&edit=1
-- 
Try a snapshot (PHP 5.4):            
https://bugs.php.net/fix.php?id=55326&r=trysnapshot54
Try a snapshot (PHP 5.3):            
https://bugs.php.net/fix.php?id=55326&r=trysnapshot53
Try a snapshot (trunk):              
https://bugs.php.net/fix.php?id=55326&r=trysnapshottrunk
Fixed in SVN:                        
https://bugs.php.net/fix.php?id=55326&r=fixed
Fixed in SVN and need be documented: 
https://bugs.php.net/fix.php?id=55326&r=needdocs
Fixed in release:                    
https://bugs.php.net/fix.php?id=55326&r=alreadyfixed
Need backtrace:                      
https://bugs.php.net/fix.php?id=55326&r=needtrace
Need Reproduce Script:               
https://bugs.php.net/fix.php?id=55326&r=needscript
Try newer version:                   
https://bugs.php.net/fix.php?id=55326&r=oldversion
Not developer issue:                 
https://bugs.php.net/fix.php?id=55326&r=support
Expected behavior:                   
https://bugs.php.net/fix.php?id=55326&r=notwrong
Not enough info:                     
https://bugs.php.net/fix.php?id=55326&r=notenoughinfo
Submitted twice:                     
https://bugs.php.net/fix.php?id=55326&r=submittedtwice
register_globals:                    
https://bugs.php.net/fix.php?id=55326&r=globals
PHP 4 support discontinued:          
https://bugs.php.net/fix.php?id=55326&r=php4
Daylight Savings:                    https://bugs.php.net/fix.php?id=55326&r=dst
IIS Stability:                       
https://bugs.php.net/fix.php?id=55326&r=isapi
Install GNU Sed:                     
https://bugs.php.net/fix.php?id=55326&r=gnused
Floating point limitations:          
https://bugs.php.net/fix.php?id=55326&r=float
No Zend Extensions:                  
https://bugs.php.net/fix.php?id=55326&r=nozend
MySQL Configuration Error:           
https://bugs.php.net/fix.php?id=55326&r=mysqlcfg

Reply via email to