diff --git a/Classes/Common/Solr/SolrSearch.php b/Classes/Common/Solr/SolrSearch.php index 03bd97685..24e8ece38 100644 --- a/Classes/Common/Solr/SolrSearch.php +++ b/Classes/Common/Solr/SolrSearch.php @@ -781,6 +781,9 @@ private function getCollectionFilterQuery(string $query) : string { $collectionsQueryString = ''; $virtualCollectionsQueryString = ''; + + $this->filterCollections(); + foreach ($this->collections as $collection) { // check for virtual collections query string if ($collection->getIndexSearch()) { @@ -808,6 +811,18 @@ private function getCollectionFilterQuery(string $query) : string return implode(' OR ', array_filter([$collectionsQueryString, $virtualCollectionsQueryString])); } + /** + * Filter collections to avoid null values. + * + * @return void + */ + private function filterCollections(): void + { + if (is_array($this->collections)) { + array_filter($this->collections, fn($value) => $value !== null); + } + } + /** * Get sort order of the results as given or by title as default. *