Bug #79349 [Com]: Unlinked anonymous classes prevent using preloading
| From: | nicolasgrekas@php.net | Date: | Thu, 05 Mar 2020 11:19:47 +0000 |
| Subject: | Bug #79349 [Com]: Unlinked anonymous classes prevent using preloading | ||
| References: | 1 | Groups: | php.bugs |
| Request: | Send a blank email to php-bugs+get-225905@lists.php.net to get a copy of this message | ||
Edit report at https://bugs.php.net/bug.php?id=79349&edit=1
ID: 79349
Comment by: nicolasgrekas@php.net
Reported by: nicolasgrekas@php.net
Summary: Unlinked anonymous classes prevent using preloading
Status: Open
Type: Bug
Package: opcache
PHP Version: 7.4.3
Block user comment: N
Private report: N
New Comment:
Maybe all missing symbols could trigger the autoloader before linking happens?
Previous Comments:
------------------------------------------------------------------------
[2020-03-05 11:15:30] nicolasgrekas@php.net
Of course, using regular class autoloading would work also instead of the current error.
------------------------------------------------------------------------
[2020-03-05 11:09:16] nicolasgrekas@php.net
The first affect class is this one:
https://github.com/symfony/symfony/blob/7c90c8ba84f24e3d4b62c02eeb8b14ce23eff59f/src/Symfony/Component/HttpKernel/Kernel.php#L459
> $cache = new class($cachePath, $this->debug) extends ConfigCache {
Right now, this anonymous class cannot be linked during preloading because the ConfigCache is not
available. Then, at runtime, when the code path is hit, the error occurs.
I wish there would be a way to discover programmatically that the ConfigCache class is required so
that it could be loaded.
Apparently, there is one internally, since opcache is able to trigger this warning:
> Can't preload unlinked class class@anonymous: Unknown parent
> Symfony\Component\Config\ConfigCache
But that's too late for me to do anything about it.
Of course, I could explicitly list ConfigCache for preloading - but this doesn't work in the
generic case as it requires ad-hoc knowledge of the codebase.
------------------------------------------------------------------------
[2020-03-05 11:03:19] nikic@php.net
Can you please share the relevant code in Symfony?
------------------------------------------------------------------------
[2020-03-05 11:02:09] nicolasgrekas@php.net
Typo:
Would it be possible to have nested anonymous classes be loaded at *preload* time?
------------------------------------------------------------------------
[2020-03-05 11:00:58] nicolasgrekas@php.net
Description:
------------
Following https://bugs.php.net/78937, commit
20ef51db22c46fd45976eb6d0b780c14022c8873 added a new runtime exception that says:
> Fatal error: Class foo wasn't preloaded
I don't how to deal with this exception. I feel like this is a blocker that prevents using
preloading when the preloading strategy is base on composer+autoloading. This hits Symfony.
Would it be possible to have nested anonymous classes be loaded at runtime?
This would allow the autoloader to load their dependencies, thus solving the issue.
------------------------------------------------------------------------
--
Edit this bug report at https://bugs.php.net/bug.php?id=79349&edit=1