[BUGFIX] Prevent permission Exception in ElementBrowser 45/27145/3
authorAlexander Stehlik <alexander.stehlik@googlemail.com>
Thu, 30 Jan 2014 12:02:38 +0000 (13:02 +0100)
committerFrans Saris <franssaris@gmail.com>
Fri, 31 Jan 2014 11:29:29 +0000 (12:29 +0100)
To prevent Exceptions in the ElementBrowser resource Exceptions are
catched in two places:

The Exception is catched in the ElementBrowser itsself when the
previously selected folder is not accessible.

Additionally the Exception is cached in the getDefaultUploadFolder()
method in BackendUserAuthentication when the default folder of a
storage is not accessible.

Resolves: #55439
Releases: 6.2
Change-Id: I64848c3a88cc2cc571c0bf692101647b95666972
Reviewed-on: https://review.typo3.org/27145
Reviewed-by: Anja Leichsenring
Tested-by: Anja Leichsenring
Reviewed-by: Stefan Froemken
Tested-by: Stefan Froemken
Reviewed-by: Frans Saris
Tested-by: Frans Saris
typo3/sysext/core/Classes/Authentication/BackendUserAuthentication.php
typo3/sysext/recordlist/Classes/Browser/ElementBrowser.php

index 9729fdb..469eb7d 100644 (file)
@@ -1736,11 +1736,13 @@ class BackendUserAuthentication extends \TYPO3\CMS\Core\Authentication\AbstractU
                if ($uploadFolder) {
                        $uploadFolder = \TYPO3\CMS\Core\Resource\ResourceFactory::getInstance()->getFolderObjectFromCombinedIdentifier($uploadFolder);
                } else {
-                       $storages = $this->getFileStorages();
-                       if (count($storages) > 0) {
-                               /** @var $firstStorage \TYPO3\CMS\Core\Resource\ResourceStorage */
-                               $firstStorage = reset($storages);
-                               $uploadFolder = $firstStorage->getDefaultFolder();
+                       foreach($this->getFileStorages() as $storage) {
+                               try {
+                                       $uploadFolder = $storage->getDefaultFolder();
+                                       break;
+                               } catch (\TYPO3\CMS\Core\Resource\Exception $folderAccessException) {
+                                       // If the folder is not accessible (no permissions / does not exist) try the next one.
+                               }
                        }
                }
                if ($uploadFolder instanceof \TYPO3\CMS\Core\Resource\Folder) {
index 1027f73..b6f443d 100644 (file)
@@ -1308,14 +1308,15 @@ class ElementBrowser {
                // Create upload/create folder forms, if a path is given
                if ($this->expandFolder) {
                        $this->selectedFolder = FALSE;
+                       $fileOrFolderObject = NULL;
 
-                       // try to fetch the folder the user had open the last time he browsed files
-                       // fallback to the default folder in case the last used folder is not existing
+                       // Try to fetch the folder the user had open the last time he browsed files
+                       // Fallback to the default folder in case the last used folder is not existing
                        try {
                                $fileOrFolderObject = \TYPO3\CMS\Core\Resource\ResourceFactory::getInstance()->retrieveFileOrFolderObject($this->expandFolder);
-                       } catch (\TYPO3\CMS\Core\Resource\Exception\ResourceDoesNotExistException $inexistentFolderException) {
-                               // we're just catching the exception here, nothing to be done if folder does not exist
-                       };
+                       } catch (\TYPO3\CMS\Core\Resource\Exception $accessException) {
+                               // We're just catching the exception here, nothing to be done if folder does not exist or is not accessible.
+                       }
 
                        if ($fileOrFolderObject instanceof \TYPO3\CMS\Core\Resource\Folder) {
                                // It's a folder