[1.15.0] bug, "Session has not been set" error thrown by select2_facets

Created on 27 July 2024, 4 months ago

Problem/Motivation

After upgrading to Drupal 10.3.0 I'm getting 404 when search via autocomplete widget from select2_facets.

Debug shown that $this->facetManager->build($facet); fails with watchdog message Session has not been set. Because we executing facets in a new request context I assume that there was something wrong with instantinating it.
Checking drupal core codebase for similar case I found core comment module has such example:

$redirect_request = Request::create(...);
// Carry over the session to the subrequest.
$redirect_request->setSession($request->getSession());

Git blame on https://git.drupalcode.org/project/drupal/-/blame/10.3.0/core/modules/co... shown the πŸ“Œ Remove calls to Request::hasSession() Active issue cased changes went into the core.

Note: I assume that this error also will be observable in facets module too because there are Request::create entries in facets/src/Controller/FacetBlockAjaxController.php, there is even an issue #3052574-239: Facets with AJAX not working in most of situations β†’

Steps to reproduce

Use drupal core 10.3.0, and select2 1.15.0, configure search api, views, facets and widget.

Proposed resolution

Set excplicitly session for sub request:

      $new_request = $this->createRequestFromPath($selection_settings['path']);
      $new_request->setSession($request->getSession());
πŸ› Bug report
Status

Active

Version

1.0

Component

Facets integration

Created by

πŸ‡ΊπŸ‡¦Ukraine vlad.dancer Kyiv

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