Verified Commit 0d54ea9c authored by Alex Pott's avatar Alex Pott
Browse files

Issue #3413153 by znerol, alexpott: Remove calls to Request::hasSession()

parent a058be43
Loading
Loading
Loading
Loading
Loading
+3 −12
Original line number Diff line number Diff line
@@ -147,10 +147,7 @@ function install_drupal($class_loader, $settings = [], callable $callback = NULL
  // installations can send output to the browser or redirect the user to the
  // next page.
  if ($state['interactive']) {
    // If a session has been initiated in this request, make sure to save it.
    if (\Drupal::request()->hasSession()) {
    \Drupal::request()->getSession()->save();
    }
    if ($state['parameters_changed']) {
      // Redirect to the correct page if the URL parameters have changed.
      install_goto(install_redirect_url($state));
@@ -645,10 +642,7 @@ 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 (\Drupal::request()->hasSession()) {
        \Drupal::request()->getSession()->save();
        }
        // Send the response.
        $response->send();
        exit;
      }
@@ -663,10 +657,7 @@ function install_run_task($task, &$install_state) {
      // @todo Replace this when we refactor the installer to use a request-
      //   response workflow.
      if ($output instanceof Response) {
        if (\Drupal::request()->hasSession()) {
        \Drupal::request()->getSession()->save();
        }
        // Send the response.
        $output->send();
        exit;
      }
+1 −5
Original line number Diff line number Diff line
@@ -22,11 +22,7 @@ public static function getLabel() {
   * {@inheritdoc}
   */
  public function getContext() {
    $request = $this->requestStack->getCurrentRequest();
    if ($request->hasSession()) {
      return Crypt::hashBase64($request->getSession()->getId());
    }
    return 'none';
    return Crypt::hashBase64($this->requestStack->getSession()->getId());
  }

}
+2 −6
Original line number Diff line number Diff line
@@ -971,11 +971,9 @@ protected function initializeContainer() {
    if (($request_stack = $this->container->get('request_stack', ContainerInterface::NULL_ON_INVALID_REFERENCE))) {
      if ($request = $request_stack->getMainRequest()) {
        $subrequest = TRUE;
        if ($request->hasSession()) {
        $request->setSession($this->container->get('session'));
      }
    }
    }

    if (!empty($current_user_id)) {
      $this->container->get('current_user')->setInitialAccountId($current_user_id);
@@ -1243,11 +1241,9 @@ public function resetContainer(): ContainerInterface {
    if (($request_stack = $this->container->get('request_stack', ContainerInterface::NULL_ON_INVALID_REFERENCE))) {
      if ($request = $request_stack->getMainRequest()) {
        $subrequest = TRUE;
        if ($request->hasSession()) {
        $request->setSession($this->container->get('session'));
      }
    }
    }

    if (!empty($current_user_id)) {
      $this->container->get('current_user')->setInitialAccountId($current_user_id);
+0 −3
Original line number Diff line number Diff line
@@ -62,9 +62,6 @@ public function __construct(EntityTypeManagerInterface $entity_type_manager, Pri
   *   Allowed or forbidden, neutral if tempstore is empty.
   */
  public function access(AccountInterface $account, $entity_type_id) {
    if (!$this->requestStack->getCurrentRequest()->hasSession()) {
      return AccessResult::neutral();
    }
    $selection = $this->tempStore->get($account->id() . ':' . $entity_type_id);
    if (empty($selection) || !is_array($selection)) {
      return AccessResult::neutral();
+1 −2
Original line number Diff line number Diff line
@@ -246,8 +246,7 @@ public function buildForm($form_arg, FormStateInterface &$form_state) {
      $form_state->setUserInput($input);
    }

    // @todo Remove hasSession() condition in https://www.drupal.org/i/3413153
    if ($request->hasSession() && $request->getSession()->has('batch_form_state')) {
    if ($request->getSession()->has('batch_form_state')) {
      // We've been redirected here after a batch processing. The form has
      // already been processed, but needs to be rebuilt. See _batch_finished().
      $session = $request->getSession();
Loading