Project

General

Profile

Actions

Bug #88696

closed

DataHandler getSortNumber use of increaseSortingOfFollowing wrong

Added by F Altrock almost 5 years ago. Updated almost 5 years ago.

Status:
Closed
Priority:
Should have
Assignee:
-
Category:
DataHandler aka TCEmain
Target version:
-
Start date:
2019-07-05
Due date:
% Done:

0%

Estimated time:
TYPO3 Version:
9
PHP Version:
7.2
Tags:
Complexity:
easy
Is Regression:
Yes
Sprint Focus:

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:

https://github.com/TYPO3-CMS/core/blob/36060d9992e72a43ef398b6b33e9099a216a686d/Classes/DataHandling/DataHandler.php#L6845

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

https://github.com/TYPO3-CMS/core/blob/36060d9992e72a43ef398b6b33e9099a216a686d/Classes/DataHandling/DataHandler.php#L6941

(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

page_with_11_content_elements.png (37.9 KB) page_with_11_content_elements.png Bug precondition: a page with at least 11 content elements F Altrock, 2019-07-05 16:30
page_with_11_content_elements_BUG.png (46.8 KB) page_with_11_content_elements_BUG.png Bug result: wrong sorting of content elements in copied page F Altrock, 2019-07-05 16:33

Related issues 3 (0 open3 closed)

Related to TYPO3 Core - Task #85300: Improve record sorting performanceClosed2018-06-18

Actions
Is duplicate of TYPO3 Core - Bug #87612: Content element sorting wrong when one element has sorting value of zeroClosedMarkus Klein2019-02-01

Actions
Is duplicate of TYPO3 Core - Bug #88051: Wrong CE order when copying pages with more than 10 CEs per columnClosed2019-04-02

Actions
Actions #1

Updated by F Altrock almost 5 years ago

  • Description updated (diff)
Actions #2

Updated by Tymoteusz Motylewski almost 5 years ago

  • Related to Task #85300: Improve record sorting performance added
Actions #3

Updated by Jonas Eberle almost 5 years ago

Is this maybe related? https://forge.typo3.org/issues/87612
If you think so, could you please try the patch?

Actions #4

Updated by F Altrock almost 5 years ago

  • Is duplicate of Bug #87612: Content element sorting wrong when one element has sorting value of zero added
Actions #5

Updated by F Altrock almost 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.

Actions #6

Updated by F Altrock almost 5 years ago

  • Is duplicate of Bug #88051: Wrong CE order when copying pages with more than 10 CEs per column added
Actions #7

Updated by Markus Klein almost 5 years ago

  • Status changed from New to Closed

Closed as duplicate

Actions

Also available in: Atom PDF