Problem/Motivation

\Drupal\facets\Plugin\facets\url_processor\QueryString::buildUrls() overwrites the route parameters for the facet URL based on the initial request. However, this overwrites the correct route parameters returned in \Drupal\facets\Plugin\facets\url_processor\QueryString::getUrlForRequest() earlier.

Steps to reproduce

  1. Create a Search page with a facet on Node type
  2. Place a facets block on a node page
  3. Observe the facet URL contains the route parameters for the current node, rather than the Search page.

Proposed resolution

Do not overwrite the route parameters with the route parameters for the current request.

Remaining tasks

  1. Write a patch
  2. Review
  3. Commit

User interface changes

None.

API changes

None.

Data model changes

None.

CommentFileSizeAuthor
#2 3165817-2.patch1.6 KBidebr
Support from Acquia helps fund testing for Drupal Acquia logo

Comments

idebr created an issue. See original summary.

idebr’s picture

Status: Active » Needs review
FileSize
1.6 KB

Attached patch removes the overwrite of the route parameters with the route parameters for the current request.

borisson_’s picture

We originally did this for performance reasons, this change does not make it slower again?

idebr’s picture

#3013991: QueryString::buildUrls should not rebuild requests for the same facet source path refactored the existing code, so the route parameters are built once per request instead of once per facet result.

This issue removes the route parameters logic entirely.

  • borisson_ committed e475078 on 8.x-1.x authored by idebr
    Issue #3165817 by idebr, borisson_: QueryString::buildUrls() sets route...
borisson_’s picture

Ok, few things in life make me as happy as deleting code. Thanks @idebr!

borisson_’s picture

Status: Needs review » Fixed

Oh, this one should've been set to fixed already.

Status: Fixed » Closed (fixed)

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

Sylvio69’s picture

Hi !

Since the last facet 8.x-1.6 release I have a problem with the facet.
My drupal core version is the last of branch 8, I try on a 8.9.7 and 8.9.8.

- I have a search page (with search_api_pages) with several facets on Node type.
- I place a facets block on a "search" page.
- When a submit my query, the search page works perfectly. I have in a URL the search term :

http://mydruapl.com/fr/recherche/{searchTerm}

- When I click on a facet link/checkbox/whatever, the problem occurs and on the URL I lost the {searchTerm}

http://mydruapl.com/fr/recherche?f[0]={facetName}:{facetValue}

With the 8.x-1.5 => no problem.
I have read the 8.x-1.6 changelog and I found this issue #3165817 with this patch on the comment #2

With the 8.x-1.6 and the reverse patch => It works !

What can I do to manage this behavior ?

Thank you in advance for your answer.

neclimdul’s picture

I thought I might need to revert this as well but on closer inspection it seems that this is a legitimate fix and the code was only accidentally fixing some problems. @Sylvio69 #3191091: QueryString url_processor broken(ish) for Ajax Views fixed my problem and it might fix yours as well. I'm guessing there is a similar problem with the request stack and i18n that is breaking your site.

Neslee Canil Pinto’s picture

@here i am also having similar issue as of #9

ankithashetty’s picture

Agree with #9, been facing a similar issue!