[BUGFIX] Check default storage first to find default upload folder 01/37401/2
authorFrans Saris <franssaris@gmail.com>
Tue, 24 Feb 2015 10:22:34 +0000 (11:22 +0100)
committerAnja Leichsenring <aleichsenring@ab-softlab.de>
Sun, 1 Mar 2015 11:08:19 +0000 (12:08 +0100)
Resolves: #65040
Releases: master, 6.2
Change-Id: I14d6d362db1796c90b03254f6339cb131f152a45
Reviewed-on: http://review.typo3.org/37401
Reviewed-by: Anja Leichsenring <aleichsenring@ab-softlab.de>
Tested-by: Anja Leichsenring <aleichsenring@ab-softlab.de>
typo3/sysext/core/Classes/Authentication/BackendUserAuthentication.php

index 575fd22..90ba74b 100644 (file)
@@ -14,6 +14,7 @@ namespace TYPO3\CMS\Core\Authentication;
  * The TYPO3 project - inspiring people to share!
  */
 
+use TYPO3\CMS\Core\Resource\ResourceStorage;
 use TYPO3\CMS\Core\Utility\GeneralUtility;
 use TYPO3\CMS\Backend\Utility\BackendUtility;
 
@@ -1887,11 +1888,25 @@ class BackendUserAuthentication extends \TYPO3\CMS\Core\Authentication\AbstractU
                        $uploadFolder = \TYPO3\CMS\Core\Resource\ResourceFactory::getInstance()->getFolderObjectFromCombinedIdentifier($uploadFolder);
                } else {
                        foreach($this->getFileStorages() as $storage) {
-                               try {
-                                       $uploadFolder = $storage->getDefaultFolder();
+                               if ($storage->isDefault()) {
+                                       try {
+                                               $uploadFolder = $storage->getDefaultFolder();
+                                               break;
+                                       } catch (\TYPO3\CMS\Core\Resource\Exception $folderAccessException) {
+                                               // If the folder is not accessible (no permissions / does not exist) we skip this one.
+                                       }
                                        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) {
+                               /** @var ResourceStorage $storage */
+                               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.
+                                       }
                                }
                        }
                }