[FOLLOWUP][TASK] Doctrine: Migrate \TYPO3\CMS\Frontend\Page\PageRepository
[Packages/TYPO3.CMS.git] / typo3 / sysext / frontend / Classes / Page / PageRepository.php
index aa9963f..a22b7aa 100644 (file)
@@ -697,16 +697,19 @@ class PageRepository
         $queryBuilder = GeneralUtility::makeInstance(ConnectionPool::class)->getQueryBuilderForTable('pages');
         $queryBuilder->getRestrictions()->removeAll();
 
-        $result = $queryBuilder->select(...GeneralUtility::trimExplode(',', $fields, true))
+        $res = $queryBuilder->select(...GeneralUtility::trimExplode(',', $fields, true))
             ->from('pages')
             ->where(
                 $queryBuilder->expr()->in($relationField, array_map('intval', $pageIds)),
                 QueryHelper::stripLogicalOperatorPrefix($this->where_hid_del),
                 QueryHelper::stripLogicalOperatorPrefix($this->where_groupAccess),
                 QueryHelper::stripLogicalOperatorPrefix($additionalWhereClause)
-            )
-            ->orderBy($sortField)
-            ->execute();
+            );
+
+        if (!empty($sortField)) {
+            $res->orderBy($sortField);
+        }
+        $result = $res->execute();
 
         while ($page = $result->fetch()) {
             $originalUid = $page['uid'];