Problem/Motivation
Enabling the module on Drupal 10 and making use of URL process facets plugin gives error:
[error] Error: Call to undefined method Symfony\Component\HttpFoundation\RequestStack::getMasterRequest() in Drupal\facets_pretty_paths\Plugin\facets\url_processor\FacetsPrettyPathsUrlProcessor::create() (line 76 of /Applications/MAMP/htdocs/acquia_cms/docroot/modules/contrib/facets_pretty_paths/src/Plugin/facets/url_processor/FacetsPrettyPathsUrlProcessor.php) #0 /Applications/MAMP/htdocs/acquia_cms/docroot/core/lib/Drupal/Core/Plugin/Factory/ContainerFactory.php(21): Drupal\facets_pretty_paths\Plugin\facets\url_processor\FacetsPrettyPathsUrlProcessor::create(Object(Drupal\Core\DependencyInjection\Container), Array, 'facets_pretty_p...', Array)
The error is coming because Drupal 10 uses symfony 6. And in symfony 6, the method name `getMasterRequest()` has been renamed with `getMainRequest()`. See here.
Proposed resolution
As the module supports Drupal 9.1 (and this release doesn't have getMainRequest()), so possible solution to support Drupal Core 9 and 10 as well is:
Update file: src/Plugin/facets/url_processor/FacetsPrettyPathsUrlProcessor.php#L76 and change it to:
version_compare(\Drupal::VERSION, '9.3', '>=') ? $request_stack->getMainRequest() : $request_stack->getMasterRequest(),
| Comment | File | Size | Author |
|---|---|---|---|
| #4 | 3327265-fix-undefined-method-error.patch | 868 bytes | vishalkhode |
Comments
Comment #2
vishalkhode commentedComment #3
vishalkhode commentedComment #4
vishalkhode commentedAttached is the patch that fixes the issue.
Comment #5
ankitv18 commentedIf this approved by maintainer and pushed with a new tag then we are good to close this ticket, please take look just in case https://www.drupal.org/project/facets_pretty_paths/issues/3287445#commen...
Comment #7
strykaizer