[BUGFIX] Return InaccessibleFolder for non existing processed folder 97/36397/3
authorFrans Saris <franssaris@gmail.com>
Fri, 30 Jan 2015 08:50:03 +0000 (09:50 +0100)
committerFrans Saris <franssaris@gmail.com>
Fri, 30 Jan 2015 22:03:51 +0000 (23:03 +0100)
When the processed folder of a folder isn't present the ResourceStorage
tries to create it. When storage is offline or write-only this will fail
and as a result you run into exceptions on several places in BE.

This change makes sure there is a InaccessibleFolder object returned
in these cases.

Resolves: #61688
Releases: master, 6.2
Change-Id: Ie32c09f8d322914234860903c18ca44ff5cbf5db
Reviewed-on: http://review.typo3.org/36397
Reviewed-by: Frans Saris <franssaris@gmail.com>
Tested-by: Frans Saris <franssaris@gmail.com>
typo3/sysext/core/Classes/Resource/ResourceStorage.php

index 0039efd..557dea3 100644 (file)
@@ -14,6 +14,7 @@ namespace TYPO3\CMS\Core\Resource;
  * The TYPO3 project - inspiring people to share!
  */
 
+use TYPO3\CMS\Core\Resource\Exception\InsufficientFolderWritePermissionsException;
 use TYPO3\CMS\Core\Resource\Index\FileIndexRepository;
 use TYPO3\CMS\Core\Utility\GeneralUtility;
 use TYPO3\CMS\Core\Utility\PathUtility;
@@ -2517,11 +2518,17 @@ class ResourceStorage implements ResourceStorageInterface {
                        if (!empty($this->storageRecord['processingfolder'])) {
                                $processingFolder = $this->storageRecord['processingfolder'];
                        }
-                       if ($this->driver->folderExists($processingFolder) === FALSE) {
-                               $this->processingFolder = $this->createFolder($processingFolder);
-                       } else {
-                               $data = $this->driver->getFolderInfoByIdentifier($processingFolder);
-                               $this->processingFolder = ResourceFactory::getInstance()->createFolderObject($this, $data['identifier'], $data['name']);
+                       try {
+                               if ($this->driver->folderExists($processingFolder) === FALSE) {
+                                       $this->processingFolder = $this->createFolder($processingFolder);
+                               } else {
+                                       $data = $this->driver->getFolderInfoByIdentifier($processingFolder);
+                                       $this->processingFolder = ResourceFactory::getInstance()->createFolderObject($this, $data['identifier'], $data['name']);
+                               }
+                       } catch(InsufficientFolderWritePermissionsException $e) {
+                               $this->processingFolder = GeneralUtility::makeInstance(
+                                       'TYPO3\\CMS\\Core\\Resource\\InaccessibleFolder', $this, $processingFolder, $processingFolder
+                               );
                        }
                }
                return $this->processingFolder;