Skip to content

Commit

Permalink
[WebProfilerBundle] Always remember the query including the token
Browse files Browse the repository at this point in the history
  • Loading branch information
vicb committed Mar 9, 2011
1 parent 45ff494 commit c9ab593
Show file tree
Hide file tree
Showing 3 changed files with 13 additions and 11 deletions.
Expand Up @@ -162,7 +162,7 @@ public function toolbarAction($token, $position = null)
*
* @return Response A Response instance
*/
public function searchBarAction($token)
public function searchBarAction()
{
$profiler = $this->container->get('profiler');
$profiler->disable();
Expand All @@ -171,6 +171,7 @@ public function searchBarAction($token)
$ip = $session->get('_profiler_search_ip');
$url = $session->get('_profiler_search_url');
$limit = $session->get('_profiler_search_limit');
$token = $session->get('_profiler_search_token');

return $this->container->get('templating')->renderResponse('WebProfilerBundle:Profiler:search.html.twig', array(
'token' => $token,
Expand All @@ -192,14 +193,16 @@ public function searchResultsAction($token)
$profiler = $this->container->get('profiler');
$profiler->disable();

$pofiler = $profiler->loadFromToken($token);

$session = $this->container->get('request')->getSession();
$ip = $session->get('_profiler_search_ip');
$url = $session->get('_profiler_search_url');
$limit = $session->get('_profiler_search_limit');

return $this->container->get('templating')->renderResponse('WebProfilerBundle:Profiler:results.html.twig', array(
'token' => $token,
'profiler' => $this->container->get('profiler')->loadFromToken($token),
'profiler' => $profiler,
'tokens' => $profiler->find($ip, $url, $limit),
'ip' => $ip,
'url' => $url,
Expand All @@ -220,17 +223,16 @@ public function searchAction()

$request = $this->container->get('request');

if ($token = $request->query->get('token')) {
return new RedirectResponse($this->container->get('router')->generate('_profiler', array('token' => $token)));
}

$session = $request->getSession();
$session->set('_profiler_search_ip', $ip = preg_replace('/[^\d\.]/', '', $request->query->get('ip')));
$session->set('_profiler_search_url', $url = $request->query->get('url'));
$session->set('_profiler_search_limit', $limit = $request->query->get('limit'));
$session->set('_profiler_search_token', $token = $request->query->get('token'));

if (!empty($token)) {
return new RedirectResponse($this->container->get('router')->generate('_profiler', array('token' => $token)));
}

$profiler = $this->container->get('profiler');
$profiler->disable();
$tokens = $profiler->find($ip, $url, $limit);

return new RedirectResponse($this->container->get('router')->generate('_profiler_search_results', array('token' => $tokens ? $tokens[0]['token'] : '')));
Expand Down
Expand Up @@ -35,8 +35,8 @@
</ul>
{% endif %}

{% render 'WebProfilerBundle:Profiler:searchBar' with { 'token': token } %}
{% render 'WebProfilerBundle:Profiler:searchBar' %}

{% include 'WebProfilerBundle:Profiler:admin.html.twig' with { 'token': token } only %}

</div>
Expand Down
Expand Up @@ -11,7 +11,7 @@
<input type="text" name="url" id="url" value="{{ url }}" />
<div class="clear_fix"></div>
<label for="token">Token</label>
<input type="text" name="token" id="token" />
<input type="text" name="token" id="token" value="{{ token }}" />
<div class="clear_fix"></div>
<label for="limit">Limit</label>
<select name="limit" id="limit">
Expand Down

0 comments on commit c9ab593

Please sign in to comment.