Skip to content

[FrameworkBundle] check _controller attribute is a string before parsing it #23457

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 1 commit into from
Jul 11, 2017

Conversation

alekitto
Copy link
Contributor

@alekitto alekitto commented Jul 9, 2017

Q A
Branch? 3.3
Bug fix? yes
New feature? no
BC breaks? no
Deprecations? no
Tests pass? yes
Fixed tickets #23456
License MIT

Avoids an error to be raised in case described in issue #23456.

@@ -51,4 +51,23 @@ public function testSkipsOtherControllerFormats()
$subscriber->onKernelRequest(new GetResponseEvent($httpKernel, $request, HttpKernelInterface::MASTER_REQUEST));
$this->assertEquals('Other:format', $request->attributes->get('_controller'));
}

public function testSkipsNonStringControllers()
Copy link
Contributor

Choose a reason for hiding this comment

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

@alekitto, you could use the data provider to avoid a code duplication. Like this:

/** @dataProvider provideSkippedControllers */
public function testSkipsOtherControllerFormats($controller)
{
    // ...
    $this->assertEquals($controller, $request->attributes->get('_controller'));
}

private function provideSkippedControllers()
{
    yield [ 'Other:format' ];
    yield [ function() {} ];
}

@alekitto alekitto force-pushed the master branch 3 times, most recently from c7385cc to 7f0da59 Compare July 9, 2017 22:32
@alekitto
Copy link
Contributor Author

alekitto commented Jul 9, 2017

@voronkovich Ok, i've added a data provider for this test as requested.

@nicolas-grekas nicolas-grekas changed the title check _controller attribute is a string before parsing it [FrameworkBundle] check _controller attribute is a string before parsing it Jul 10, 2017
Copy link
Member

@nicolas-grekas nicolas-grekas left a comment

Choose a reason for hiding this comment

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

👍 with minor comment

@@ -37,18 +37,27 @@ public function testReplacesControllerAttribute()
$this->assertEquals('App\\Final\\Format::methodName', $request->attributes->get('_controller'));
}

public function testSkipsOtherControllerFormats()
public function provideSkippedControllers()
Copy link
Member

Choose a reason for hiding this comment

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

can you please move it below the test case?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Done.

@nicolas-grekas nicolas-grekas added this to the 3.3 milestone Jul 10, 2017
@nicolas-grekas
Copy link
Member

Thank you @alekitto.

@nicolas-grekas nicolas-grekas merged commit 0b349ae into symfony:3.3 Jul 11, 2017
nicolas-grekas added a commit that referenced this pull request Jul 11, 2017
…before parsing it (alekitto)

This PR was merged into the 3.3 branch.

Discussion
----------

[FrameworkBundle] check _controller attribute is a string before parsing it

| Q             | A
| ------------- | ---
| Branch?       | 3.3
| Bug fix?      | yes
| New feature?  | no
| BC breaks?    | no
| Deprecations? | no
| Tests pass?   | yes
| Fixed tickets | #23456
| License       | MIT

Avoids an error to be raised in case described in issue #23456.

Commits
-------

0b349ae check _controller attribute is a string before parsing it
@fabpot fabpot mentioned this pull request Jul 17, 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