Project

General

Profile

Actions

Bug #88455

closed

Never attach random string if file already exists in folder

Added by Thomas Walder about 5 years ago. Updated over 4 years ago.

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


Related issues 2 (0 open2 closed)

Related to TYPO3 Core - Task #76257: Cleanup and remove old filefunc logicClosedBenni Mack2016-05-22

Actions
Is duplicate of TYPO3 Core - Bug #88332: incorrect generation of unique file name in BasicFileUtilityClosed2019-05-10

Actions
Actions

Also available in: Atom PDF