Bug #55326 [Opn->Csd]: Trait method copying misindentifies serialization callbacks
| From: | felipe@php.net | Date: | Sun, 31 Jul 2011 12:28:00 +0000 |
| Subject: | Bug #55326 [Opn->Csd]: Trait method copying misindentifies serialization callbacks | ||
| References: | 1 | Groups: | php.bugs |
| Request: | Send a blank email to php-bugs+get-162306@lists.php.net to get a copy of this message | ||
Edit report at https://bugs.php.net/bug.php?id=55326&edit=1
ID: 55326
Updated by: felipe@php.net
Reported by: cataphract@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] felipe@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] cataphract@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] cataphract@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