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

[Router] routing cache crash when using generator_class#31964

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

Merged
nicolas-grekas merged 1 commit intosymfony:4.3fromdFayet:hotfix/issue-31807
Sep 6, 2019

Conversation

@dFayet
Copy link

@dFayetdFayet commentedJun 9, 2019
edited by nicolas-grekas
Loading

QA
Branch?4.3
Bug fix?yes
New feature?no
BC breaks?no
Deprecations?no
Tests pass?yes
Fixed tickets#31807
LicenseMIT

Since#28865 the Router use, by default, new generator, matcher, and dumpers.
This leads to crash when the Router use a custom generator, or matcher based on the old ones.

// Fallback to PhpGeneratorDumper if the UrlGenerator and UrlGeneratorDumper are not consistent with each other
if (is_a($this->options['generator_class'], CompiledUrlGenerator::class,true) !==
is_a($this->options['generator_dumper_class'], CompiledUrlGeneratorDumper::class,true)) {
$this->options['generator_dumper_class'] ='Symfony\\Component\\Routing\\Generator\\Dumper\\PhpGeneratorDumper';
Copy link
Member

@nicolas-grekasnicolas-grekasJun 10, 2019
edited
Loading

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others.Learn more.

I'm not super comfortable with this:PhpGeneratorDumper is deprecated, so that this line of code will have to change in v5. But to what? Let's say we remove it: this means we broke BC without any deprecation notice in v4. To the minimum, this might miss one.
Maybe the added logic is in the wrong method: shouldn't it be ingetGenerator() instead?
Note also that this overrides any values set by the user. I'd suggest replacing theis_a by a direct string comparison instead (that still wouldn't allow detecting when the option is explicitly set vs loaded from the defaults.)

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others.Learn more.

It must be removed when thePhpGeneratorDumper will be removed. You're right it misses a notice.

It does not remove all the values set by the user, only the "invalid" ones.
The only cases where values are overriden is when the user use a compiled generator|matcher with a "non-compiled" generator|matcher dumper (inverse is also true)

I think it should be more ingetGeneratorDumperInstance orgetMatcherDumperInstance, thangetGenerator andgetMatcher. But the changed values won't be visible if you callgetOption, your thoughts?

I don't think string comparision is right here, as the given classes will in most cases be children of the generator|matcher classes.

@dFayet
Copy link
Author

dFayet commentedJun 22, 2019
edited
Loading

@nicolas-grekas In#28865 the default router generator and matcher were changed to the newCompiledUrl classes. This leads to an exception if the router is used along with a custom generator/matcher build with the previous classes. This is what was faced in the issue#31807

Rather than "force changing" the classes used by the router in case of mismatch, would it be better to revert the changes made onRouter::setOptions, and add a deprecation warning(if needed) if a legacy class is used?

Copy link
Member

@nicolas-grekasnicolas-grekas left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others.Learn more.

(I pushed here the implementation you talked about - no need for additional notices as one will already be triggered when loading the class)

dFayet reacted with laugh emoji
@nicolas-grekas
Copy link
Member

Thank you@dFayet.

nicolas-grekas added a commit that referenced this pull requestSep 6, 2019
…Fayet)This PR was merged into the 4.3 branch.Discussion----------[Router] routing cache crash when using generator_class| Q             | A| ------------- | ---| Branch?       | 4.3| Bug fix?      | yes| New feature?  | no| BC breaks?    | no| Deprecations? | no| Tests pass?   | yes| Fixed tickets |#31807| License       | MITSince#28865 the Router use, by default, new generator, matcher, and dumpers.This leads to crash when the Router use a custom generator, or matcher based on the old ones.Commits-------a5b46e5 Fix routing cache broken when using generator_class
@nicolas-grekasnicolas-grekas merged commita5b46e5 intosymfony:4.3Sep 6, 2019
@fabpotfabpot mentioned this pull requestOct 7, 2019
nicolas-grekas added a commit that referenced this pull requestJan 8, 2020
…ass (fancyweb)This PR was merged into the 4.3 branch.Discussion----------[Routing] Fix using a custom matcher & generator dumper class| Q             | A| ------------- | ---| Branch?       | 4.3| Bug fix?      | yes| New feature?  | no| Deprecations? | no| Tickets       | -| License       | MIT| Doc PR        | -This PR fixes a BC break I encountered while upgrading an existing project from 4.2 to 4.4. In this project I use a custom `generator_dumper_class` that is not a `CompiledUrlGeneratorDumper` (it didn't exist yet). I faced 2 problems:- The generator is considered "compiled" while it is not. This is because we don't check if the `generator_dumper_class` is effectively a `CompiledUrlGeneratorDumper` to compute the `$compiled` variable. That result in a `\TypeError: Return value of Symfony\Component\Routing\Router::getCompiledRoutes() must be of the type array, int returned`- My custom dumper is not used at all. This is because of#31964. I altered the condition to fall back only in one way and not the other. The original issue is still fixed (if one uses a classic `UrlGenerator` + a `CompiledUrlGeneratorDumper`, it fall backs on `PhpGeneratorDumper`). However, if one uses a `CompiledUrlGenerator` + a classic `PhpGeneratorDumper` (my case), the classic dumper is still returned. Since `$compiled` is now correctly computed, this case works fine. The Router won't try to get the compiled routes and will use the "old" way.Commits-------3a840a9 [Routing] Fix using a custom matcher & generator dumper class
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

4.3

Development

Successfully merging this pull request may close these issues.

3 participants

@dFayet@nicolas-grekas@carsonbot

[8]ページ先頭

©2009-2025 Movatter.jp