php.net |  support |  documentation |  report a bug |  advanced search |  search howto |  statistics |  random bug |  login
Bug #79740 serialize() and unserialize() methods can not be called statically
Submitted: 2020-06-26 08:10 UTC Modified: 2020-06-26 10:54 UTC
From: qqqqqwwwww731 at gmail dot com Assigned: nikic (profile)
Status: Closed Package: *General Issues
PHP Version: 7.4.7 OS: Linux
Private report: No CVE-ID: None
Welcome back! If you're the original bug submitter, here's where you can edit the bug or add additional notes.
If this is not your bug, you can add a comment by following this link.
If this is your bug, but you forgot your password, you can retrieve your password here.
Password:
Status:
Package:
Bug Type:
Summary:
From: qqqqqwwwww731 at gmail dot com
New email:
PHP Version: OS:

 

 [2020-06-26 08:10 UTC] qqqqqwwwww731 at gmail dot com
Description:
------------
is_callable function behavior changed in php 7.4


Test script:
---------------
<?php
class A
{
    public function serialize($v)
    {

    }

    public function func($v)
    {

    }
    
}

var_dump(is_callable(['A', 'serialize']));

var_dump(is_callable(['A', 'func']));

Expected result:
----------------
bool(true)
bool(true)

as in php before 7.4


Actual result:
--------------
in php 7.4 we have
bool(false)
bool(true)


Patches

Add a Patch

Pull Requests

Add a Pull Request

History

AllCommentsChangesGit/SVN commitsRelated reports
 [2020-06-26 08:20 UTC] nikic@php.net
The correct result is bool(false) for both, which is returned in PHP 8.

What's weird here is that one of the cases returns false and the other true. At least they should be returning the same value.
 [2020-06-26 08:26 UTC] nikic@php.net
-Status: Open +Status: Verified
 [2020-06-26 08:26 UTC] nikic@php.net
The problem is that we do not set ZEND_ACC_ALLOW_STATIC for serialize/unserialize methods anymore.
 [2020-06-26 08:30 UTC] nikic@php.net
-Summary: is_callable issue +Summary: serialize() and unserialize() methods can not be called statically -Status: Verified +Status: Assigned -Assigned To: +Assigned To: nikic
 [2020-06-26 10:54 UTC] nikic@php.net
-Status: Assigned +Status: Closed
 [2020-06-26 10:54 UTC] nikic@php.net
Fixed by https://github.com/php/php-src/commit/c5caa051711319f78b2b8b116dbc0186a73049a0, for some reason the auto-close did not trigger.
 
PHP Copyright © 2001-2024 The PHP Group
All rights reserved.
Last updated: Sat Apr 20 03:01:28 2024 UTC