-
-
Notifications
You must be signed in to change notification settings - Fork 9.7k
[HttpKernel] changed the fragment handler to explicitely disallow non-scalar in generated URIs (refs #8263) #8437
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
Conversation
@@ -56,4 +61,17 @@ protected function generateFragmentUri(ControllerReference $reference, Request $ | |||
|
|||
return $request->getUriForPath($this->fragmentPath.'?'.http_build_query($reference->query, '', '&')); | |||
} | |||
|
|||
private function checkNonScalar($values) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
shouldn't this be typehinted as array ?
…-scalar in generated URIs (refs symfony#8263)
} | ||
|
||
if (!is_scalar($value)) { | ||
throw new \LogicException('Controller attributes cannot contain non-scalar values.'); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Can you add the "key" of the value to message ? It will be easier to debug with it.
…rks for inline controllers
if (is_array($value)) { | ||
$this->checkNonScalar($value); | ||
} elseif (!is_scalar($value)) { | ||
throw new \LogicException(sprintf('Controller attributes cannot contain non-scalar values (value for key "%s" is not a scalar).', $key)); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Maybe also add gettype($value)
to show the actual type passed
This PR was merged into the master branch. Discussion ---------- [HttpKernel] changed the fragment handler to explicitely disallow non-scalar in generated URIs (refs #8263) | Q | A | ------------- | --- | Bug fix? | no | New feature? | yes | BC breaks? | no | Deprecations? | no | Tests pass? | yes | Fixed tickets | #8263 | License | MIT | Doc PR | n/a When using the `render()` function in Twig with a `controller()` reference, the attributes can contain non-scalar. That's fine for the inline strategy, but it cannot work for other strategies as it then involves a proper HTTP request. So, this PR properly throw an exception in such situations to avoid difficult to find bugs. Commits ------- 43ce368 [HttpKernel] added a unit test to demonstrate that passing objects works for inline controllers 70f3399 [HttpKernel] changed the fragment handler to explicitely disallow non-scalar in generated URIs (refs #8263)
Could this be merged to 2.3 branch ? Thanks |
New features are never backported to older versions. Your issue here is that you are using in the class in a way which is not covered by our BC promise: http://symfony.com/bc |
When using the
render()
function in Twig with acontroller()
reference, the attributes can contain non-scalar. That's fine for the inline strategy, but it cannot work for other strategies as it then involves a proper HTTP request.So, this PR properly throw an exception in such situations to avoid difficult to find bugs.