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

Also available in: Atom PDF