|  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
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
 [2020-03-08 21:13 UTC] laurent35240 at gmail dot com
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:

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


Add a Patch

Pull Requests

Add a Pull Request


AllCommentsChangesGit/SVN commitsRelated reports
 [2020-03-09 17:32 UTC]
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]
-Status: Open +Status: Duplicate
 [2020-03-11 15:53 UTC]
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: Wed Feb 21 03:01:33 2024 UTC