Skip to content

Commit fd92e9f

Browse files
[HttpKernel] Fix exception when serializing request attributes
1 parent 1df5e7f commit fd92e9f

File tree

2 files changed

+15
-5
lines changed

2 files changed

+15
-5
lines changed

src/Symfony/Bundle/WebProfilerBundle/Controller/RouterController.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -87,7 +87,7 @@ private function getTraces(RequestDataCollector $request, $method)
8787
$traceRequest = Request::create(
8888
$request->getPathInfo(),
8989
$request->getRequestServer(true)->get('REQUEST_METHOD'),
90-
$request->getRequestAttributes(true)->all(),
90+
array(),
9191
$request->getRequestCookies(true)->all(),
9292
array(),
9393
$request->getRequestServer(true)->all()

src/Symfony/Component/HttpKernel/DataCollector/RequestDataCollector.php

Lines changed: 14 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -127,7 +127,7 @@ public function collect(Request $request, Response $response, \Exception $except
127127
if ('request_headers' === $key || 'response_headers' === $key) {
128128
$value = array_map(function ($v) { return isset($v[1]) ? $v : $v[0]; }, $value);
129129
}
130-
if ('request_server' !== $key && 'request_attributes' !== $key && 'request_cookies' !== $key) {
130+
if ('request_server' !== $key && 'request_cookies' !== $key) {
131131
$this->data[$key] = array_map(array($this, 'cloneVar'), $value);
132132
}
133133
}
@@ -190,9 +190,9 @@ public function getRequestCookies($raw = false)
190190
return new ParameterBag($raw ? $this->data['request_cookies'] : array_map(array($this, 'cloneVar'), $this->data['request_cookies']));
191191
}
192192

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

198198
public function getResponseHeaders()
@@ -271,7 +271,17 @@ public function getIdentifier()
271271
*/
272272
public function getRouteParams()
273273
{
274-
return isset($this->data['request_attributes']['_route_params']) ? array_map(array($this, 'cloneVar'), $this->data['request_attributes']['_route_params']) : array();
274+
if (!isset($this->data['request_attributes']['_route_params'])) {
275+
return array();
276+
}
277+
278+
$data = $this->data['request_attributes']['_route_params'];
279+
$params = array();
280+
foreach ($data->getRawData()[1] as $k => $v) {
281+
$params[$k] = $data->seek($k);
282+
}
283+
284+
return $params;
275285
}
276286

277287
/**

0 commit comments

Comments
 (0)