[BUGFIX] Check if storage exists before accessing it 34/29634/5
authorChristian Weiske <cweiske@cweiske.de>
Thu, 24 Apr 2014 09:23:26 +0000 (11:23 +0200)
committerXavier Perseguers <xavier@typo3.org>
Mon, 12 May 2014 08:38:34 +0000 (10:38 +0200)
When editing a file mount in the backend, we need to check if
the storage backend actually exists.

Change-Id: I76e677f9b44eea7694005a4939eb9489dc4f71de
Fixes: #57986
Releases: 6.2
Reviewed-on: https://review.typo3.org/29634
Reviewed-by: Wouter Wolters
Reviewed-by: Frans Saris
Reviewed-by: Sebastian Fischer
Tested-by: Sebastian Fischer
Reviewed-by: Xavier Perseguers
Tested-by: Xavier Perseguers
typo3/sysext/core/Classes/Resource/Service/UserFileMountService.php

index 38fa17d..39b731b 100644 (file)
@@ -61,7 +61,18 @@ class UserFileMountService {
                        $storageRepository = GeneralUtility::makeInstance('TYPO3\\CMS\\Core\\Resource\\StorageRepository');
                        /** @var $storage \TYPO3\CMS\Core\Resource\ResourceStorage */
                        $storage = $storageRepository->findByUid($storageUid);
-                       if ($storage->isBrowsable()) {
+                       if ($storage === NULL) {
+                               /** @var \TYPO3\CMS\Core\Messaging\FlashMessageService $flashMessageService */
+                               $flashMessageService = GeneralUtility::makeInstance('TYPO3\\CMS\\Core\\Messaging\\FlashMessageService');
+                               $queue = $flashMessageService->getMessageQueueByIdentifier();
+                               $queue->enqueue(new FlashMessage('Storage #' . $storageUid . ' does not exist. No folder is currently selectable.', '', FlashMessage::ERROR));
+                               if (!count($PA['items'])) {
+                                       $PA['items'][] = array(
+                                               $PA['row'][$PA['field']],
+                                               $PA['row'][$PA['field']]
+                                       );
+                               }
+                       } elseif ($storage->isBrowsable()) {
                                $rootLevelFolders = array();
 
                                $fileMounts = $storage->getFileMounts();