Check session before accessing it

Created on 16 April 2024, about 1 year ago
Updated 1 May 2024, 12 months ago

Problem/Motivation

After updating to Drupal 10.2.5, some code of variants which is checking and reading the session, runs into an exception as apparently Symfony changed the Request::getSession() method to throw an exception if there is no session. This as opposed to just calling trigger_error in version 4.4.

The error occurs for example when executing drush commands as there's no session in that case.

Steps to reproduce

On a site using Drupal 10.2.5 and variants, run a drush cr.

Proposed resolution

Check if there is a session using Request::hasSession() before reading the session.

πŸ› Bug report
Status

Fixed

Version

1.0

Component

Code

Created by

Live updates comments and jobs are added and updated live.
Sign in to follow issues

Merge Requests

Comments & Activities

Production build 0.71.5 2024