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(),

Comments

vishalkhode created an issue. See original summary.

vishalkhode’s picture

Issue summary: View changes
vishalkhode’s picture

Title: Enabling module on D10 giving error: Call to undefined method Symfony\Component\HttpFoundation\RequestStack::getMasterRequest() » Enabling module on Drupal 10 gives error: Call to undefined method Symfony\Component\HttpFoundation\RequestStack::getMasterRequest()
vishalkhode’s picture

StatusFileSize
new868 bytes

Attached is the patch that fixes the issue.

ankitv18’s picture

Status: Active » Needs review

If 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...

strykaizer’s picture

Status: Needs review » Fixed

Status: Fixed » Closed (fixed)

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