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

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

mstrelan created an issue. See original summary.

mstrelan’s picture

Status: Active » Needs work

Haven't tried to reproduce in a vanilla set up, would be good to have a failing test

mstrelan’s picture

Status: Needs work » Needs review

Claude 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.

  • acbramley committed 20b32960 on 2.x authored by mstrelan
    fix: #3585670 "Session has not been set" error since 2.2.0
    
    By: mstrelan
    
acbramley’s picture

Now that this issue is closed, review the contribution record.

As a contributor, attribute any organization that helped you, or if you volunteered your own time.

Maintainers, credit people who helped resolve this issue.

Status: Fixed » Closed (fixed)

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