php.net |  support |  documentation |  report a bug |  advanced search |  search howto |  statistics |  random bug |  login
Bug #72615 Method __call is triggered instead of an existing method
Submitted: 2016-07-18 08:08 UTC Modified: 2020-07-21 18:32 UTC
Votes:4
Avg. Score:4.0 ± 0.7
Reproduced:3 of 3 (100.0%)
Same Version:1 (33.3%)
Same OS:3 (100.0%)
From: madboy at gmail dot com Assigned: nikic (profile)
Status: Closed Package: opcache
PHP Version: 5.6.23 OS: Ubuntu 14.04
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 you forgot your password, you can retrieve your password here.
Password:
Status:
Package:
Bug Type:
Summary:
From: madboy at gmail dot com
New email:
PHP Version: OS:

 

 [2016-07-18 08:08 UTC] madboy at gmail dot com
Description:
------------
Method __call is triggered instead of an existing method

Test script:
---------------
class A
{
    const METHOD = 'test';
    public function test()
    { echo 'test'; }
    
    public function __call($a, $b)
    { echo '__call'; }
    
    public function start()
    { $this->{self::METHOD}(); }
}
$obj = new A();
$obj->start();

Expected result:
----------------
a string "test"

Actual result:
--------------
a string "__call"

Patches

Pull Requests

History

AllCommentsChangesGit/SVN commitsRelated reports
 [2016-07-18 09:25 UTC] requinix@php.net
-Status: Open +Status: Feedback
 [2016-07-18 09:25 UTC] requinix@php.net
Working fine for me. https://3v4l.org/NKfA4
 [2016-07-18 10:09 UTC] madboy at gmail dot com
if I run this code from command line it works fine.
I get this problem only if I execute it through Apache (haven`t tried any other methods).
 [2016-07-18 13:52 UTC] cmb@php.net
-Assigned To: +Assigned To: cmb
 [2016-07-18 13:52 UTC] cmb@php.net
Is OPcache (or another bytecode cache) involved when you run on
Apache?
 [2016-07-18 15:30 UTC] madboy at gmail dot com
I did have opcache enabled by default.
After I disabled it, I get an expected result from code snippet reported.

I tried this code on PHP 5.5 and 7.0.8 and it worked fine with default settings. Though I don`t know if I had cache enabled and I don`t have those docker containers right now.
 [2016-07-18 15:58 UTC] cmb@php.net
-Package: Class/Object related +Package: opcache -Assigned To: cmb +Assigned To:
 [2016-07-18 15:58 UTC] cmb@php.net
Thanks for the fast feedback!
 [2016-07-18 15:58 UTC] cmb@php.net
-Status: Feedback +Status: Open
 [2020-07-21 17:39 UTC] smcbride at msn dot com
This bug has been open way too long.  Someone close it or fix it.  2016?  Give me a break.  4 years for a simple bug is ridiculous.
 [2020-07-21 18:32 UTC] nikic@php.net
-Status: Open +Status: Closed -Assigned To: +Assigned To: nikic
 [2020-07-21 18:32 UTC] nikic@php.net
Happy to oblige. I can't reproduce this issue with or without opcache. If anyone can still reproduce this on a supported PHP version, please say so and I'll take another look.
 
PHP Copyright © 2001-2024 The PHP Group
All rights reserved.
Last updated: Sun Oct 27 16:01:27 2024 UTC