[BUGFIX] Natural sorting for integer keys 43/48443/2
authorFrank Naegler <frank.naegler@typo3.org>
Mon, 30 May 2016 14:22:05 +0000 (16:22 +0200)
committerChristian Kuhn <lolli@schwarzbu.ch>
Fri, 3 Jun 2016 15:07:31 +0000 (17:07 +0200)
LocalDriver has a sorting bug if multiple files have
the same timestamp or size.
This patch adds a character to the sorting key to sort correctly.

Resolves: #73754
Releases: master, 7.6
Change-Id: Ie1ae0c11eea5a3bdf9ad23b0d4855364e5a62bab
Reviewed-on: https://review.typo3.org/48443
Reviewed-by: Markus Klein <markus.klein@typo3.org>
Reviewed-by: Christian Kuhn <lolli@schwarzbu.ch>
Tested-by: Christian Kuhn <lolli@schwarzbu.ch>
typo3/sysext/core/Classes/Resource/Driver/LocalDriver.php

index d8a0776..845c17f 100644 (file)
@@ -589,11 +589,12 @@ class LocalDriver extends AbstractHierarchicalFilesystemDriver
             $fullPath = $this->getAbsoluteBasePath() . $entryArray['identifier'];
             switch ($sort) {
                 case 'size':
+                    $sortingKey = '0';
                     if ($entryArray['type'] === 'file') {
                         $sortingKey = $this->getSpecificFileInformation($fullPath, $dir, 'size');
-                    } else {
-                        $sortingKey = '0';
                     }
+                    // Add a character for a natural order sorting
+                    $sortingKey .= 's';
                     break;
                 case 'rw':
                     $perms = $this->getPermissions($entryArray['identifier']);
@@ -604,11 +605,12 @@ class LocalDriver extends AbstractHierarchicalFilesystemDriver
                     $sortingKey = pathinfo($entryArray['name'], PATHINFO_EXTENSION);
                     break;
                 case 'tstamp':
+                    $sortingKey = '0';
                     if ($entryArray['type'] === 'file') {
                         $sortingKey = $this->getSpecificFileInformation($fullPath, $dir, 'mtime');
-                    } else {
-                        $sortingKey = '0';
                     }
+                    // Add a character for a natural order sorting
+                    $sortingKey .= 't';
                     break;
                 case 'name':
                 case 'file':