Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[BUGFIX:BP:11.5] add empty string as fallback #3559

Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -37,6 +37,6 @@ class QueryGroupUrlDecoder implements FacetUrlDecoderInterface
*/
public function decode(string $value, array $configuration = []): string
{
return $configuration[$value . '.']['query'];
return $configuration[$value . '.']['query'] ?? '';
}
}
17 changes: 14 additions & 3 deletions Classes/Query/Modifier/Faceting.php
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,8 @@
use ApacheSolrForTypo3\Solr\Domain\Search\SearchRequestAware;
use ApacheSolrForTypo3\Solr\System\Configuration\TypoScriptConfiguration;
use InvalidArgumentException;
use TYPO3\CMS\Core\Log\LogManager;
use TYPO3\CMS\Core\Utility\GeneralUtility;

/**
* Modifies a query to add faceting parameters
Expand Down Expand Up @@ -155,8 +157,11 @@ protected function addFacetQueryFilters(array $resultParameters, bool $keepAllFa
$facetConfiguration = $allFacets[$facetName . '.'];
$tag = $this->getFilterTag($facetConfiguration, $keepAllFacetsOnSelection);
$filterParts = $this->getFilterParts($facetConfiguration, $facetName, $filterValues);
$operator = (($facetConfiguration['operator'] ?? null) === 'OR') ? ' OR ' : ' AND ';
$facetFilters[$facetName] = $tag . '(' . implode($operator, $filterParts) . ')';

if (!empty($filterParts)) {
$operator = (($facetConfiguration['operator'] ?? null) === 'OR') ? ' OR ' : ' AND ';
$facetFilters[$facetName] = $tag . '(' . implode($operator, $filterParts) . ')';
}
}

return $facetFilters;
Expand Down Expand Up @@ -208,7 +213,13 @@ protected function getFilterParts(array $facetConfiguration, string $facetName,
}

$filterValue = $filterEncoder->decode($filterValue, $filterOptions);
$filterParts[] = $facetConfiguration['field'] . ':' . $filterValue;
if (($facetConfiguration['field'] ?? '') !== '' && $filterValue !== '') {
$filterParts[] = $facetConfiguration['field'] . ':' . $filterValue;
} else {
/** @var $logger \TYPO3\CMS\Core\Log\Logger */
$logger = GeneralUtility::makeInstance(LogManager::class)->getLogger(__CLASS__);
$logger->warning('Invalid filter options found, skipping.', ['facet' => $facetName, 'configuration' => $facetConfiguration]);
}
}

return $filterParts;
Expand Down