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
Comment #2
randalv commentedPatch attached.
Edit: It applies to 1.8, not to 2.x :-)
Comment #3
neclimdulOuch! 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.
Comment #4
claudiu.cristeaI'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:
Not sure is related.
Comment #5
claudiu.cristeaOh, sorry! My problem from #4 is #3046872: ResourceNotFoundException with ajax facets when site running in subfolder . Ignore #4.
Comment #6
catchI'v added a change record to the original issue, cribbing from the patch here: https://www.drupal.org/node/3253744
Comment #7
mkalkbrennerI added test to #3
Comment #8
mkalkbrennerComment #10
mkalkbrennerCommitted to 2.0.x. Thanks for your help.