Skip to content

Commit

Permalink
[BUGFIX] Filters in autosuggest get added twice (#2225)
Browse files Browse the repository at this point in the history
The filters in the autosuggest currently get added twice. Once from TypoScript and once
from the passed additionalFilters (That originally also come from the TypoScript of the previous request).

Since we can access the TypoScript from the suggest controller as well we should not pass those filters as additionalFilters.

Nevertheless we should keep the evaluation of additionalFilters to allow additionalFilters on a view base.

Related: #2211
  • Loading branch information
timohund committed Jan 31, 2019
1 parent 039c82a commit 7aff158
Show file tree
Hide file tree
Showing 2 changed files with 19 additions and 3 deletions.
17 changes: 14 additions & 3 deletions Classes/Controller/SearchController.php
Original file line number Diff line number Diff line change
Expand Up @@ -106,7 +106,7 @@ public function resultsAction()
$this->controllerContext->setSearchResultSet($searchResultSet);

$values = [
'additionalFilters' => $this->searchService->getAdditionalFilters(),
'additionalFilters' => $this->getAdditionalFilters(),
'resultSet' => $searchResultSet,
'pluginNamespace' => $this->typoScriptConfiguration->getSearchPluginNamespace()
];
Expand All @@ -127,7 +127,7 @@ public function formAction()

$values = [
'search' => $this->searchService->getSearch(),
'additionalFilters' => $this->searchService->getAdditionalFilters(),
'additionalFilters' => $this->getAdditionalFilters(),
'pluginNamespace' => $this->typoScriptConfiguration->getSearchPluginNamespace()
];
$values = $this->emitActionSignal(__CLASS__, __FUNCTION__, [$values]);
Expand All @@ -151,7 +151,7 @@ public function frequentlySearchedAction()
$this->controllerContext->setSearchResultSet($searchResultSet);

$values = [
'additionalFilters' => $this->searchService->getAdditionalFilters(),
'additionalFilters' => $this->getAdditionalFilters(),
'resultSet' => $searchResultSet
];
$values = $this->emitActionSignal(__CLASS__, __FUNCTION__, [$values]);
Expand Down Expand Up @@ -195,4 +195,15 @@ protected function handleSolrUnavailable()
parent::handleSolrUnavailable();
$this->forward('solrNotAvailable');
}

/**
* This method can be overwritten to add additionalFilters for the autosuggest.
* By default the suggest controller will apply the configured filters from the typoscript configuration.
*
* @return array
*/
protected function getAdditionalFilters()
{
return [];
}
}
5 changes: 5 additions & 0 deletions Classes/Domain/Search/ResultSet/SearchResultSetService.php
Original file line number Diff line number Diff line change
Expand Up @@ -280,10 +280,15 @@ protected function getInitializedSearchResultSet(SearchRequest $searchRequest):S
/**
* Retrieves the configuration filters from the TypoScript configuration, except the __pageSections filter.
*
* @deprecated Since the suggest controller is a controller with a pagetype there is no need to pass around
* the filters that are configured in TypoScript. Therefore this method is not required anymore since the suggest
* controller retrieves the configured filters directly from the typoscript. Nevertheless you can pass view specific
* additionFilters to you search view when needed and they will still be evaluated. Depreacted since EXT:solr 9 will be removed in EXT:solr 10
* @return array
*/
public function getAdditionalFilters()
{
trigger_error('Additional filters in the suggest are now retrieved from typoscript directly and there is no need to keep this. Will be removed in EXT:solr 10.', E_USER_DEPRECATED);
return $this->queryBuilder->getAdditionalFilters();
}

Expand Down

0 comments on commit 7aff158

Please sign in to comment.