Skip to content

Commit

Permalink
[BUGFIX] Filter null collections (kitodo#1461)
Browse files Browse the repository at this point in the history
  • Loading branch information
beatrycze-volk authored Feb 4, 2025
1 parent ea4b14f commit 3328552
Showing 1 changed file with 15 additions and 0 deletions.
15 changes: 15 additions & 0 deletions Classes/Common/Solr/SolrSearch.php
Original file line number Diff line number Diff line change
Expand Up @@ -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()) {
Expand Down Expand Up @@ -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.
*
Expand Down

0 comments on commit 3328552

Please sign in to comment.