php.net |  support |  documentation |  report a bug |  advanced search |  search howto |  statistics |  random bug |  login
Bug #79354 Fatal error: Anonymous class wasn't preloaded when using opcache preload
Submitted: 2020-03-08 21:13 UTC Modified: 2020-03-11 15:53 UTC
Votes:2
Avg. Score:5.0 ± 0.0
Reproduced:2 of 2 (100.0%)
Same Version:2 (100.0%)
Same OS:1 (50.0%)
From: laurent35240 at gmail dot com Assigned:
Status: Duplicate Package: opcache
PHP Version: 7.4.3 OS: *nix
Private report: No CVE-ID: None
View Developer Edit
Welcome! If you don't have a Git account, you can't do anything here.
If you reported this bug, you can edit this bug over here.
(description)
Block user comment
Status: Assign to:
Package:
Bug Type:
Summary:
From: laurent35240 at gmail dot com
New email:
PHP Version: OS:

 

 [2020-03-08 21:13 UTC] laurent35240 at gmail dot com
Description:
------------
When using opcache preload, I got this message when running my code "Fatal error: Anonymous class wasn't preloaded"

This happens when there is usage of an anonymous class extending a class that was not preloaded (cf test script)

I reproduced this issue with version 7.4.3 of PHP with cli and php-fpm on Mac and Linux

Test script:
---------------
I tried to gather a test script here: https://github.com/laurent35240/test-opcache-preload

Basically, you need to have a class using a anonymous class like in this example
class A
{
    public function getChildOfB() {
        return new class () extends B {};
    }
}

And put only class A and not class B in your opcache preload file.

Running a script calling A::getChildofB will then fail with a fatal error.

Expected result:
----------------
No Fatal Error

Actual result:
--------------
Fatal error: Anonymous class wasn't preloaded

Patches

Pull Requests

History

AllCommentsChangesGit/SVN commitsRelated reports
 [2020-03-09 17:32 UTC] cmb@php.net
This looks related to bug #79349.
 [2020-03-09 19:17 UTC] laurent35240 at gmail dot com
Yes this is the same issue. Sorry I didn't see it before.
I also had this issue when using symfony and worked on providing a simpler example without symfony
 [2020-03-11 15:53 UTC] nikic@php.net
-Status: Open +Status: Duplicate
 [2020-03-11 15:53 UTC] nikic@php.net
Closing this as a duplicate of bug #79349, for which I have attached a patch.
 
PHP Copyright © 2001-2024 The PHP Group
All rights reserved.
Last updated: Sun Dec 22 05:01:30 2024 UTC