From 3861622236f587e490bce30f32ae63163c496c7b Mon Sep 17 00:00:00 2001 From: Frans Saris <franssaris@gmail.com> Date: Tue, 24 Feb 2015 11:22:34 +0100 Subject: [PATCH] [BUGFIX] Check default storage first to find default upload folder Resolves: #65040 Releases: master, 6.2 Change-Id: I14d6d362db1796c90b03254f6339cb131f152a45 Reviewed-on: http://review.typo3.org/37159 Reviewed-by: Viktor Livakivskyi <invisible.kinder@gmail.com> Tested-by: Viktor Livakivskyi <invisible.kinder@gmail.com> Reviewed-by: Wouter Wolters <typo3@wouterwolters.nl> Reviewed-by: Michael Oehlhof <typo3@oehlhof.de> Reviewed-by: Anja Leichsenring <aleichsenring@ab-softlab.de> Tested-by: Anja Leichsenring <aleichsenring@ab-softlab.de> --- .../BackendUserAuthentication.php | 23 +++++++++++++++---- 1 file changed, 19 insertions(+), 4 deletions(-) diff --git a/typo3/sysext/core/Classes/Authentication/BackendUserAuthentication.php b/typo3/sysext/core/Classes/Authentication/BackendUserAuthentication.php index 58690847c358..5dafdd138cf9 100644 --- a/typo3/sysext/core/Classes/Authentication/BackendUserAuthentication.php +++ b/typo3/sysext/core/Classes/Authentication/BackendUserAuthentication.php @@ -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; @@ -1833,11 +1834,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. + } } } } -- GitLab