-
-
Notifications
You must be signed in to change notification settings - Fork 9.6k
[DebugClassLoader] Can't recover on a failed required file #32499
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Comments
Duplicate of #32395? |
Including the missing file would generate a warning that we could handle to throw a proper exception. But including instead of requiring would be a breaking change I guess. Somehow related : throwing an exception in a class loader behaves differently since PHP 7.3 (cf https://3v4l.org/OQPk9). I think that the |
How does composer deal with the missing file case? I'm not sure we care actually: if you dump the classmap, you must resync it when needed. |
Composer includes the file. So it just produces a warning + the class is not found + a |
Let's do the same? Use include instead of require? |
That's the easiest way but that's a big change for userland isn't it? We might break some workflows. However, doing it would resolve my bug in the |
What would break? |
I guess that going from a fatal error to a warning could have side effects.
Probably not on 99.99% of projects though... So if you agree with this
solution, let’s go for it. I will open a PR as a bug fix.
…On Thu 11 Jul 2019 at 18:35, Nicolas Grekas ***@***.***> wrote:
What would break?
—
You are receiving this because you authored the thread.
Reply to this email directly, view it on GitHub
<#32499?email_source=notifications&email_token=AA35DB5AUAXHVPOBDUXBJZDP65OMPA5CNFSM4IBLTUEKYY3PNVWWK3TUL52HS4DFVREXG43VMVBW63LNMVXHJKTDN5WW2ZLOORPWSZGODZXISZA#issuecomment-510560612>,
or mute the thread
<https://github.com/notifications/unsubscribe-auth/AA35DB37A4NYCDDP77HFKWDP65OMPANCNFSM4IBLTUEA>
.
|
Please do, thanks. |
…equiring them (fancyweb) This PR was merged into the 3.4 branch. Discussion ---------- [Debug][DebugClassLoader] Include found files instead of requiring them | Q | A | ------------- | --- | Branch? | 3.4 | Bug fix? | yes | New feature? | no | BC breaks? | no | Deprecations? | no | Tests pass? | yes | Fixed tickets | #32499 | License | MIT | Doc PR | no It fixes #32499 + it makes the `DebugClassLoader` behaves like composer `ClassLoader` that is very likely the wrapped class loader. Commits ------- c7141c8 [Debug][DebugClassLoader] Include found files instead of requiring them
…reflection classes autoload (fancyweb) This PR was merged into the 3.4 branch. Discussion ---------- [FrameworkBundle][Config] Ignore exceptions thrown during reflection classes autoload | Q | A | ------------- | --- | Branch? | 3.4 | Bug fix? | yes | New feature? | no | BC breaks? | no | Deprecations? | no | Tests pass? | yes | Fixed tickets | #32499 with PHP 7.3+ | License | MIT | Doc PR | - The behavior when an exception is thrown in a class loader changed in PHP 7.3 (cf https://3v4l.org/OQPk9). That means that the `throwOnRequiredClass` trick that is done in the parent class of these cache warmers (`AbstractPhpFileCacheWarmer`) does not work anymore with PHP7.3+. Commits ------- dbd9b75 [FrameworkBundle][Config] Ignore exeptions thrown during reflection classes autoload
…reflection classes autoload (fancyweb) This PR was merged into the 3.4 branch. Discussion ---------- [FrameworkBundle][Config] Ignore exceptions thrown during reflection classes autoload | Q | A | ------------- | --- | Branch? | 3.4 | Bug fix? | yes | New feature? | no | BC breaks? | no | Deprecations? | no | Tests pass? | yes | Fixed tickets | symfony/symfony#32499 with PHP 7.3+ | License | MIT | Doc PR | - The behavior when an exception is thrown in a class loader changed in PHP 7.3 (cf https://3v4l.org/OQPk9). That means that the `throwOnRequiredClass` trick that is done in the parent class of these cache warmers (`AbstractPhpFileCacheWarmer`) does not work anymore with PHP7.3+. Commits ------- dbd9b75d86 [FrameworkBundle][Config] Ignore exeptions thrown during reflection classes autoload
…reflection classes autoload (fancyweb) This PR was merged into the 3.4 branch. Discussion ---------- [FrameworkBundle][Config] Ignore exceptions thrown during reflection classes autoload | Q | A | ------------- | --- | Branch? | 3.4 | Bug fix? | yes | New feature? | no | BC breaks? | no | Deprecations? | no | Tests pass? | yes | Fixed tickets | symfony/symfony#32499 with PHP 7.3+ | License | MIT | Doc PR | - The behavior when an exception is thrown in a class loader changed in PHP 7.3 (cf https://3v4l.org/OQPk9). That means that the `throwOnRequiredClass` trick that is done in the parent class of these cache warmers (`AbstractPhpFileCacheWarmer`) does not work anymore with PHP7.3+. Commits ------- dbd9b75d86 [FrameworkBundle][Config] Ignore exeptions thrown during reflection classes autoload
Symfony version(s) affected: all
Description
In the
DebugClassLoader
, classes that are found by the wrapped class loaderfindFile()
method are required (and not included like in the composerClassLoader
for example). That means that if the file is not found, the fatal error that is triggered is not recoverable.So why would the wrapped class loader finds the file but the file doesn't actually exist? With Composer, it can happen if you dump your autoload files with the optimize option and if you delete a class file for example. The class will still be in the Composer class map.
What problem does it cause? When you do reflection on a class like this, it ends up with a fatal error instead of a
\ReflectionException
. In Symfony, that breaks theAnnotationCacheWarmer
process that is supposed to ignore\ReflectionException
s on classes that don't exist.Possible Solution
DebugClassLoader
: I guess it would be very bad for performance.SafeDebugClassLoader
that wraps theDebugClassLoader
to check if the file exists, so we can enable it / disable it on demand?@nicolas-grekas 🙏
The text was updated successfully, but these errors were encountered: