Project

General

Profile

Bug #88696

Updated by F Altrock over 5 years ago

h2. 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. 

 h2. 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. 

 h2. 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) 

 h2. 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 

 @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 

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

 (Aside: the parameter variable name should be @$sortingValue@ here.) 

 h2. 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@. 

Back