minor #40760 Simplified condition and removed unused code from AbstractSessionListener::onKernelRequest (StefanoCappellini)

This PR was submitted for the 5.x branch but it was merged into the 4.4 branch instead.

Discussion
----------

Simplified condition and removed unused code from AbstractSessionListener::onKernelRequest

| Q             | A
| ------------- | ---
| Branch?       | 4.4
| Bug fix?      | no
| New feature?  | no
| Deprecations? | no
| Tickets       | None
| License       | MIT

This PR simplifies a condition and removes unused code (AFAIK coming from  #38894)).

Commits
-------

d344b8d6cb Simplified condition and removed unused code from AbstractSessionListener::onKernelRequest
This commit is contained in:
Nicolas Grekas 2021-04-11 14:47:43 +02:00
commit 03ef116496

View File

@ -53,14 +53,13 @@ abstract class AbstractSessionListener implements EventSubscriberInterface
return; return;
} }
$session = null;
$request = $event->getRequest(); $request = $event->getRequest();
if (!$request->hasSession()) { if (!$request->hasSession()) {
$sess = null; $sess = null;
$request->setSessionFactory(function () use (&$sess) { return $sess ?? $sess = $this->getSession(); }); $request->setSessionFactory(function () use (&$sess) { return $sess ?? $sess = $this->getSession(); });
} }
$session = $session ?? ($this->container && $this->container->has('initialized_session') ? $this->container->get('initialized_session') : null); $session = $this->container && $this->container->has('initialized_session') ? $this->container->get('initialized_session') : null;
$this->sessionUsageStack[] = $session instanceof Session ? $session->getUsageIndex() : 0; $this->sessionUsageStack[] = $session instanceof Session ? $session->getUsageIndex() : 0;
} }