Skip to content

[HttpFoundation] Add Request::isStateless method #57852

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

Closed
wants to merge 7 commits into from
Closed
Show file tree
Hide file tree
Changes from 1 commit
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
Prev Previous commit
Keep has check
  • Loading branch information
VincentLanglet committed Aug 13, 2024
commit 9685160f2a48e634ef77ffb47b0ba8b6a77b6a51
Original file line number Diff line number Diff line change
Expand Up @@ -66,7 +66,7 @@ private function getFirewallContext(Request $request): ?FirewallContext
/** @var FirewallContext $context */
$context = $this->container->get($contextId);

if ($context->getConfig()?->isStateless() && null === $request->isStateless()) {
if ($context->getConfig()?->isStateless() && !$request->attributes->has('_stateless')) {
$request->setStateless();
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -54,7 +54,7 @@ public function testGetListenersWithInvalidParameter()
$this->assertEquals([[], null, null], $firewallMap->getListeners($request));
$this->assertNull($firewallMap->getFirewallConfig($request));
$this->assertFalse($request->attributes->has(self::ATTRIBUTE_FIREWALL_CONTEXT));
$this->assertNull($request->isStateless());
$this->assertFalse($request->attributes->has('_stateless'));
}

/** @dataProvider providesStatefulStatelessRequests */
Expand Down
6 changes: 1 addition & 5 deletions src/Symfony/Component/HttpFoundation/Request.php
Original file line number Diff line number Diff line change
Expand Up @@ -656,12 +656,8 @@ public function setStateless(bool $stateless = true): void
$this->attributes->set('_stateless', $stateless);
}

public function isStateless(): ?bool
public function isStateless(): bool
{
if (!$this->attributes->has('_stateless')) {
return null;
}

return $this->attributes->getBoolean('_stateless');
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -124,7 +124,7 @@ protected function createSubRequest(string $uri, Request $request): Request
if ($request->getDefaultLocale() !== $request->getLocale()) {
$subRequest->setLocale($request->getLocale());
}
if (null !== $request->isStateless()) {
if ($request->attributes->has('_stateless')) {
$subRequest->setStateless($request->isStateless());
}
if ($request->attributes->has('_check_controller_is_allowed')) {
Expand Down
pFad - Phonifier reborn

Pfad - The Proxy pFad of © 2024 Garber Painting. All rights reserved.

Note: This service is not intended for secure transactions such as banking, social media, email, or purchasing. Use at your own risk. We assume no liability whatsoever for broken pages.


Alternative Proxies:

Alternative Proxy

pFad Proxy

pFad v3 Proxy

pFad v4 Proxy