-
-
Notifications
You must be signed in to change notification settings - Fork 9.6k
[3.2][HttpKernel] Fix rendering route params in WDT #20571
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
👍 I can confirm this error in 3.2.0-rc1 ... and I can also confirm that the proposed change fixes the error. Thanks @ro0NL!! |
@@ -63,6 +64,10 @@ public function collect(Request $request, Response $response, \Exception $except | |||
if ('_route' === $key) { | |||
$route = is_object($value) ? $value->getPath() : $value; | |||
} | |||
|
|||
if ('_route_params' === $key && is_array($value)) { | |||
$routeParams = $value; |
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 we clone $value
here to get a nicer output?
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.
Well.. that's what broke it before :)) The value is passed to table.html.twig
(if is empty
passes) which uses profiler_dump
already.
We could wrap the array in a ParameterBag
(seems consistent..) and use bag.html.twig
, but it's the same result and probably a BC break for getRouteParams
.
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.
I agree with @wouterj , here is the patch (fixing session data display meanwhile):
diff --git a/src/Symfony/Component/HttpKernel/DataCollector/RequestDataCollector.php b/src/Symfony/Component/HttpKernel/DataCollector/RequestDataCollector.php
index f0c18c5..7bcd77a 100644
--- a/src/Symfony/Component/HttpKernel/DataCollector/RequestDataCollector.php
+++ b/src/Symfony/Component/HttpKernel/DataCollector/RequestDataCollector.php
@@ -56,6 +56,10 @@ class RequestDataCollector extends DataCollector implements EventSubscriberInter
foreach ($request->attributes->all() as $key => $value) {
if ('_route' === $key && is_object($value)) {
$attributes[$key] = $this->cloneVar($value->getPath());
+ } elseif ('_route_params' === $key) {
+ foreach ($value as $k => $v) {
+ $attributes[$key][$k] = $this->cloneVar($v);
+ }
} else {
$attributes[$key] = $this->cloneVar($value);
}
@@ -83,7 +87,9 @@ class RequestDataCollector extends DataCollector implements EventSubscriberInter
$sessionMetadata['Created'] = date(DATE_RFC822, $session->getMetadataBag()->getCreated());
$sessionMetadata['Last used'] = date(DATE_RFC822, $session->getMetadataBag()->getLastUsed());
$sessionMetadata['Lifetime'] = $session->getMetadataBag()->getLifetime();
- $sessionAttributes = $session->all();
+ foreach ($session->all() as $k => $v) {
+ $sessionAttributes[$k] = $this->cloneVar($v);
+ }
$flashes = $session->getFlashBag()->peekAll();
}
}
@@ -264,7 +270,7 @@ class RequestDataCollector extends DataCollector implements EventSubscriberInter
*/
public function getRouteParams()
{
- return isset($this->data['request_attributes']['_route_params']) ? $this->data['request_attributes']['_route_params'] : $this->cloneVar(array());
+ return isset($this->data['request_attributes']['_route_params']) ? $this->data['request_attributes']['_route_params'] : array();
}
/**
diff --git a/src/Symfony/Component/HttpKernel/Tests/DataCollector/RequestDataCollectorTest.php b/src/Symfony/Component/HttpKernel/Tests/DataCollector/RequestDataCollectorTest.php
index 2ae1c5c..be24ea9 100644
--- a/src/Symfony/Component/HttpKernel/Tests/DataCollector/RequestDataCollectorTest.php
+++ b/src/Symfony/Component/HttpKernel/Tests/DataCollector/RequestDataCollectorTest.php
@@ -47,7 +47,7 @@ class RequestDataCollectorTest extends \PHPUnit_Framework_TestCase
$this->assertInstanceOf('Symfony\Component\HttpFoundation\ParameterBag', $c->getRequestQuery());
$this->assertSame('html', $c->getFormat());
$this->assertEquals('foobar', $c->getRoute());
- $this->assertEquals($cloner->cloneVar(array('name' => 'foo')), $c->getRouteParams());
+ $this->assertEquals(array('name' => $cloner->cloneVar('foo')), $c->getRouteParams());
$this->assertSame(array(), $c->getSessionAttributes());
$this->assertSame('en', $c->getLocale());
$this->assertEquals($cloner->cloneVar($request->attributes->get('resource')), $attributes->get('resource'));
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.
@nicolas-grekas now the request attributes break 😭
Not sure we can support this with only 1 structural value..
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.
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.
Last commit fixes both request attributes as route attributes, in terms of looking great.
@javiereguiluz ill have a look.
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.
Hmz not sure where to begin or how that affects this PR change. Maybe @nicolas-grekas can give a heads up.
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.
give me a few minutes, patch coming :)
@javiereguiluz the ellipsis on AppBundle is not specific to this screenshot, and depends on the actual font in use I'd say. |
@@ -83,6 +90,9 @@ public function collect(Request $request, Response $response, \Exception $except | |||
$sessionMetadata['Created'] = date(DATE_RFC822, $session->getMetadataBag()->getCreated()); | |||
$sessionMetadata['Last used'] = date(DATE_RFC822, $session->getMetadataBag()->getLastUsed()); | |||
$sessionMetadata['Lifetime'] = $session->getMetadataBag()->getLifetime(); | |||
foreach ($sessionAttributes as $key => $value) { |
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.
this should be foreach ($session->all() as $key => $value) {
right now, $sessionAttributes is always empty, isn't it?
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.
Derp. Yes.
Looks like appveyor doesn't like the patch :( |
Hmz it seems to fail due
https://ci.appveyor.com/project/fabpot/symfony/build/1.0.14541#L1044 I can have a look tomorrow.. otherwise perhaps revert the session prettifying? |
calling profiler_dump with anything else than a Data object is deprecated. That's another reason why we need to "clone" session data. |
Which makes me figure out there are much more deprecations to fix. I'm on it. |
Side note: please mind your commit messages, especially the first one. Should match the PR title. |
I ended up with a too big patch, so I created a new PR that should supersede this one: #20595 |
👍 closing in favor of #20595 Could cherry-pick the original commits first next time? Now my credits are gone :)) which i dont mind.. but still ;-) |
…nicolas-grekas) This PR was merged into the 3.2 branch. Discussion ---------- [WebProfilerBundle] Fix deprecated uses of profiler_dump | Q | A | ------------- | --- | Branch? | 3.2 | Bug fix? | yes | New feature? | no | BC breaks? | no | Deprecations? | no | Tests pass? | yes | Fixed tickets | - | License | MIT | Doc PR | - Replaces #20571 that made me realize that we completely missed updating the "Request / Response" panel that is current triggering a bunch of deprecation notices about profiler_dump. Yet, these notices triggered by the profiler are not displayed anywhere (what, we don't have a profiler for the profiler? :) ). And we missed them. Commits ------- b4c327d [WebProfilerBundle] Fix deprecated uses of profiler_dump
The route parameters are not rendered in 3.2 in the WDT (routing panel) as
is empty
in twig fails on aData
object. This preserves the array type.With or without params.
See also https://github.com/symfony/symfony/pull/19614/files#diff-e8f5b14fbfbbeac60fc9f3abe310c3b0L59