diff --git a/core/includes/install.core.inc b/core/includes/install.core.inc index 62e078d54e34..ce5ca8ad109d 100644 --- a/core/includes/install.core.inc +++ b/core/includes/install.core.inc @@ -145,8 +145,8 @@ function install_drupal($class_loader, $settings = [], callable $callback = NULL // next page. if ($state['interactive']) { // If a session has been initiated in this request, make sure to save it. - if ($session = \Drupal::request()->getSession()) { - $session->save(); + if (\Drupal::request()->hasSession()) { + \Drupal::request()->getSession()->save(); } if ($state['parameters_changed']) { // Redirect to the correct page if the URL parameters have changed. @@ -657,8 +657,8 @@ function install_run_task($task, &$install_state) { $url = Url::fromUri('base:install.php', ['query' => $install_state['parameters'], 'script' => '']); $response = batch_process($url, clone $url); if ($response instanceof Response) { - if ($session = \Drupal::request()->getSession()) { - $session->save(); + if (\Drupal::request()->hasSession()) { + \Drupal::request()->getSession()->save(); } // Send the response. $response->send(); diff --git a/core/lib/Drupal/Core/Entity/EntityDeleteMultipleAccessCheck.php b/core/lib/Drupal/Core/Entity/EntityDeleteMultipleAccessCheck.php index 470c1b091504..6e9564caea2a 100644 --- a/core/lib/Drupal/Core/Entity/EntityDeleteMultipleAccessCheck.php +++ b/core/lib/Drupal/Core/Entity/EntityDeleteMultipleAccessCheck.php @@ -62,7 +62,7 @@ class EntityDeleteMultipleAccessCheck implements AccessInterface { * Allowed or forbidden, neutral if tempstore is empty. */ public function access(AccountInterface $account, $entity_type_id) { - if (!$this->requestStack->getCurrentRequest()->getSession()) { + if (!$this->requestStack->getCurrentRequest()->hasSession()) { return AccessResult::neutral(); } $selection = $this->tempStore->get($account->id() . ':' . $entity_type_id); diff --git a/core/modules/big_pipe/src/Controller/BigPipeController.php b/core/modules/big_pipe/src/Controller/BigPipeController.php index a5f57b14b4ff..da95f6d9dce2 100644 --- a/core/modules/big_pipe/src/Controller/BigPipeController.php +++ b/core/modules/big_pipe/src/Controller/BigPipeController.php @@ -42,7 +42,7 @@ class BigPipeController { // the cookie was already set, yet the user is executing this controller; // - there is no session, in which case BigPipe is not enabled anyway, so it // is pointless to set this cookie. - if ($request->cookies->has(BigPipeStrategy::NOJS_COOKIE) || $request->getSession() === NULL) { + if ($request->cookies->has(BigPipeStrategy::NOJS_COOKIE) || !$request->hasSession()) { throw new AccessDeniedHttpException(); } diff --git a/core/modules/comment/src/Controller/CommentController.php b/core/modules/comment/src/Controller/CommentController.php index 82289bed921c..417b581b75f2 100644 --- a/core/modules/comment/src/Controller/CommentController.php +++ b/core/modules/comment/src/Controller/CommentController.php @@ -152,8 +152,8 @@ class CommentController extends ControllerBase { $subrequest_url = $entity->toUrl()->setOption('query', ['page' => $page])->toString(TRUE); $redirect_request = Request::create($subrequest_url->getGeneratedUrl(), 'GET', $request->query->all(), $request->cookies->all(), [], $request->server->all()); // Carry over the session to the subrequest. - if ($session = $request->getSession()) { - $redirect_request->setSession($session); + if ($request->hasSession()) { + $redirect_request->setSession($request->getSession()); } $request->query->set('page', $page); $response = $this->httpKernel->handle($redirect_request, HttpKernelInterface::SUB_REQUEST);