Issue Bug Resolved

#110686ExistingTargetFolderException when processing folder is created by a parallel request

Wolfgang Klinger 09/12/26, 05:38 updated 09/25/26, 18:55

Description

ResourceStorage::getNestedProcessingFolder() catches ExistingTargetFolderException
since #96727. ResourceStorage::getProcessingFolder() has the same problem, but no
catch for it.

The code checks first, then creates:

if ($this->driver->folderExists($processingFolder) === false) {
    $rootFolder = $this->getRootLevelFolder(false);
    try {
        $currentEvaluatePermissions = $this->evaluatePermissions;
        $this->evaluatePermissions = false;
        $this->processingFolder = $this->createFolder(
            $processingFolder,
            $rootFolder
        );

Between folderExists() and createFolder() another request can create the same
folder. ResourceStorage::createFolder() then does its own check with
folderExistsInFolder() and throws ExistingTargetFolderException. The catch blocks
around this only handle \InvalidArgumentException,
InsufficientFolderWritePermissionsException and
ResourcePermissionsUnavailableException, so the exception goes up and the request
dies with a 500.

The second branch has the same race. If processingfolder points to another storage
(for example “1:processed”), the code calls $storage->hasFolder() and then
$storage->createFolder(). A fix for only one of the two branches leaves the other
one broken.

The driver itself is not the problem. LocalDriver::createFolder() uses mkdir_deep()
and is fine with an existing folder. Only the check in ResourceStorage throws.

How to reproduce:
Delete the processing folder (or use a fresh install / a new storage), then send
several requests at the same time that need image processing. One request creates
the folder, the others can get the exception.

Inside one request this does not happen. Images are processed one after another and
$this->processingFolder is cached in the object. It needs parallel requests.

Suggested fix, same idea as #96727: catch ExistingTargetFolderException and take the
folder that is already there.

Related: #96727

Reviews 2

History 26

  1. Georg Ringer commented and changed status Under Review Resolved done 0 % 100 % <span data-processor="relativetime" data-value="2026-09-25T18:55:13+00:00" > 09/25/26, 18:55 </span>

    Applied in changeset commit:971f1712a0b877c1f271f294e49612f7ea7c556d.