Bug #73754

LocalDriver sorting bug if multiple file with same timestamp

Added by Yohann CERDAN over 4 years ago. Updated over 2 years ago.

Status:
Closed
Priority:
Should have
Assignee:
Category:
-
Target version:
Start date:
2016-02-29
Due date:
% Done:

100%

TYPO3 Version:
7
PHP Version:
Tags:
Complexity:
Is Regression:
Yes
Sprint Focus:
Stabilization Sprint

Description

Hi,

I found a bug in the typo3_src-7.6.4/typo3/sysext/core/Classes/Resource/Driver/LocalDriver.php.

I use the function retrieveFileAndFoldersInPath() to recursively list file in a Folder. This list is sort by timestamp.

In the function sortDirectoryEntries() we create an array with timestamp=>File.

At the end of this function we do this:


$i = 0;
while (isset($entriesToSort[$sortingKey . $i])) {
 $i++;
}
$entriesToSort[intval($sortingKey . $i)] = $entryArray;

I think the developper implement this to avoid duplicate key, in my case, duplicate timestamp.
So the while() add an extra value to the timestamp. But when you have more than 10 files with the same timestamp, you have a number bigger than before.

Here is a simple example:
  • I have a 9 files wit the timestamp 1355300542.
  • If i have another file with the same timestamp the key will be 135530054210.

To process a sorting on number with strnatcasecmp(), this is a big issue and the list return is not the good one.
This bug happen for sorting file by timesamp and size.


Related issues

Related to TYPO3 Core - Bug #56746: File list always fetches all files in folder Closed 2014-03-11

Associated revisions

Revision c6847d9f (diff)
Added by Frank Naegler almost 4 years ago

[BUGFIX] Natural sorting for integer keys

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/48405
Reviewed-by: Anja Leichsenring <>
Tested-by: Marco Bresch <>
Tested-by: Eugene Kenah Djomo <>
Reviewed-by: Marco Bresch <>
Reviewed-by: Christian Kuhn <>
Tested-by: Christian Kuhn <>

Revision 004913ad (diff)
Added by Frank Naegler almost 4 years ago

[BUGFIX] Natural sorting for integer keys

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 <>
Reviewed-by: Christian Kuhn <>
Tested-by: Christian Kuhn <>

History

#1 Updated by Yohann CERDAN over 4 years ago

Sorry i add intval() in $entriesToSort[intval($sortingKey . $i)] = $entryArray; for testing purpose.

#2 Updated by Riccardo De Contardi about 4 years ago

  • Status changed from New to Needs Feedback

@Yohann: can you tell us if your problem has been solved? Thank you!

#3 Updated by Yohann CERDAN about 4 years ago

Hi, no it doesnt have a "simple" solution. The method to sort the files have to be rewritten because using key can provide some bugs.

#4 Updated by Riccardo De Contardi about 4 years ago

  • Target version changed from 7.6.3 to Candidate for patchlevel

#5 Updated by Riccardo De Contardi about 4 years ago

  • Status changed from Needs Feedback to New

#6 Updated by Gerrit Code Review about 4 years ago

  • Status changed from New to Under Review

Patch set 1 for branch master of project Packages/TYPO3.CMS has been pushed to the review server.
It is available at https://review.typo3.org/48405

#7 Updated by Gerrit Code Review about 4 years ago

Patch set 2 for branch master of project Packages/TYPO3.CMS has been pushed to the review server.
It is available at https://review.typo3.org/48405

#8 Updated by Gerrit Code Review about 4 years ago

Patch set 3 for branch master of project Packages/TYPO3.CMS has been pushed to the review server.
It is available at https://review.typo3.org/48405

#9 Updated by Frank Naegler almost 4 years ago

  • Target version changed from Candidate for patchlevel to 8.2
  • Sprint Focus set to Stabilization Sprint

#10 Updated by Frank Naegler almost 4 years ago

  • Assignee set to Frank Naegler

#11 Updated by Gerrit Code Review almost 4 years ago

Patch set 4 for branch master of project Packages/TYPO3.CMS has been pushed to the review server.
It is available at https://review.typo3.org/48405

#12 Updated by Gerrit Code Review almost 4 years ago

Patch set 1 for branch TYPO3_7-6 of project Packages/TYPO3.CMS has been pushed to the review server.
It is available at https://review.typo3.org/48443

#13 Updated by Frank Naegler almost 4 years ago

  • Status changed from Under Review to Resolved
  • % Done changed from 0 to 100

#14 Updated by Riccardo De Contardi over 2 years ago

  • Status changed from Resolved to Closed

Also available in: Atom PDF