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

Appearance settings

[HttpKernel] Make the behaviour of surrogate renderers consistent in all environments #16283

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 1 commit into from
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -64,6 +64,10 @@ public function __construct(SurrogateInterface $surrogate = null, FragmentRender
public function render($uri, Request $request, array $options = array())
{
if (!$this->surrogate || !$this->surrogate->hasSurrogateCapability($request)) {
if ($uri instanceof ControllerReference) {
$this->checkNonScalar($uri->attributes);
Copy link
Contributor Author

Choose a reason for hiding this comment

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

Instead of making checkNonScalar() protected in order to call it here, we could generate the uri instead:

if ($uri instanceof ControllerReference) {
    $uri = $this->generateFragmentUri($uri, $request, false, true);
}

return $this->inlineStrategy->render($uri, $request, $options);

This way, however, _locale and _format might not be passed properly as the following code in the InlineFragmentRenderer wouldn't be called:

foreach (array('_format', '_locale') as $key) {
    if (isset($attributes[$key])) {
        $reference->attributes[$key] = $attributes[$key];
    }
}

I'm not sure if this is an issue. Perhaps it'd actually be good, if we're trying to make the dev/non-dev behaviour consistent for surrogate renderers.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Any thoughts on this?

Copy link
Member

Choose a reason for hiding this comment

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

I prefer your current solution. This looks good to me.

}

return $this->inlineStrategy->render($uri, $request, $options);
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -77,7 +77,10 @@ protected function generateFragmentUri(ControllerReference $reference, Request $
return $request->getBaseUrl().$path;
}

private function checkNonScalar($values)
/**
* @internal
*/
protected function checkNonScalar(array $values)
Copy link
Member

Choose a reason for hiding this comment

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

I would mark it as @internal then.

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.

{
foreach ($values as $key => $value) {
if (is_array($value)) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -90,6 +90,20 @@ public function testRenderAltControllerReferenceWithoutSignerThrowsException()
$strategy->render('/', $request, array('alt' => new ControllerReference('alt_controller')));
}

/**
* @expectedException \LogicException
*/
public function testRenderFallbackWithObjectAttributesThrowsException()
{
$strategy = new EsiFragmentRenderer(new Esi(), $this->getInlineStrategy(), new UriSigner('foo'));

$request = Request::create('/');

$reference = new ControllerReference('main_controller', array('foo' => new \stdClass()), array());

$strategy->render($reference, $request);
}

private function getInlineStrategy($called = false)
{
$inline = $this->getMockBuilder('Symfony\Component\HttpKernel\Fragment\InlineFragmentRenderer')->disableOriginalConstructor()->getMock();
Expand Down
Morty Proxy This is a proxified and sanitized view of the page, visit original site.