10000 bug #50218 Profiler respect stateless attribute (alamirault) · symfony/symfony@78a26b4 · GitHub
[go: up one dir, main page]

Skip to content

Commit 78a26b4

Browse files
committed
bug #50218 Profiler respect stateless attribute (alamirault)
This PR was merged into the 6.3 branch. Discussion ---------- Profiler respect stateless attribute | Q | A | ------------- | --- | Branch? | 6.3 | Bug fix? | yes | New feature? | no <!-- please update src/**/CHANGELOG.md files --> | Deprecations? | no <!-- please update UPGRADE-*.md and src/**/CHANGELOG.md files --> | Tickets | Fix #50037 | License | MIT | Doc PR | symfony/symfony-docs#... <!-- required for new features --> Now that #50198 forward `_stateless` attribute in fragments, this PR check this attribute and make profiler stateless when is required. I don't know which tests I have to add because session is not checked. (I checked on reproducer and it's ok) Commits ------- 7820776 [WebProfilerBundle] Profiler respect stateless attribute
2 parents e498b54 + 7820776 commit 78a26b4

File tree

1 file changed

+9
-3
lines changed

1 file changed

+9
-3
lines changed

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

Lines changed: 9 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -128,7 +128,9 @@ public function toolbarAction(Request $request, string $token = null): Response
128128
throw new NotFoundHttpException('The profiler must be enabled.');
129129
}
130130

131-
if ($request->hasSession() && ($session = $request->getSession())->isStarted() && $session->getFlashBag() instanceof AutoExpireFlashBag) {
131+
if (!$request->attributes->getBoolean('_stateless') && $request->hasSession()
132+
&& ($session = $request->getSession())->isStarted() && $session->getFlashBag() instanceof AutoExpireFlashBag
133+
) {
132134
// keep current flashes for one more request if using AutoExpireFlashBag
133135
$session->getFlashBag()->setAll($session->getFlashBag()->peekAll());
134136
}
@@ -172,7 +174,11 @@ public function searchBarAction(Request $request): Response
172174

173175
$this->cspHandler?->disableCsp();
174176

175-
$session = $request->hasSession() ? $request->getSession() : null;
177+
178+
$session = null;
179+
if ($request->attributes->getBoolean('_stateless') && $request->hasSession()) {
180+
$session = $request->getSession();
181+
}
176182

177183
return new Response(
178184
$this->twig->render('@WebProfiler/Profiler/search.html.twig', [
@@ -247,7 +253,7 @@ public function searchAction(Request $request): Response
247253
$limit = $request->query->get('limit');
248254
$token = $request->query->get('token');
249255

250-
if ($request->hasSession()) {
256+
if (!$request->attributes->getBoolean('_stateless') && $request->hasSession()) {
251257
$session = $request->getSession();
252258

253259
$session->set('_profiler_search_ip', $ip);

0 commit comments

Comments
 (0)
0