php.net |  support |  documentation |  report a bug |  advanced search |  search howto |  statistics |  random bug |  login
Bug #55326 Trait method copying misindentifies serialization callbacks
Submitted: 2011-07-31 03:16 UTC Modified: 2011-07-31 12:28 UTC
From: cataphract@php.net Assigned: felipe (profile)
Status: Closed Package: Scripting Engine problem
PHP Version: trunk-SVN-2011-07-31 (SVN) OS: Irrelevant
Private report: No CVE-ID: None
 [2011-07-31 03:16 UTC] 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}

Patches

bug55326.diff (last revision 2011-07-31 03:17 UTC by cataphract@php.net)

Add a Patch

Pull Requests

Add a Pull Request

History

AllCommentsChangesGit/SVN commitsRelated reports
 [2011-07-31 03:17 UTC] 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 12:27 UTC] felipe@php.net
Automatic comment from SVN on behalf of felipe
Revision: http://svn.php.net/viewvc/?view=revision&amp;revision=313991
Log: - Fixed bug #55326 (Trait method copying misindentifies serialization callbacks)
  patch by: Gustavo Lopes (cataphract@php)
 [2011-07-31 12:28 UTC] felipe@php.net
-Status: Open +Status: Closed -Assigned To: +Assigned To: felipe
 [2011-07-31 12:28 UTC] felipe@php.net
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.


 [2012-04-18 09:49 UTC] laruence@php.net
Automatic comment on behalf of felipe
Revision: http://git.php.net/?p=php-src.git;a=commit;h=b07c3c3e014ab0f492e4424eaa17db810c94970d
Log: - Fixed bug #55326 (Trait method copying misindentifies serialization callbacks)   patch by: Gustavo Lopes (cataphract@php)
 [2012-07-24 23:40 UTC] rasmus@php.net
Automatic comment on behalf of felipe
Revision: http://git.php.net/?p=php-src.git;a=commit;h=b07c3c3e014ab0f492e4424eaa17db810c94970d
Log: - Fixed bug #55326 (Trait method copying misindentifies serialization callbacks)   patch by: Gustavo Lopes (cataphract@php)
 [2013-11-17 09:37 UTC] laruence@php.net
Automatic comment on behalf of felipe
Revision: http://git.php.net/?p=php-src.git;a=commit;h=b07c3c3e014ab0f492e4424eaa17db810c94970d
Log: - Fixed bug #55326 (Trait method copying misindentifies serialization callbacks)   patch by: Gustavo Lopes (cataphract@php)
 
PHP Copyright © 2001-2024 The PHP Group
All rights reserved.
Last updated: Fri Mar 29 09:01:28 2024 UTC