Skip to content

[Routing] Fix "config-file-relative" annotation loader resources #25113

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

Merged
merged 2 commits into from
Nov 24, 2017

Conversation

nicolas-grekas
Copy link
Member

@nicolas-grekas nicolas-grekas commented Nov 22, 2017

Q A
Branch? 3.4
Bug fix? yes
New feature? no
BC breaks? slight behavior change
Deprecations? no
Tests pass? yes
Fixed tickets -
License MIT
Doc PR -

By using the locator in its supports() method, the AnnotationDirectoryLoader breaks config-relative annotation resources. The workaround is to fallback on kernel.root_dir-relative paths, as done in https://github.com/symfony/recipes/blob/master/doctrine/annotations/1.0/config/routes/annotations.yaml
But as you can see, this is rather WTF: extra knowledge is required to know what to type there. All the other loader look relatively to the config file first.

This is a bug, but since this is a slight behavior change, I think it's best to merge it on 3.4.

@nicolas-grekas
Copy link
Member Author

See symfony/recipes#272 for a corresponding recipe (verified locally.)

@nicolas-grekas
Copy link
Member Author

nicolas-grekas commented Nov 22, 2017

Note that it would be great to deprecate using the locator at all in supports(), but 3.4 is now closed for deprecations, so should/could happen on master only.

@sroze
Copy link
Contributor

sroze commented Nov 23, 2017

Can you add some tests for that?

@fabpot
Copy link
Member

fabpot commented Nov 23, 2017

This one makes is difficult (read impossible) to have a config that works on 3.3 and 3.4/4.0 (cf. the changed recipe).

@nicolas-grekas
Copy link
Member Author

The current config that works will continue to work. I'm now rebasing on 3.3 as bug fix, so that Flex+3.3 can get the good DX config.

@nicolas-grekas nicolas-grekas changed the base branch from 3.4 to 3.3 November 23, 2017 13:59
@nicolas-grekas
Copy link
Member Author

rebased on 3.3

@nicolas-grekas nicolas-grekas modified the milestones: 3.4, 3.3 Nov 23, 2017
@sroze
Copy link
Contributor

sroze commented Nov 24, 2017

And we even have tests now 👍

@nicolas-grekas
Copy link
Member Author

Thank you @sroze.

@nicolas-grekas nicolas-grekas merged commit f4999d8 into symfony:3.3 Nov 24, 2017
nicolas-grekas added a commit that referenced this pull request Nov 24, 2017
…ources (nicolas-grekas, sroze)

This PR was merged into the 3.3 branch.

Discussion
----------

[Routing] Fix "config-file-relative" annotation loader resources

| Q             | A
| ------------- | ---
| Branch?       | 3.4
| Bug fix?      | yes
| New feature?  | no
| BC breaks?    | slight behavior change
| Deprecations? | no
| Tests pass?   | yes
| Fixed tickets | -
| License       | MIT
| Doc PR        | -

By using the locator in its `supports()` method, the `AnnotationDirectoryLoader` breaks config-relative annotation resources. The workaround is to fallback on `kernel.root_dir`-relative paths, as done in https://github.com/symfony/recipes/blob/master/doctrine/annotations/1.0/config/routes/annotations.yaml
But as you can see, this is rather WTF: extra knowledge is required to know what to type there. All the other loader look relatively to the config file first.

This is a bug, but since this is a slight behavior change, I think it's best to merge it on 3.4.

Commits
-------

f4999d8 Add tests proving it can load annotated files
5998e9d [Routing] Fix "config-file-relative" annotation loader resources
@nicolas-grekas nicolas-grekas deleted the locator branch November 24, 2017 11:34
This was referenced Nov 24, 2017
@fabpot fabpot mentioned this pull request Dec 4, 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.

5 participants