Movatterモバイル変換


[0]ホーム

URL:


Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

[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 ourterms of service andprivacy statement. We’ll occasionally send you account related emails.

Already on GitHub?Sign in to your account

Conversation

@fancyweb
Copy link
Contributor

QA
Branch?3.4
Bug fix?yes
New feature?no
BC breaks?no
Deprecations?no
Tests pass?yes
Fixed tickets#32499 with PHP 7.3+
LicenseMIT
Doc PR-

The behavior when an exception is thrown in a class loader changed in PHP 7.3 (cfhttps://3v4l.org/OQPk9). That means that thethrowOnRequiredClass trick that is done in the parent class of these cache warmers (AbstractPhpFileCacheWarmer) does not work anymore with PHP7.3+.

@nicolas-grekas
Copy link
Member

nicolas-grekas commentedJul 12, 2019
edited
Loading

I'm not sure we need to work around since the new behavior has been reverted on <7.4
See#32395
For 7.4, there are more places that need to be changed, and I'd like we really understand the best way to fix the root issue.

@nicolas-grekasnicolas-grekas added this to the3.4 milestoneJul 12, 2019
@nicolas-grekas
Copy link
Member

nicolas-grekas commentedJul 12, 2019
edited
Loading

Hmm, this is different and discussed inhttps://bugs.php.net/74372
@nikic can we consider fixing the BC break by having the new behavior only for child classes ofError and letException behave as before?

@nikic
Copy link
Contributor

@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...

@nicolas-grekas
Copy link
Member

nicolas-grekas commentedJul 12, 2019
edited
Loading

@nikic thanks for the feedback, OK.

@fancywebI think the patch should be only this one:

--- 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) {

The other places should not be changed (according to my current understanding at least.)

@nicolas-grekas
Copy link
Member

OK, I missed the} catch (\ReflectionException $e) { in warmers, I understand how the issue propagates here. We should factorize this logic now, inside throwOnRequiredClass I believe.

@fancywebfancywebforce-pushed thecache-warmer-ignore-reflection-exception-during-class-autoload branch from2f420b6 to0816b13CompareJuly 12, 2019 15:39
@fancyweb
Copy link
ContributorAuthor

fancyweb commentedJul 12, 2019
edited
Loading

@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 😁

@nicolas-grekas
Copy link
Member

ClassExistenceResource::isFresh() is also affected + any direct user ofPhpArrayAdapter::throwOnRequiredClass() would too.
The plan could be:

  • factorize inClassExistenceResource
  • find a way to useClassExistenceResource instead ofPhpArrayAdapter inFrameworkBundle
  • don't patchPhpArrayAdapter but deprecate itsthrowOnRequiredClass() in 4.4

@fancywebfancywebforce-pushed thecache-warmer-ignore-reflection-exception-during-class-autoload branch 3 times, most recently from63bbf4c to2f39c7eCompareJuly 16, 2019 10:31
@fancyweb
Copy link
ContributorAuthor

fancyweb commentedJul 16, 2019
edited
Loading

@nicolas-grekas

factorize in ClassExistenceResource

Done.

find a way to use ClassExistenceResource instead of PhpArrayAdapter in FrameworkBundle

symfony/config is a requirement of theFrameworkBundle so it's alright.

don't patch PhpArrayAdapter but deprecate its throwOnRequiredClass() in 4.4

Actually this method was introduced directly as@internal, so I just removed it.

$reader->getMethodAnnotations($reflectionMethod);
try {
$reader->getMethodAnnotations($reflectionMethod);
}catch (AnnotationException$e) {
Copy link
ContributorAuthor

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.

@fancywebfancyweb changed the title[FrameworkBundle][CacheWarmer] Ignore exeptions thrown during reflection classes autoload[FrameworkBundle][CacheWarmer] Ignore exceptions thrown during reflection classes autoloadJul 16, 2019
@fancywebfancywebforce-pushed thecache-warmer-ignore-reflection-exception-during-class-autoload branch 5 times, most recently fromf609060 to1782e42CompareJuly 17, 2019 07:11
@fancywebfancywebforce-pushed thecache-warmer-ignore-reflection-exception-during-class-autoload branch 3 times, most recently from9f23898 to5df2cebCompareJuly 22, 2019 22:18
@fancywebfancywebforce-pushed thecache-warmer-ignore-reflection-exception-during-class-autoload branch 3 times, most recently fromef3229e tod13f943CompareJuly 26, 2019 15:42
@fancywebfancywebforce-pushed thecache-warmer-ignore-reflection-exception-during-class-autoload branch 2 times, most recently fromfd5bc1e toccf2004CompareAugust 6, 2019 10:13
@nicolas-grekasnicolas-grekasforce-pushed thecache-warmer-ignore-reflection-exception-during-class-autoload branch fromccf2004 tobf467ccCompareAugust 6, 2019 15:39
@nicolas-grekasnicolas-grekas changed the title[FrameworkBundle][CacheWarmer] Ignore exceptions thrown during reflection classes autoload[FrameworkBundle][Config] Ignore exceptions thrown during reflection classes autoloadAug 6, 2019
@nicolas-grekasnicolas-grekasforce-pushed thecache-warmer-ignore-reflection-exception-during-class-autoload branch frombf467cc to1f06925CompareAugust 6, 2019 15:41
@nicolas-grekasnicolas-grekasforce-pushed thecache-warmer-ignore-reflection-exception-during-class-autoload branch from1f06925 todbd9b75CompareAugust 6, 2019 16:40
@nicolas-grekas
Copy link
Member

Thank you@fancyweb.

@nicolas-grekasnicolas-grekas merged commitdbd9b75 intosymfony:3.4Aug 7, 2019
nicolas-grekas added a commit that referenced this pull requestAug 7, 2019
…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 (cfhttps://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
@fancywebfancyweb deleted the cache-warmer-ignore-reflection-exception-during-class-autoload branchAugust 7, 2019 14:38
This was referencedAug 26, 2019
Sign up for freeto join this conversation on GitHub. Already have an account?Sign in to comment

Reviewers

@nicolas-grekasnicolas-grekasnicolas-grekas approved these changes

Assignees

No one assigned

Projects

None yet

Milestone

3.4

Development

Successfully merging this pull request may close these issues.

4 participants

@fancyweb@nicolas-grekas@nikic@carsonbot

[8]ページ先頭

©2009-2025 Movatter.jp