Beta phase evaluation

Reference: https://www.drupal.org/core/beta-changes
Issue category Task because its part of the larger session work
Issue priority Normal, because the impact isn't that high. Things still work as they are at the moment.
Disruption No disruption, its a cleanup only patch

Problem/Motivation

There are still quite some references to Session Manager and the session_manager service throughout core, despite the fact that as of #2229145: Register symfony session components in the DIC and inject the session service into the request object, the session should be accessed and controlled via the SessionInterface obtained from $request->getSession().

Proposed resolution

  • Replace direct access of session_manager service with symfony sessions obtained from the request wherever possible.
    Regrettably there is still one place where we need to reference it directly (user_logout(), see also the comment there).
  • Update documentation wherever necessary.

Remaining tasks

User interface changes

API changes

Support from Acquia helps fund testing for Drupal Acquia logo

Comments

znerol’s picture

Status: Active » Needs review
FileSize
8.58 KB

Status: Needs review » Needs work

The last submitted patch, 1: 2478119-use-request-session-instead-of-session-manager.diff, failed testing.

znerol’s picture

Status: Needs work » Needs review
FileSize
10.26 KB
2.4 KB

BrowserTestBase uses a different public ad-hoc property in order to store the session id on the account than WebTestBase :(

andypost’s picture

looks great, any idea how to check that session manager should not be used?
Probably IS needs update with that

znerol’s picture

Regrettably there is still one place where we need to reference it directly (user_logout(), see also the comment there). So public: false does not buy us anything here.

dawehner’s picture

Issue summary: View changes
+++ b/core/lib/Drupal/Core/DrupalKernel.php
@@ -699,21 +699,21 @@ protected function getKernelParameters() {
+      // If there is a session, close and save it.
+      if ($this->container->initialized('session')) {
+        $session = $this->container->get('session');
+        if ($session->isStarted()) {
+          $session_started = TRUE;
+          $session->save();
         }
-        unset($session_manager);
+        unset($session);
       }

This itself is way better to understand. ... its about the session

dawehner’s picture

So yeah is there anything left for the RTBC? I updated the issue summary with a beta evaluation and documented the user_logout() .

znerol’s picture

Looks like #3 contains hunks from #2478167: Generate proper value for sessionName property in BrowserTestBase. Other than that the patch is complete I think.

andypost’s picture

Status: Needs review » Reviewed & tested by the community
FileSize
8.58 KB

https://github.com/symfony/symfony/issues/12375 still open so user_logout() not the case, maybe we need separate issue for that...

Just a re-roll so RTBC

alexpott’s picture

Status: Reviewed & tested by the community » Needs work

This looks good and an obvious followup from all the current work on sessions.

+++ b/core/modules/system/tests/modules/session_test/src/Controller/SessionTestController.php
@@ -36,8 +36,8 @@ public function get() {
    * @return string
    *   A notification message.
    */
-  public function getFromSessionObject() {
-    $value = \Drupal::request()->getSession()->get("session_test_key");
+  public function getFromSessionObject(Request $request) {
+    $value = $request->getSession()->get("session_test_key");

@@ -49,12 +49,12 @@ public function getFromSessionObject() {
    * @return string
    *   A notification message with session ID.
    */
-  public function getId() {
+  public function getId(Request $request) {

@@ -145,16 +145,16 @@ public function isLoggedIn() {
    * @return \Symfony\Component\HttpFoundation\JsonResponse
    *   The response.
    */
-  public function traceHandler() {
+  public function traceHandler(Request $request) {

The method document needs updating (sorry this seems quite minor).

znerol’s picture

Status: Needs work » Reviewed & tested by the community
FileSize
9.07 KB
1.27 KB

Done.

alexpott’s picture

Status: Reviewed & tested by the community » Fixed

Committed a108bf0 and pushed to 8.0.x. Thanks!

I agree that this is allowable under the beta followup to other work clause.

  • alexpott committed a108bf0 on 8.0.x
    Issue #2478119 by znerol, andypost: Replace references to Session...

Status: Fixed » Closed (fixed)

Automatically closed - issue fixed for 2 weeks with no activity.