Bug #88696
closedDataHandler getSortNumber use of increaseSortingOfFollowing wrong
0%
Description
Bug description¶
After copying a page, a single content element is sorted at the very top instead of where it was previously.
Inspecting the sorting
column in the List module reveals a sorting value of 0
for this one content element.
Impact¶
AFAICS the bug was introduced by https://review.typo3.org/c/Packages/TYPO3.CMS/+/57218/ in August 2018, so
all versions of TYPO3 since 9.4.0 are affected.
Repro setup:¶
- Create a page with 11 content elements, for example 11 headers with numbers 1-11.
- Check that the sorting is correct in the list module.
(see first screenshot) - Copy the page into the clipboard
- Paste the page anywhere, paste mode is not important
- Check the sorting of the content elements in the new page
- See that heading "2" has been sorted at the very top with sorting 0
(see second screenshot)
Source of the bug¶
The method getSortNumber
of class DataHandler
checks for the minimum sorting value in a table
when inserting a new record and halves the value for the new record. When copying a page, the first
record gets the value 256, thus after 10 records we are at sorting value 0.
The 11th record then triggers a re-sorting via the method increaseSortingOfFollowing
:
but crucially the value 0
is passed for the sortingValue
, and that method:
Increases sorting field value of all records with sorting higher than $sortingNumber
(Aside: the parameter variable name should be $sortingValue
here.)
Fix¶
getSortNumber
should use -1
as the sortingValue
passed to increaseSortingOfFollowingRecords
.
This way all records in the new page get re-sorted, not just the ones with a sorting value > 0
.
Files
Updated by Tymoteusz Motylewski over 5 years ago
- Related to Task #85300: Improve record sorting performance added
Updated by Jonas Eberle over 5 years ago
Is this maybe related? https://forge.typo3.org/issues/87612
If you think so, could you please try the patch?
Updated by F Altrock over 5 years ago
- Is duplicate of Bug #87612: Content element sorting wrong when one element has sorting value of zero added
Updated by F Altrock over 5 years ago
It is the same bug, and my proposed fix is basically the same as the patch https://review.typo3.org/c/Packages/TYPO3.CMS/+/59604/ -
to use sorting > (current_lowest_sorting) -1
as the re-sort query condition.
Updated by F Altrock over 5 years ago
- Is duplicate of Bug #88051: Wrong CE order when copying pages with more than 10 CEs per column added