Uncaught SessionNotFoundException in ProximityFilter

Created on 23 August 2023, 10 months ago
Updated 2 September 2023, 10 months ago

Problem/Motivation

The API for Request::getSession() has changed between Symfony versions 4 and 6. Previously it would return NULL if a session was not previously set. Now it throws a SessionNotFoundException. There is a code path which can lead to this exception.

Steps to reproduce

My apologies, it's difficult to create a minimal test case where the session is not properly set. However, it involves creating a view with an exposed proximity filter in D10.1 with PHP 8.1 and the latest alpha release of this module.

Proposed resolution

See ProximityFilter::storeExposedInput(). We can call hasSession() before calling getSession() here:

// Previously:
// $session = $this->view->getRequest()->getSession() ?? NULL;

// A way to resolve it:
$session = $this->view->getRequest()->hasSession() ? $this->view->getRequest()->getSession() : NULL;
πŸ› Bug report
Status

Fixed

Version

4.0

Component

Geolocation Field / Backend

Created by

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

Comments & Activities

Production build 0.69.0 2024