[BUGFIX] Enforce processing folder generation 38/48838/2
authorNicole Cordes <typo3@cordes.co>
Fri, 6 May 2016 18:18:22 +0000 (20:18 +0200)
committerFrank Naegler <frank.naegler@typo3.org>
Fri, 8 Jul 2016 12:26:57 +0000 (14:26 +0200)
If the processing folder of a storage was deleted and the current user
isn't allowed to create new folders, an exception is thrown. This patch
turns off the access check to allow generation of the processing folder.

Resolves: #76067
Releases: master, 7.6
Change-Id: Idd096b44753ab438916d45ff2d6f085118ab2bcf
Reviewed-on: https://review.typo3.org/48838
Reviewed-by: Frank Naegler <frank.naegler@typo3.org>
Tested-by: Frank Naegler <frank.naegler@typo3.org>
typo3/sysext/core/Classes/Resource/ResourceStorage.php

index c2be560..862ebda 100644 (file)
@@ -2855,11 +2855,25 @@ class ResourceStorage implements ResourceStorageInterface
                     if ($storage->hasFolder($processingFolderIdentifier)) {
                         $this->processingFolder = $storage->getFolder($processingFolderIdentifier);
                     } else {
-                        $this->processingFolder = $storage->createFolder(ltrim($processingFolderIdentifier, '/'));
+                        $rootFolder = $storage->getRootLevelFolder(false);
+                        $currentEvaluatePermissions = $storage->getEvaluatePermissions();
+                        $storage->setEvaluatePermissions(false);
+                        $this->processingFolder = $storage->createFolder(
+                            ltrim($processingFolderIdentifier, '/'),
+                            $rootFolder
+                        );
+                        $storage->setEvaluatePermissions($currentEvaluatePermissions);
                     }
                 } else {
                     if ($this->driver->folderExists($processingFolder) === false) {
-                        $this->processingFolder = $this->createFolder($processingFolder);
+                        $rootFolder = $this->getRootLevelFolder(false);
+                        $currentEvaluatePermissions = $this->evaluatePermissions;
+                        $this->evaluatePermissions = false;
+                        $this->processingFolder = $this->createFolder(
+                            $processingFolder,
+                            $rootFolder
+                        );
+                        $this->evaluatePermissions = $currentEvaluatePermissions;
                     } else {
                         $data = $this->driver->getFolderInfoByIdentifier($processingFolder);
                         $this->processingFolder = ResourceFactory::getInstance()->createFolderObject($this, $data['identifier'], $data['name']);
@@ -2905,7 +2919,10 @@ class ResourceStorage implements ResourceStorageInterface
                 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);
                 }
             }
         } catch (Exception\FolderDoesNotExistException $e) {
@@ -2919,7 +2936,7 @@ class ResourceStorage implements ResourceStorageInterface
      *
      * @param string $fileIdentifier
      * @param int $levels
-     * @return []
+     * @return string[]
      */
     protected function getNamesForNestedProcessingFolder($fileIdentifier, $levels)
     {