Problem/Motivation
Since #3456231: Do not add the session cache context if multiple entity support is disabled or there is only 1:1 relationship between the entity and preview link there is a fatal error when the request does not have a session, regardless of if it's a preview link URL. Not sure if this is specific to my site or environment.
The issue is because in \Drupal\preview_link\Access\PreviewLinkCanonicalRerouteAccessCheck::access we call $request->getSession()->isStarted(), but \Symfony\Component\HttpFoundation\Request::getSession will throw a SessionNotFoundException if there is no session yet.
Steps to reproduce
Proposed resolution
Check $request->hasSession() first
Remaining tasks
User interface changes
API changes
Data model changes
Issue fork preview_link-3585670
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
mstrelan commentedHaven't tried to reproduce in a vanilla set up, would be good to have a failing test
Comment #5
mstrelan commentedClaude helped me write a passing/failing test after I gave it the backtrace from where I experienced this. See https://git.drupalcode.org/project/preview_link/-/pipelines/799264
Now that I've seen the reproduction steps I wonder if it would be better to simply check if this is the master request rather than allowing it to check for sub-requests.
Comment #7
acbramley commentedhttps://www.drupal.org/project/preview_link/releases/2.2.1