8000 Implementation v2 · symfony/symfony@5b83906 · GitHub
[go: up one dir, main page]

Skip to content

Commit 5b83906

Browse files
committed
Implementation v2
1 parent f73a5f5 commit 5b83906

File tree

7 files changed

+29
-309
lines changed

7 files changed

+29
-309
lines changed

src/Symfony/Bundle/FrameworkBundle/EventListener/DisableSessionSubscriber.php

Lines changed: 0 additions & 51 deletions
This file was deleted.

src/Symfony/Bundle/FrameworkBundle/Resources/config/session.xml

Lines changed: 0 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -17,10 +17,6 @@
1717
<argument type="service" id="session.flash_bag" />
1818
</service>
1919

20-
<service id="disableable_session" class="Symfony\Component\HttpFoundation\Session\DisableableSessionProxy" decorates="session">
21-
<argument type="service" id="disableable_session.inner"/>
22-
</service>
23-
2420
<service id="Symfony\Component\HttpFoundation\Session\SessionInterface" alias="session" />
2521
<service id="Symfony\Component\HttpFoundation\Session\Storage\SessionStorageInterface" alias="session.storage" />
2622
<service id="SessionHandlerInterface" alias="session.handler" />
@@ -73,11 +69,6 @@
7369
</argument>
7470
</service>
7571

76-
<service id="session.disable_listener" class="Symfony\Bundle\FrameworkBundle\EventListener\DisableSessionSubscriber">
77-
<tag name="kernel.event_subscriber" />
78-
<argument type="service" id="session" />
79-
</service>
80-
8172
<!-- for BC -->
8273
<service id="session.storage.filesystem" alias="session.storage.mock_file" />
8374
</services>

src/Symfony/Component/HttpFoundation/Request.php

Lines changed: 3 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,6 @@
1313

1414
use Symfony\Component\HttpFoundation\Exception\ConflictingHeadersException;
1515
use Symfony\Component\HttpFoundation\Exception\SuspiciousOperationException;
16-
use Symfony\Component\HttpFoundation\Session\DisableableSessionProxy;
1716
use Symfony\Component\HttpFoundation\Session\SessionInterface;
1817

1918
/**
@@ -750,14 +749,14 @@ public function hasPreviousSession()
750749
* like whether the session is started or not. It is just a way to check if this Request
751750
* is associated with a Session instance.
752751
*
753-
* @return bool true when the Request contains an enabled Session object, false otherwise
752+
* @return bool true when the Request contains a Session object, false otherwise
754753
*/
755754
public function hasSession()
756755
{
757-
return null !== $this->session && !($this->session instanceof DisableableSessionProxy && $this->session->isDisabled());
756+
return null !== $this->session;
758757
}
759758

760-
public function setSession(?SessionInterface $session)
759+
public function setSession(SessionInterface $session)
761760
{
762761
$this->session = $session;
763762
}

src/Symfony/Component/HttpFoundation/Session/DisableableSessionProxy.php

< 8000 button class="Button Button--iconOnly Button--invisible flex-shrink-0 js-expand-all-difflines-button" aria-label="Expand all lines: src/Symfony/Component/HttpFoundation/Session/DisableableSessionProxy.php" data-file-path="src/Symfony/Component/HttpFoundation/Session/DisableableSessionProxy.php" aria-describedby=":R13edlab:">
Lines changed: 0 additions & 238 deletions
This file was deleted.

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

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -18,6 +18,7 @@
1818
use Symfony\Component\HttpKernel\Event\FinishRequestEvent;
1919
use Symfony\Component\HttpKernel\Event\RequestEvent;
2020
use Symfony\Component\HttpKernel\Event\ResponseEvent;
21+
use Symfony\Component\HttpKernel\Exception\UnexpectedSessionUsageException;
2122
use Symfony\Component\HttpKernel\KernelEvents;
2223

2324
/**
@@ -83,6 +84,10 @@ public function onKernelResponse(ResponseEvent $event)
8384
}
8485

8586
if ($session instanceof Session ? $session->getUsageIndex() !== end($this->sessionUsageStack) : $session->isStarted()) {
87+
if (true === $event->getRequest()->attributes->get('_stateless', false)) {
88+
throw new UnexpectedSessionUsageException();
89+
}
90+
8691
if ($autoCacheControl) {
8792
$response
8893
->setExpires(new \DateTime())

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

Lines changed: 1 addition & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,6 @@
1212
namespace Symfony\Component\HttpKernel\EventListener;
1313

1414
use Psr\Container\ContainerInterface;
15-
use Symfony\Component\HttpFoundation\Session\DisableableSessionProxy;
1615
use Symfony\Component\HttpFoundation\Session\SessionInterface;
1716
use Symfony\Component\HttpFoundation\Session\Storage\NativeSessionStorage;
1817

@@ -40,11 +39,6 @@ protected function getSession(): ?SessionInterface
4039
return null;
4140
}
4241

43-
$session = $this->container->get('session');
44-
if ($session instanceof DisableableSessionProxy && $session->isDisabled()) {
45-
return null;
46-
}
47-
4842
if ($this->container->has('session_storage')
4943
&& ($storage = $this->container->get('session_storage')) instanceof NativeSessionStorage
5044
&& ($masterRequest = $this->container->get('request_stack')->getMasterRequest())
@@ -53,6 +47,6 @@ protected function getSession(): ?SessionInterface
5347
$storage->setOptions(['cookie_secure' => true]);
5448
}
5549

56-
return $session;
50+
return $this->container->get('session');
5751
}
5852
}

0 commit comments

Comments
 (0)
0