Commit 4cb2db24 authored by Thomas Löffler's avatar Thomas Löffler

[BUGFIX] Remove exception when using not existing sorting field

parent cc56c35a
Pipeline #9794 passed with stages
in 6 minutes and 7 seconds
......@@ -37,6 +37,7 @@
"ext-zip": "*",
"ext-zlib": "*",
"apache-solr-for-typo3/solr": "^11.0",
"cweagans/composer-patches": "^1.7",
"gordalina/cachetool": "^4.0",
"nimut/testing-framework": "^5.0",
"t3o/t3olayout": "^5.0",
......@@ -69,7 +70,8 @@
"typo3/cms": {
"web-dir": "public",
"root-dir": "private"
}
},
"patches-file": "composer.patches.json"
},
"scripts": {
"test:unit": [
......
This diff is collapsed.
{
"patches": {
"apache-solr-for-typo3/solr": {
"Do not throw exception for wrong sorting parameter": "patches/sorting-field.diff"
}
}
}
--- Classes/Domain/Search/ResultSet/Sorting/SortingHelper.php 2020-10-21 10:26:40.000000000 +0200
+++ Classes/Domain/Search/ResultSet/Sorting/SortingHelperNew.php 2020-10-21 10:26:52.000000000 +0200
@@ -69,12 +69,10 @@
foreach ($sortParameters as $sortParameter) {
list($sortOption, $sortDirection) = explode(' ', $sortParameter);
- if (!in_array($sortOption, $configuredSortingName)) {
- throw new \InvalidArgumentException('No sorting configuration found for option name ' . $sortOption, 1316187644);
+ if (in_array($sortOption, $configuredSortingName)) {
+ $sortField = $this->configuration[$sortOption . '.']['field'];
+ $sortFields[] = $sortField . ' ' . $sortDirection;
}
-
- $sortField = $this->configuration[$sortOption . '.']['field'];
- $sortFields[] = $sortField . ' ' . $sortDirection;
}
return implode(', ', $sortFields);
--- Classes/Search/SortingComponent.php 2020-10-21 10:32:58.000000000 +0200
+++ Classes/Search/SortingComponentNew.php 2020-10-21 10:32:58.000000000 +0200
@@ -100,7 +100,9 @@
/** @var $sortHelper SortingHelper */
$sortHelper = GeneralUtility::makeInstance(SortingHelper::class, $this->searchConfiguration['sorting.']['options.']);
$sortFields = $sortHelper->getSortFieldFromUrlParameter($arguments['sort']);
- $this->queryBuilder->useSortings(Sortings::fromString($sortFields));
+ if ($sortFields) {
+ $this->queryBuilder->useSortings(Sortings::fromString($sortFields));
+ }
$this->query = $this->queryBuilder->getQuery();
}
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment