Skip to content

Commit 9a60db0

Browse files
bug symfony#57679 [WebProfilerBundle] Change incorrect check for the stateless request attribute (themasch)
This PR was merged into the 6.4 branch. Discussion ---------- [WebProfilerBundle] Change incorrect check for the `stateless` request attribute | Q | A | ------------- | --- | Branch? | 6.4 | Bug fix? | yes | New feature? | no <!-- please update src/**/CHANGELOG.md files --> | Deprecations? | no | Issues | | License | MIT When upgrading our project from 5.4 to 6.4 (yep..we're late) we encountered an "Session was used while the request was declared stateless." exception when opening the profiler. Our `main` firewall sets `stateless: true` as its only used for API requests (and the profiler). Debugging to find what caused the session to be initialized I ended up in the `ProfilerController::searchBarAction`, which gets the session *only if the `_stateless` attribute is `true`*. According to my understanding an the discussion here https://github.com/symfony/symfony/pull/50218/files#r1668401248 this seems to be incorrect. We only want to use the session if the request is **not** `stateless`. Commits ------- 92093b9 Change incorrect check for the `stateless` request attribute
2 parents 2faff1c + 92093b9 commit 9a60db0

File tree

1 file changed

+1
-1
lines changed

1 file changed

+1
-1
lines changed

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

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -180,7 +180,7 @@ public function searchBarAction(Request $request): Response
180180
$this->cspHandler?->disableCsp();
181181

182182
$session = null;
183-
if ($request->attributes->getBoolean('_stateless') && $request->hasSession()) {
183+
if (!$request->attributes->getBoolean('_stateless') && $request->hasSession()) {
184184
$session = $request->getSession();
185185
}
186186

0 commit comments

Comments
 (0)