Problem/Motivation
On Drupal 11.4 was introduced the query on the method Url::createFromRequest https://www.drupal.org/project/drupal/issues/2985400
Commit https://git.drupalcode.org/project/drupal/-/commit/478f4da250a8e58dbaa33...
public static function createFromRequest(Request $request) {
// We use the router without access checks because URL objects might be
// created and stored for different users.
$result = \Drupal::service('router.no_access_checks')->matchRequest($request);
$route_name = $result[RouteObjectInterface::ROUTE_NAME];
$route_parameters = $result['_raw_variables']->all();
- return new static($route_name, $route_parameters);
+ $options = [
+ 'query' => $request->query->all(),
+ ];
+ return new static($route_name, $route_parameters, $options);
}
On facets/src/Plugin/facets/url_processor/QueryString::buildUrls()
If the condition is not met, the query is not set, keeping the query strings on the url, and never removing the facet .
if ($result_get_params->all() !== [$this->filterKey => []]) {
$new_url_params = $result_get_params->all();
if (empty($new_url_params[$this->filterKey])) {
unset($new_url_params[$this->filterKey]);
}
// Facet links should be page-less.
// See https://www.drupal.org/node/2898189.
unset($new_url_params['page']);
// Remove core wrapper format (e.g. render-as-ajax-response) parameters.
unset($new_url_params[MainContentViewSubscriber::WRAPPER_FORMAT]);
// Set the new url parameters.
$url->setOption('query', $new_url_params);
}
Steps to reproduce
- Upgrade to D11.4
- Filter by multiples facets
- Try to remove the last one of the facets (on our test, we use summary facets links)
Proposed resolution
Clear the remaining facets from query.
Issue fork facets-3609745
Show commands
Start within a Git clone of the project using the version control instructions.
Or, if you do not have SSH keys set up on git.drupalcode.org:
Comments
Comment #3
eduardo morales albertiAI Generated Code
Mainly generated by AI, reviewed and approved by a human before this MR was created.
Comment #4
eduardo morales alberti