[BUGFIX] Use `addOrderBy()` to support multiple orderings 56/59356/3
authorAndreas Fernandez <a.fernandez@scripting-base.de>
Mon, 7 Jan 2019 14:26:02 +0000 (15:26 +0100)
committerGeorg Ringer <georg.ringer@gmail.com>
Tue, 8 Jan 2019 19:44:54 +0000 (20:44 +0100)
`DatabaseRecordList::prepareQueryBuilder()` is able to handle multiple
order clauses defined in either `sortby` or `default_sortby`. However,
the wrong method for appending the order clause is used, which results in
overriding the previous set clause.

This patch changes the method to use `addOrderBy()` instead which appends
multiple order clauses properly.

Resolves: #87352
Releases: master, 9.5
Change-Id: I08f4248d4dc890079715efb9a48b1d270a6b1077
Reviewed-on: https://review.typo3.org/59356
Tested-by: TYPO3com <no-reply@typo3.com>
Reviewed-by: featdd <dorndorf@featdd.de>
Tested-by: featdd <dorndorf@featdd.de>
Reviewed-by: Wouter Wolters <typo3@wouterwolters.nl>
Tested-by: Wouter Wolters <typo3@wouterwolters.nl>
Reviewed-by: Georg Ringer <georg.ringer@gmail.com>
Tested-by: Georg Ringer <georg.ringer@gmail.com>
typo3/sysext/backend/Classes/View/PageLayoutView.php
typo3/sysext/recordlist/Classes/RecordList/DatabaseRecordList.php

index 77d71b4..380b9e1 100644 (file)
@@ -3376,7 +3376,7 @@ class PageLayoutView implements LoggerAwareInterface
                 $orderBy = $GLOBALS['TCA'][$table]['ctrl']['sortby'] ?: $GLOBALS['TCA'][$table]['ctrl']['default_sortby'];
                 $orderBys = QueryHelper::parseOrderBy((string)$orderBy);
                 foreach ($orderBys as $orderBy) {
-                    $queryBuilder->orderBy($orderBy[0], $orderBy[1]);
+                    $queryBuilder->addOrderBy($orderBy[0], $orderBy[1]);
                 }
             }
         }
index 0ada2cd..df11ef5 100644 (file)
@@ -3295,7 +3295,7 @@ class DatabaseRecordList
                 $orderBy = $GLOBALS['TCA'][$table]['ctrl']['sortby'] ?: $GLOBALS['TCA'][$table]['ctrl']['default_sortby'];
                 $orderBys = QueryHelper::parseOrderBy((string)$orderBy);
                 foreach ($orderBys as $orderBy) {
-                    $queryBuilder->orderBy($orderBy[0], $orderBy[1]);
+                    $queryBuilder->addOrderBy($orderBy[0], $orderBy[1]);
                 }
             }
         }