I am using apaceh solr and have altered taxonomy term links so that they are search facets from anywhere on the site using hook_url_outbound_alter(), FacetapiAdapter::getSearchPath() and FacetapiAdapter::getQueryString(), along with a custom function to run empty solr searches when necessary based a little on the code in #1252648: Allow for enabling facet blocks on non-search pages.

The aim is to only add facets using this method, and never remove them.
If I call FacetapiAdapter::getQueryString() with $active = 0 and the facet is already part of the search the resulting query contains that facet twice, exactly the same.

I'm sure I could get my code to do some checks and modifications to make sure this doesn't happen but it seems like it might be a bug in FacetapiAdapter::getQueryString() because in no case would you want a duplicate filter in the query string.

Comments

cpliakas’s picture

Issue tags: +low hanging fruit

Hi rooby.

Thanks for the detailed explanation. I think this is a bit of an edge case, however I do think that the API function should be able to handle this. It seems like the array_unique() function could be be applied to the $qstring[$this->filterKey] array that is built towards the bottom of the FacetapiUrlProcessorStandard::getQueryString() method. Try that our and roll a patch if it works.

Thanks,
Chris

rooby’s picture

Status: Active » Needs review
StatusFileSize
new665 bytes

Thanks for the direction.
Here is a patch.

cpliakas’s picture

Status: Needs review » Reviewed & tested by the community

Thanks for rolling the patch. This looks good to me!

cpliakas’s picture

Status: Reviewed & tested by the community » Fixed

Committed at 0940443.

Congrats on becoming the 13th committer to Facet API!

rooby’s picture

Thanks :)

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