Commit 0b9df659 authored by Stefan Bürk's avatar Stefan Bürk
Browse files

[BUGFIX] Ensure deterministic sorting in `PageTreeRepository`

Using database queries without deterministic sorting
definition may lead to unreliabe resultsets in some
dbms type and version, which also may change over time.
Thus it's good practice to have proper defined sorting
for queries, at least if result relies on a constant
and reliable result sorting.

With #96512 and #97774 additional tests has been added,
which showed the unreliable of these database queries,
blocking the bugfix backport to TYPO3 v10.4.

This patch adds sorting definition to two db queries in
`\TYPO3\CMS\Backend\Tree\Repository\PageTreeRepository`
to ensure consistent results in a deterministic manner
and make it possible to provide the related bugfix for
TYPO3 v10.4.

Resolves: #98056
Related: #96512
Related: #97774
Releases: main, 11.5, 10.4
Change-Id: I8a1bf3b93bcfcaec4c3de3ea6321db62847d0c21
Reviewed-on: https://review.typo3.org/c/Packages/TYPO3.CMS/+/75333


Tested-by: core-ci's avatarcore-ci <typo3@b13.com>
Tested-by: Christian Kuhn's avatarChristian Kuhn <lolli@schwarzbu.ch>
Tested-by: Nikita Hovratov's avatarNikita Hovratov <nikita.h@live.de>
Tested-by: Stefan Bürk's avatarStefan Bürk <stefan@buerk.tech>
Reviewed-by: Christian Kuhn's avatarChristian Kuhn <lolli@schwarzbu.ch>
Reviewed-by: Oliver Klee's avatarOliver Klee <typo3-coding@oliverklee.de>
Reviewed-by: Nikita Hovratov's avatarNikita Hovratov <nikita.h@live.de>
Reviewed-by: Stefan Bürk's avatarStefan Bürk <stefan@buerk.tech>
parent 6193f3fb
......@@ -232,7 +232,10 @@ class PageTreeRepository
)
->andWhere(
QueryHelper::stripLogicalOperatorPrefix($GLOBALS['BE_USER']->getPagePermsClause(Permission::PAGE_SHOW))
);
)
// ensure deterministic sorting
->orderBy('sorting', 'ASC')
->addOrderBy('uid', 'ASC');
if (count($pageIds) > 0) {
$queryBuilder->andWhere(
......@@ -284,6 +287,9 @@ class PageTreeRepository
->where(
$queryBuilder->expr()->in('uid', $queryBuilder->createNamedParameter($recordIds, Connection::PARAM_INT_ARRAY))
)
// ensure deterministic sorting
->orderBy('sorting', 'ASC')
->addOrderBy('uid', 'ASC')
->executeQuery()
->fetchAllAssociative();
......
Supports Markdown
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