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

[Routing] Fix BC break in AnnotationClassLoader defaults attributes handling#21379

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
fabpot merged 1 commit intosymfony:2.7fromchalasr:routing/fix-bc-break
Jan 24, 2017

Conversation

@chalasr
Copy link
Member

@chalasrchalasr commentedJan 23, 2017
edited
Loading

QA
Branch?2.7
Bug fix?no
New feature?no
BC breaks?no
Deprecations?no
Tests pass?yes
Fixed tickets77289b9#commitcomment-20572462
LicenseMIT
Doc PRn/a

This fixes a BC break introduced in#21333. Instead of removing the automatic request attributes creation, we keep it but only for attributes that are mandatory (i.e. present in the route path).

Thanks to@iltar for the idea.

@chalasr
Copy link
MemberAuthor

We could still deprecate this feature in 3.3 as it's inconsistent with other loaders, properly defining attributes is always better IMHO.

@linaori
Copy link
Contributor

Can you add a test-case with the(Request $request = null) and a test with a controller like this (viaWebTestCase) to prevent regressions?

What to do about the feature regarding defaults?

  • it should be kept as is
  • it should be removed
  • it should be added to the other loaders as well

@chalasr
Copy link
MemberAuthor

chalasr commentedJan 23, 2017
edited
Loading

What to do about the feature regarding defaults?

IMHO it should be removed, at least not kept as is, switching between two config formats for routing should not break an app.

Can you add a test-case with the (Request $request = null) and a test with a controller like this (via WebTestCase) to prevent regressions?

Sure!
Status: needs work

linaori reacted with thumbs up emoji

@stof
Copy link
Member

IMHO it should be removed, at least not kept as is, switching between two config formats for routing should not break an app.

Removing it makes sense, but it must be done using a deprecation first (so deprecated in 3.3 and removed in 4.0)

@chalasrchalasrforce-pushed therouting/fix-bc-break branch 7 times, most recently from33e78ce tode10ea6CompareJanuary 23, 2017 20:10
@chalasr
Copy link
MemberAuthor

Functional test added. Hope the fix is good, it was not that easy 😄

Status: needs review

@fabpot
Copy link
Member

Not sure we should deprecate the feature, I think it's a nice one.

ogizanagi, robfrawley, and smertius reacted with thumbs up emoji

@chalasr
Copy link
MemberAuthor

I can understand. I'll look at adding it to other formats on 3.3 if you agree

use Symfony\Component\HttpFoundation\Response;
use Symfony\Component\Routing\Annotation\Route;

class AnnotatedController extends ContainerAware
Copy link
MemberAuthor

Choose a reason for hiding this comment

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

It doesn't need the container.

@chalasr
Copy link
MemberAuthor

Build failure is normal (high deps only).

@nicolas-grekasnicolas-grekas added this to the2.7 milestoneJan 24, 2017
@fabpot
Copy link
Member

Thank you@chalasr.

@fabpotfabpot merged commit1d298f0 intosymfony:2.7Jan 24, 2017
fabpot added a commit that referenced this pull requestJan 24, 2017
… attributes handling (chalasr)This PR was merged into the 2.7 branch.Discussion----------[Routing] Fix BC break in AnnotationClassLoader defaults attributes handling| Q             | A| ------------- | ---| Branch?       | 2.7| Bug fix?      | no| New feature?  | no| BC breaks?    | no| Deprecations? | no| Tests pass?   | yes| Fixed tickets |77289b9#commitcomment-20572462| License       | MIT| Doc PR        | n/aThis fixes a BC break introduced in#21333. Instead of removing the automatic request attributes creation, we keep it but only for attributes that are mandatory (i.e. present in the route path).Thanks to@iltar for the idea.Commits-------1d298f0 [Routing] Fix BC break in AnnotationClassLoader defaults attributes handling
@chalasrchalasr deleted the routing/fix-bc-break branchJanuary 24, 2017 18:50
@fabpot
Copy link
Member

This is still a BC break as demonstrated by the tests of FrameworkExtraBundle:https://travis-ci.org/sensiolabs/SensioFrameworkExtraBundle/jobs/197153674

@chalasr Can you have a look at this?

@linaori
Copy link
Contributor

/**     * @Route("/simple/multiple/{a}/{b}/")     * @Template("@Foo/Simple/some.html.twig")     */publicfunctionsomeMoreAction($a,$b,$c ='c')    {    }

expectation ishenk, bar, c as{c} is not provided. Result ishenk, bar,.$c appears to be empty while it should getc as value.

@chalasr
Copy link
MemberAuthor

I'll look into it.

@chalasr
Copy link
MemberAuthor

chalasr commentedFeb 1, 2017
edited
Loading

Reproduced on our test case in 2.7 and 3.3 (master...chalasr:reproduce-sensioextra-test) all is fine for argument resolving.

The bottleneck seems to be in theTemplate annotation handling which relies on request attributes to resolve template vars:https://github.com/sensiolabs/SensioFrameworkExtraBundle/blob/3.0/EventListener/TemplateListener.php#L153.
Since we no longer set request attributes for arguments that are not expected in the route path (because it was buggy), the test is failing.
I think it should be solved on the SensioFrameworkExtraBundle by making it inject vars from both request attributes and method argument defaults.
Let me know what do you think, anyway I'll open a PR on SensioFrameworkExtraBundle later today so you can judge.

@chalasr
Copy link
MemberAuthor

fabpot added a commit to sensiolabs/SensioFrameworkExtraBundle that referenced this pull requestFeb 1, 2017
This PR was merged into the 3.0 branch.Discussion----------Fix default vars resolution for Template annotationFixes broken `@Template` default vars resolution which was relying on a buggy behaviorfixedsymfony/symfony#21379 (the annotation class loader no longer sets request attributes for any argument that has a default value, but only for ones which may be expected in the route path).Commits-------9ddf58a Fix default vars resolution for Template annotation
Sign up for freeto join this conversation on GitHub. Already have an account?Sign in to comment

Reviewers

No reviews

Assignees

No one assigned

Projects

None yet

Milestone

2.7

Development

Successfully merging this pull request may close these issues.

6 participants

@chalasr@linaori@stof@fabpot@nicolas-grekas@carsonbot

[8]ページ先頭

©2009-2025 Movatter.jp