-
-
Notifications
You must be signed in to change notification settings - Fork 9.6k
[FrameworkBundle][Config] Ignore exceptions thrown during reflection classes autoload #32516
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
[FrameworkBundle][Config] Ignore exceptions thrown during reflection classes autoload #32516
Conversation
I'm not sure we need to work around since the new behavior has been reverted on <7.4 |
Hmm, this is different and discussed in https://bugs.php.net/74372 |
@nicolas-grekas I don't think introducing an Error/Exception distinction here makes sense. If you want to ignore exceptions, please ignore them explicitly. We could revert from 7.3 and introduce in a later version, but given that we're at 7.3.8 already and this change is explicitly called out in the migration guide, I'm not sure doing that is a good idea. You'll have to deal with it at some point in either case... |
@nikic thanks for the feedback, OK. @fancyweb --- a/src/Symfony/Component/Config/Resource/ClassExistenceResource.php
+++ b/src/Symfony/Component/Config/Resource/ClassExistenceResource.php
@@ -76,11 +76,12 @@ class ClassExistenceResource implements SelfCheckingResourceInterface, \Serializ
try {
$exists = class_exists($this->resource) || interface_exists($this->resource, false) || trait_exists($this->resource, false);
- } catch (\ReflectionException $e) {
+ } catch (\Throwable $e) {
if (0 >= $timestamp) {
unset(self::$existsCache[1][$this->resource]);
throw $e;
}
+ $exists = class_exists($this->resource, false) || interface_exists($this->resource, false) || trait_exists($this->resource, false);
} finally {
self::$autoloadedClass = $autoloadedClass;
if (!--self::$autoloadLevel) {
|
OK, I missed the |
2f420b6
to
0816b13
Compare
@nicolas-grekas Just pushed all tests + a deduplication of the code. I don't think it was what you wanted so I'm waiting for your feedback 😁 |
|
63bbf4c
to
2f39c7e
Compare
Done.
Actually this method was introduced directly as |
$reader->getMethodAnnotations($reflectionMethod); | ||
try { | ||
$reader->getMethodAnnotations($reflectionMethod); | ||
} catch (AnnotationException $e) { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This is another fix / improvement. Moving this catch on every calls allows to not fail totally on first fail but just on each failing cases.
f609060
to
1782e42
Compare
src/Symfony/Component/Config/Resource/ClassExistenceResource.php
Outdated
Show resolved
Hide resolved
src/Symfony/Component/Config/Resource/ClassExistenceResource.php
Outdated
Show resolved
Hide resolved
9f23898
to
5df2ceb
Compare
ef3229e
to
d13f943
Compare
fd5bc1e
to
ccf2004
Compare
ccf2004
to
bf467cc
Compare
bf467cc
to
1f06925
Compare
1f06925
to
dbd9b75
Compare
Thank you @fancyweb. |
…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
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+.