Problem/Motivation

FacetBlockAjaxController creates a new Symfony RequestStack and sets it as the current request's request_stack service in the container, this however breaks in 9.3.0 due to Symfony deprecations (getMasterRequest() is soon to be deprecated and Drupal is already preparing for this.)
So you get Ajax errors like:

HTTP-resultaatcode: 500
Debug informatie volgt.
Pad: /nl-BE/facets-block-ajax
Statustekst: Internal Server Error
Antwoordtekst: The website encountered an unexpected error. Please try again later.Error: Call to undefined method Symfony\Component\HttpFoundation\RequestStack::getMainRequest() in system_js_settings_alter() (line 705 of core/modules/system/system.module). system_js_settings_alter(Array, Object, NULL) (Line: 539)

Steps to reproduce

- Install drupal 9.3.0
- Use drupal facets in an ajax view
- Change any value in any available facet
- Get the ajax error as a result

Proposed resolution

I'll attach a small patch that fixed this functionality for me.

Comments

RandalV created an issue. See original summary.

randalv’s picture

Patch attached.

Edit: It applies to 1.8, not to 2.x :-)

neclimdul’s picture

StatusFileSize
new1.59 KB

Ouch! Confirmed but the patch won't work because it won't work with Drupal prior to 9.3. This should work for both the 8.x-1.x branch and 2.0 branch and cover supported version of Drupal.

I'm curious why this exists and why we couldn't just use the existing request stack like ViewsAjaxController but I haven't time to look and this gets things working in an acceptable way.

claudiu.cristea’s picture

I've built a simple Ajax view (D9.3, Facets 2.0.0-rc1, SAPI 1.21.0) with facets as dropdown. When selecting, I'm getting:

Symfony\Component\Routing\Exception\ResourceNotFoundException: No routes found for "/facets-poc/search?f[0]=category:97". in Drupal\Core\Routing\Router->matchRequest() (line 124 of /var/www/html/facets-poc/core/lib/Drupal/Core/Routing/Router.php).

Not sure is related.

claudiu.cristea’s picture

catch’s picture

I'v added a change record to the original issue, cribbing from the patch here: https://www.drupal.org/node/3253744

mkalkbrenner’s picture

Version: 8.x-1.8 » 2.0.x-dev

I added test to #3

mkalkbrenner’s picture

Priority: Normal » Major

mkalkbrenner’s picture

Status: Needs review » Fixed

Committed to 2.0.x. Thanks for your help.

Status: Fixed » Closed (fixed)

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