Actions
Bug #88455
closedNever attach random string if file already exists in folder
Status:
Closed
Priority:
Should have
Assignee:
-
Category:
-
Target version:
-
Start date:
2019-05-29
Due date:
% Done:
100%
Estimated time:
TYPO3 Version:
8
PHP Version:
Tags:
Complexity:
Is Regression:
Sprint Focus:
Description
\TYPO3\CMS\Core\Utility\File\BasicFileUtility::getUniqueName
The inner condition never can be reached if $a equals $this->maxNumber. Result is, that "then we try unique-strings" never can be executed
for ($a = 1; $a < $this->maxNumber; $a++) {
if ($a <= $this->maxNumber) {
// First we try to append numbers
$insert = '_' . sprintf('%02d', $a);
} else {
// .. then we try unique-strings...
$insert = '_' . substr(md5(uniqid('', true)), 0, $this->uniquePrecision);
}
Working Code
for ($a = 1; $a <= $this->maxNumber; $a++) {
if ($a < $this->maxNumber) {
// First we try to append numbers
$insert = '_' . sprintf('%02d', $a);
} else {
// .. then we try unique-strings...
$insert = '_' . substr(md5(uniqid('', true)), 0, $this->uniquePrecision);
}
The change was made in 30282eef79e069fe78ea39e53df2fc003bc6c2f4 [!!!][TASK] Cleanup and remove old filefunc logic on 2016-01-08 by Benni Mack
Actions