Remove calls to Request::hasSession()

Created on 8 January 2024, 10 months ago
Updated 4 April 2024, 8 months ago

Problem/Motivation

After 📌 Add the session to the request in KernelTestBase, BrowserTestBase, and drush Fixed a session is now always on the request. Hence, calls to hasSession() should be removed.

Steps to reproduce

Proposed resolution

Trivial changes

Trivial changes do not require any additional modifications (e.g., no changes in tests or other areas of the code base).

  • Remove 3 occurrences from core/includes/install.core.inc (trivial)
  • Remove 1 occurrence from core/lib/Drupal/Core/Entity/EntityDeleteMultipleAccessCheck.php. This one could be replaced by a call to \Drupal::service('session_configuration')->hasSession($request) which might have been the original intention anyway.
  • Remove 1 occurrence from core/lib/Drupal/Core/StackMiddleware/Session.php (trivial)
  • Remove 1 occurrence from core/lib/Drupal/Core/TempStore/SharedTempStore.php (trivial)
  • Remove 1 occurrence from core/lib/Drupal/Core/TempStore/SharedTempStoreFactory.php (trivial)
  • Remove 1 occurrence from core/lib/Drupal/Core/Update/UpdateKernel.php (trivial)
  • Remove 2 occurrences from core/lib/Drupal/Core/DrupalKernel.php (trivial). Leave one occurrence in preHandle().
  • Remove 1 occurrence from core/modules/big_pipe/src/Controller/BigPipeController.php. This one could be replaced by a call to \Drupal::service('session_configuration')->hasSession($request) which might have been the original intention anyway.
  • Remove 1 occurrence from core/modules/comment/src/Controller/CommentController.php (trivial)
  • Remove 2 occurrences from core/modules/user/src/Authentication/Provider/Cookie.php (trivial)
  • Remove 1 occurrence from core/modules/views/src/ViewExecutable.php (trivial)

Non-trivial changes

These changes require additional modifications (e.g., changes in tests or other areas of the code base).

  • Remove 1 occurrence from core/lib/Drupal/Core/Cache/Context/SessionCacheContext.php. Requires deletion of one Test in core/tests/Drupal/Tests/Core/Cache/Context/SessionCacheContextTest.php.
  • Remove 1 occurrence from core/lib/Drupal/Core/Form/FormBuilder.php. Requires a fix in core/modules/views_ui/src/ViewUI.php for the views preview functionality. Also requires a fix in core/tests/Drupal/Tests/Core/Form/FormBuilderTest.php.
  • Remove manual session start code from core/lib/Drupal/Core/TempStore/PrivateTempStore.php. This has been dead code in production for a long time. Requires a fix in core/tests/Drupal/KernelTests/Core/TempStore/AnonymousPrivateTempStoreTest.php.

Note to reviewers

This issue requires manual testing. Areas to test:

  • Installation via the web installer
  • Running update.php
  • Using views and views previews
  • Using the layout builder (private temp store)
  • Using big pipe

Remaining tasks

  • Manual Testing

User interface changes

API changes

Data model changes

Release notes snippet

📌 Task
Status

Fixed

Version

10.3

Component
Base 

Last updated about 8 hours ago

Created by

🇨🇭Switzerland znerol

Live updates comments and jobs are added and updated live.
Sign in to follow issues

Merge Requests

Comments & Activities

Production build 0.71.5 2024