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.
- Create a page with page manager. e.g.
/pm-test - On another page such as a
/pm-reprocontroller route, have ainternal:/pm-testlink to the page manager page - Have some code which calls
RequestStack::getSession(), directly or throughtempstore.privatefor an anonymous user. This can cause the error becauseRequestStack::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.
| Comment | File | Size | Author |
|---|---|---|---|
| page_manager-sessionless-request.md | 6.18 KB | tetranz |
Issue fork page_manager-3639868
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
Comment #3
tetranz commentedComment #4
tetranz commented