8000 [HttpKernel] Disable session tracking while collecting profiler data · symfony/symfony@2ad3f30 · GitHub
[go: up one dir, main page]

Skip to content

Commit 2ad3f30

Browse files
[HttpKernel] Disable session tracking while collecting profiler data
1 parent e94f1f6 commit 2ad3f30

File tree

1 file changed

+17
-2
lines changed

1 file changed

+17
-2
lines changed

src/Symfony/Component/HttpKernel/EventListener/ProfilerListener.php

Lines changed: 17 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -12,8 +12,10 @@
1212
namespace Symfony\Component\HttpKernel\EventListener;
1313

1414
use Symfony\Component\EventDispatcher\EventSubscriberInterface;
15+
use Symfony\Component\HttpFoundation\Request;
1516
use Symfony\Component\HttpFoundation\RequestMatcherInterface;
1617
use Symfony\Component\HttpFoundation\RequestStack;
18+
use Symfony\Component\HttpFoundation\Session\Session;
1719
use Symfony\Component\HttpKernel\Event\FilterResponseEvent;
1820
use Symfony\Component\HttpKernel\Event\GetResponseForExceptionEvent;
1921
use Symfony\Component\HttpKernel\Event\PostResponseEvent;
@@ -87,8 +89,21 @@ public function onKernelResponse(FilterResponseEvent $event)
8789
return;
8890
}
8991

90-
if (!$profile = $this->profiler->collect($request, $event->getResponse(), $exception)) {
91-
return;
92+
$session = method_exists(Request::class, 'getPreferredFormat') && $request->hasPreviousSession() && $request->hasSession() ? $request->getSession() : null;
93+
94+
if ($session instanceof Session) {
95+
$usageIndexValue = $usageIndexReference = &$session->getUsageIndex();
96+
$usageIndexReference = \PHP_INT_MIN;
97+
}
98+
99+
try {
100+
if (!$profile = $this->profiler->collect($request, $event->getResponse(), $exception)) {
101+
return;
102+
}
103+
} finally {
104+
if ($session instanceof Session) {
105+
$usageIndexReference = $usageIndexValue;
106+
}
92107
}
93108

94109
$this->profiles[$request] = $profile;

0 commit comments

Comments
 (0)
0