-
-
Notifications
You must be signed in to change notification settings - Fork 9.7k
[WebProfilerBundle] Fix deprecated uses of profiler_dump #20595
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
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -12,10 +12,8 @@ | |
namespace Symfony\Component\HttpKernel\DataCollector; | ||
|
||
use Symfony\Component\HttpFoundation\ParameterBag; | ||
use Symfony\Component\HttpFoundation\HeaderBag; | ||
use Symfony\Component\HttpFoundation\Request; | ||
use Symfony\Component\HttpFoundation\Response; | ||
use Symfony\Component\HttpFoundation\ResponseHeaderBag; | ||
use Symfony\Component\HttpKernel\Event\FilterResponseEvent; | ||
use Symfony\Component\HttpKernel\KernelEvents; | ||
use Symfony\Component\HttpKernel\Event\FilterControllerEvent; | ||
|
@@ -54,14 +52,11 @@ public function collect(Request $request, Response $response, \Exception $except | |
$attributes = array(); | ||
$route = ''; | ||
foreach ($request->attributes->all() as $key => $value) { | ||
if ('_route' === $key && is_object($value)) { | ||
$attributes[$key] = $this->cloneVar($value->getPath()); | ||
} else { | ||
$attributes[$key] = $this->cloneVar($value); | ||
} | ||
|
||
if ('_route' === $key) { | ||
$route = is_object($value) ? $value->getPath() : $value; | ||
$attributes[$key] = $route; | ||
} else { | ||
$attributes[$key] = $value; | ||
} | ||
} | ||
|
||
|
@@ -97,8 +92,8 @@ public function collect(Request $request, Response $response, \Exception $except | |
'content_type' => $response->headers->get('Content-Type', 'text/html'), | ||
'status_text' => isset(Response::$statusTexts[$statusCode]) ? Response::$statusTexts[$statusCode] : '', | ||
'status_code' => $statusCode, | ||
'request_query' => array_map(array($this, 'cloneVar'), $request->query->all()), | ||
'request_request' => array_map(array($this, 'cloneVar'), $request->request->all()), | ||
'request_query' => $request->query->all(), | ||
'request_request' => $request->request->all(), | ||
'request_headers' => $request->headers->all(), | ||
'request_server' => $request->server->all(), | ||
'request_cookies' => $request->cookies->all(), | ||
|
@@ -125,6 +120,18 @@ public function collect(Request $request, Response $response, \Exception $except | |
$this->data['request_request']['_password'] = '******'; | ||
} | ||
|
||
foreach ($this->data as $key => $value) { | ||
if (!is_array($value)) { | ||
continue; | ||
} | ||
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) { | ||
$this->data[$key] = array_map(array($this, 'cloneVar'), $value); | ||
} | ||
} | ||
|
||
if (isset($this->controllers[$request])) { | ||
$this->data['controller'] = $this->parseController($this->controllers[$request]); | ||
unset($this->controllers[$request]); | ||
|
@@ -170,27 +177,27 @@ public function getRequestQuery() | |
|
||
public function getRequestHeaders() | ||
{ | ||
return new HeaderBag($this->data['request_headers']); | ||
return new ParameterBag($this->data['request_headers']); | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. We are sure this breaks nothing right? In terms of possible unknown method calls by now (see also There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. As decided in previous PRs about the profiler internals, we don't want to preserve bc here, that would slow us too much. There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I was more thinking about references in core templates ;) but i guess were fine. |
||
} | ||
|
||
public function getRequestServer() | ||
public function getRequestServer($raw = false) | ||
{ | ||
return new ParameterBag($this->data['request_server']); | ||
return new ParameterBag($raw ? $this->data['request_server'] : array_map(array($this, 'cloneVar'), $this->data['request_server'])); | ||
} | ||
|
||
public function getRequestCookies() | ||
public function getRequestCookies($raw = false) | ||
{ | ||
return new ParameterBag($this->data['request_cookies']); | ||
return new ParameterBag($raw ? $this->data['request_cookies'] : array_map(array($this, 'cloneVar'), $this->data['request_cookies'])); | ||
} | ||
|
||
public function getRequestAttributes() | ||
public function getRequestAttributes($raw = false) | ||
{ | ||
return new ParameterBag($this->data['request_attributes']); | ||
return new ParameterBag($raw ? $this->data['request_attributes'] : array_map(array($this, 'cloneVar'), $this->data['request_attributes'])); | ||
} | ||
|
||
public function getResponseHeaders() | ||
{ | ||
return new ResponseHeaderBag($this->data['response_headers']); | ||
return new ParameterBag($this->data['response_headers']); | ||
} | ||
|
||
public function getSessionMetadata() | ||
|
@@ -264,7 +271,7 @@ public function getIdentifier() | |
*/ | ||
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']) ? array_map(array($this, 'cloneVar'), $this->data['request_attributes']['_route_params']) : array(); | ||
} | ||
|
||
/** | ||
|
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.
We could consider adding
cloneArray/Iterable
by now ;-)