Skip to content

[Routing] Fix resource miss #24642

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

Closed
wants to merge 2 commits into from
Closed

Conversation

dunglas
Copy link
Member

@dunglas dunglas commented Oct 20, 2017

Q A
Branch? 2.8
Bug fix? yes
New feature? no
BC breaks? no
Deprecations? no
Tests pass? yes
Fixed tickets n/a
License MIT
Doc PR n/a

Some routing resources are not watched. To reproduce:

  1. Install Symfony 4
  2. Change something in config/routes.yaml

The change is not taken into account.

This PR fixes this bug.

@dunglas dunglas force-pushed the fix-router-resource branch from 1e00afb to 1dd4f8f Compare October 20, 2017 07:45
@@ -311,6 +311,9 @@ public function build()
$subCollection->addPrefix($this->prefix);

$routeCollection->addCollection($subCollection);
foreach ($route->resources as $resource) {
Copy link
Member

Choose a reason for hiding this comment

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

shouldn't this be handled by $routeCollection->addCollection instead ?

Copy link
Member Author

Choose a reason for hiding this comment

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

This doesn't work because $route->build() (https://github.com/symfony/symfony/pull/24642/files#diff-61a7c46324774b76b342efb3f3e87b7fL310) doesn't add sub-resources to $subCollection. This is exactly what this patch fix.

Copy link
Member

Choose a reason for hiding this comment

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

it is adding them just a few lines below in this code.

Copy link
Contributor

Choose a reason for hiding this comment

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

$route->resources vs $this->resources

Copy link
Contributor

Choose a reason for hiding this comment

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

While you are on this file... it looks like nothing calls the private method addResource, so maybe you can remove the resources property of that class, as well as the loop "below".

Copy link
Member

Choose a reason for hiding this comment

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

sure. But the loop below happens inside ->build() and so the subcollection will have the resources in it if it has any.

Copy link
Member Author

Choose a reason for hiding this comment

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

But it’s not the case (the new test fail without my patch). I’ll Investigate this afternoon.

Copy link
Member Author

Choose a reason for hiding this comment

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

I double checked and pushed a better fix:

$route can have resources but no routes. So the loop over $this->resources must be outside the loop on $this->routes.

Can you check if it's ok @stof?

@fabpot
Copy link
Member

fabpot commented Oct 20, 2017

Thank you @dunglas.

fabpot added a commit that referenced this pull request Oct 20, 2017
This PR was squashed before being merged into the 2.8 branch (closes #24642).

Discussion
----------

[Routing] Fix resource miss

| Q             | A
| ------------- | ---
| Branch?       | 2.8
| Bug fix?      | yes
| New feature?  | no <!-- don't forget to update src/**/CHANGELOG.md files -->
| BC breaks?    | no
| Deprecations? | no <!-- don't forget to update UPGRADE-*.md files -->
| Tests pass?   | yes
| Fixed tickets | n/a
| License       | MIT
| Doc PR        | n/a

Some routing resources are not watched. To reproduce:

1. Install Symfony 4
2. Change something in `config/routes.yaml`

The change is not taken into account.

This PR fixes this bug.

Commits
-------

6610c25 [Routing] Fix resource miss
@fabpot fabpot closed this Oct 20, 2017
This was referenced Oct 30, 2017
This was referenced Nov 10, 2017
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

6 participants