Project

General

Profile

Actions

Bug #96727

open

ExistingTargetFolderException not handled correctly

Added by Michael Grundkötter almost 3 years ago. Updated about 1 month ago.

Status:
Under Review
Priority:
Should have
Category:
-
Target version:
-
Start date:
2022-02-02
Due date:
% Done:

0%

Estimated time:
TYPO3 Version:
10
PHP Version:
7.3
Tags:
Complexity:
Is Regression:
Sprint Focus:

Description

In `TYPO3\CMS\Core\Resource\ResourceStorage::getNestedProcessingFolder` there is this code:

foreach ($nestedFolderNames as $folderName) {
    if ($processingFolder->hasFolder($folderName)) {
        $processingFolder = $processingFolder->getSubfolder($folderName);
    } else {
        $currentEvaluatePermissions = $processingFolder->getStorage()->getEvaluatePermissions();
        $processingFolder->getStorage()->setEvaluatePermissions(false);
        $processingFolder = $processingFolder->createFolder($folderName);
        $processingFolder->getStorage()->setEvaluatePermissions($currentEvaluatePermissions);
    }
}

and the call to `$processingFolder->createFolder()` can cause an ExistingTargetFolderException, which may be caused by parallel actions of multiple editors or whatever. Although the issue seem to be handled by `$processingFolder->hasFolder($folderName)` right above, the exception does occur in our sentry system nevertheless. Hence, this code block should be changed like this instead to prevent the process from terminating completely:
foreach ($nestedFolderNames as $folderName) {
    if ($processingFolder->hasFolder($folderName)) {
        $processingFolder = $processingFolder->getSubfolder($folderName);
    } else {
        $currentEvaluatePermissions = $processingFolder->getStorage()->getEvaluatePermissions();
        $processingFolder->getStorage()->setEvaluatePermissions(false);
        try {
            $processingFolder = $processingFolder->createFolder($folderName);
            $processingFolder->getStorage()->setEvaluatePermissions($currentEvaluatePermissions);
        } catch (ExistingTargetFolderException $existingTargetFolderException) {
            $processingFolder = $processingFolder->getSubfolder($folderName);
        }
    }
}
Actions #1

Updated by Gerrit Code Review 5 months ago

  • Status changed from New to Under Review

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

Actions #2

Updated by Mathias Brodala 5 months ago

  • Assignee set to Mathias Brodala
Actions #3

Updated by Mathias Brodala 5 months ago

We see the same issue by using ichhabrecht/filefill. Here it is expected that files and folders are created by parallel requests.

Actions #4

Updated by Gerrit Code Review 5 months ago

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

Actions #5

Updated by Gerrit Code Review about 1 month ago

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

Actions #6

Updated by Gerrit Code Review about 1 month ago

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

Actions

Also available in: Atom PDF