Generated with the help of an LLM.

Problem/Motivation

VariantRouteFilter pushes a request with no session object attached. In some situations, this causes a WSOD saying "There is currently no session available". It is the error described here https://www.drupal.org/node/3337193 under "Deprecations".

Steps to reproduce

It is tedious to describe how to reproduce so I will keep this brief but add Claude's output as an attachment. See page_manager-sessionless-request.md. It is somewhat non-deterministic because it depends on Fibers being suspended which can depend on the state of caching etc. The attachment includes a test module to deterministically force the problem. It also describes a workaround using a route filter.

  1. Create a page with page manager. e.g. /pm-test
  2. On another page such as a /pm-repro controller route, have a internal:/pm-test link to the page manager page
  3. Have some code which calls RequestStack::getSession(), directly or through tempstore.private for an anonymous user. This can cause the error because RequestStack::getSession() accesses the request at the top of the stack. If that is the request that was pushed by page manager then it crashes because there is no session.

Note that "session" refers to a session object on the request. It doesn't imply a logged in Drupal session.

Proposed resolution

In VariantRouteFilter::getVariantRouteName(), if the request being pushed has no session, then give it the main request's session. Alternatively, find a way to avoid pushing a new request to the stack but that's probably a significant refactor.

Remaining tasks

Create a merge request.

CommentFileSizeAuthor
page_manager-sessionless-request.md6.18 KBtetranz
Command icon Show commands

Start within a Git clone of the project using the version control instructions.

Or, if you do not have SSH keys set up on git.drupalcode.org:

Comments

tetranz created an issue. See original summary.

tetranz’s picture

Title: VariantRouteFilter pushes a sessionless request onto the request stack which can cause “There is currently no session available.” » VariantRouteFilter pushes a sessionless request which can cause “There is currently no session available.”
tetranz’s picture

Status: Active » Needs review