Skip to content

Avoid using the app global variable in the profiler templates #14777

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
May 29, 2015
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 @@ -11,6 +11,7 @@

namespace Symfony\Bundle\WebProfilerBundle\EventListener;

use Symfony\Component\HttpFoundation\Request;
use Symfony\Component\HttpFoundation\Response;
use Symfony\Component\HttpFoundation\Session\Flash\AutoExpireFlashBag;
use Symfony\Component\HttpKernel\Event\FilterResponseEvent;
Expand Down Expand Up @@ -101,15 +102,15 @@ public function onKernelResponse(FilterResponseEvent $event)
return;
}

$this->injectToolbar($response);
$this->injectToolbar($response, $request);
}

/**
* Injects the web debug toolbar into the given Response.
*
* @param Response $response A Response instance
*/
protected function injectToolbar(Response $response)
protected function injectToolbar(Response $response, Request $request)
{
$content = $response->getContent();
$pos = strripos($content, '</body>');
Expand All @@ -121,6 +122,7 @@ protected function injectToolbar(Response $response)
'position' => $this->position,
'excluded_ajax_paths' => $this->excludedAjaxPaths,
'token' => $response->headers->get('X-Debug-Token'),
'request' => $request,
)
))."\n";
$content = substr($content, 0, $pos).$toolbar.substr($content, $pos);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -205,12 +205,12 @@
/* prevent logging AJAX calls to static and inline files, like templates */
var path = url;
if (url.substr(0, 1) === '/') {
if (0 === url.indexOf('{{ app.request.basePath|e('js') }}')) {
path = url.substr({{ app.request.basePath|length }});
if (0 === url.indexOf('{{ request.basePath|e('js') }}')) {
path = url.substr({{ request.basePath|length }});
}
}
else if (0 === url.indexOf('{{ (app.request.schemeAndHttpHost ~ app.request.basePath)|e('js') }}')) {
path = url.substr({{ (app.request.schemeAndHttpHost ~ app.request.basePath)|length }});
else if (0 === url.indexOf('{{ (request.schemeAndHttpHost ~ request.basePath)|e('js') }}')) {
path = url.substr({{ (request.schemeAndHttpHost ~ request.basePath)|length }});
}

if (path.substr(0, 1) === '/' && !path.match(new RegExp({{ excluded_ajax_paths|json_encode|raw }}))) {
Expand Down