8000 [HttpKernel] Fix exception when serializing request attributes by nicolas-grekas · Pull Request #20621 · symfony/symfony · GitHub
[go: up one dir, main page]

Skip to content

[HttpKernel] Fix exception when serializing request attributes #20621

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
Nov 24, 2016
Merged
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 @@ -87,7 +87,7 @@ private function getTraces(RequestDataCollector $request, $method)
$traceRequest = Request::create(
$request->getPathInfo(),
$request->getRequestServer(true)->get('REQUEST_METHOD'),
$request->getRequestAttributes(true)->all(),
array(),
$request->getRequestCookies(true)->all(),
array(),
$request->getRequestServer(true)->all()
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -127,7 +127,7 @@ public function collect(Request $request, Response $response, \Exception $except
if ('request_headers' === $key || 'response_headers' === $key) {
$value = array_map(function ($v) { return isset($v[1]) ? $v : $v[0]; }, $value);
}
if ('request_server' !== $key && 'request_attributes' !== $key && 'request_cookies' !== $key) {
if ('request_server' !== $key && 'request_cookies' !== $key) {
$this->data[$key] = array_map(array($this, 'cloneVar'), $value);
}
}
Expand Down Expand Up @@ -190,9 +190,9 @@ public function getRequestCookies($raw = false)
return new ParameterBag($raw ? $this->data['request_cookies'] : array_map(array($this, 'cloneVar'), $this->data['request_cookies']));
}

public function getRequestAttributes($raw = false)
public function getRequestAttributes()
{
return new ParameterBag($raw ? $this->data['request_attributes'] : array_map(array($this, 'cloneVar'), $this->data['request_attributes']));
return new ParameterBag($this->data['request_attributes']);
}

public function getResponseHeaders()
Expand Down Expand Up @@ -271,7 +271,17 @@ public function getIdentifier()
*/
public function getRouteParams()
{
return isset($this->data['request_attributes']['_route_params']) ? array_map(array($this, 'cloneVar'), $this->data['request_attributes']['_route_params']) : array();
if (!isset($this->data['request_attributes']['_route_params'])) {
return array();
}

$data = $this->data['request_attributes']['_route_params'];
$params = array();
foreach ($data->getRawData()[1] as $k => $v) {
$params[$k] = $data->seek($k);
}

return $params;
}

/**
Expand Down
$this->assertEquals($cloner->cloneVar($request->attributes->get('resource')), $attributes->get('resource'));
Original file line number Diff line number Diff line change
Expand Up @@ -47,7 +47,7 @@ public function testCollect()
$this->assertInstanceOf('Symfony\Component\HttpFoundation\ParameterBag', $c->getRequestQuery());
$this->assertSame('html', $c->getFormat());
$this->assertEquals('foobar', $c->getRoute());
$this->assertEquals(array('name' => $cloner->cloneVar('foo')), $c->getRouteParams());
$this->assertEquals(array('name' => $cloner->cloneVar(array('name' => 'foo'))->seek('name')), $c->getRouteParams());
$this->assertSame(array(), $c->getSessionAttributes());
$this->assertSame('en', $c->getLocale());
Expand Down
0