[TASK] Deleting currently opened folder in filelist results in error 30/27030/3
authorSteffen Ritter <info@rs-websystems.de>
Thu, 23 Jan 2014 16:24:23 +0000 (17:24 +0100)
committerSteffen Ritter <info@rs-websystems.de>
Thu, 30 Jan 2014 18:34:53 +0000 (19:34 +0100)
When you have a folder opened in the filelist and then delete it
via the folder-tree the file-module shows an error after its reload.

This patch checks for existence of the folder before it is created.
If it is not existent it checks wether the parent folder exists and
is accessible. If, so the parent folder will be shown instead.

If the parent folder is not accessible the usual exception is thrown.

Releases: 6.2
Resolves: #54554
Change-Id: I7a21c76fd476ebce439489040f3b4c6786afd10a
Reviewed-on: https://review.typo3.org/27030
Reviewed-by: Marcin Sągol
Tested-by: Marcin Sągol
Reviewed-by: Marcel Wieser
Tested-by: Marcel Wieser
Reviewed-by: Steffen Ritter
Tested-by: Steffen Ritter
typo3/sysext/filelist/Classes/Controller/FileListController.php

index 4a7588a..96bd6b3 100644 (file)
@@ -145,7 +145,13 @@ class FileListController {
                        if ($combinedIdentifier) {
                                /** @var $fileFactory \TYPO3\CMS\Core\Resource\ResourceFactory */
                                $fileFactory = GeneralUtility::makeInstance('TYPO3\\CMS\\Core\\Resource\\ResourceFactory');
-                               $this->folderObject = $fileFactory->getFolderObjectFromCombinedIdentifier($combinedIdentifier);
+                               $storage = $fileFactory->getStorageObjectFromCombinedIdentifier($combinedIdentifier);
+                               $identifier = substr($combinedIdentifier, strpos($combinedIdentifier, ':') + 1);
+                               if (!$storage->hasFolder($identifier)) {
+                                       $identifier = $storage->getFolderIdentifierFromFileIdentifier($identifier);
+                               }
+
+                               $this->folderObject = $fileFactory->getFolderObjectFromCombinedIdentifier($storage->getUid() . ':' . $identifier);
                                // Disallow the rendering of the processing folder (e.g. could be called manually)
                                // and all folders without any defined storage
                                if ($this->folderObject && ($this->folderObject->getStorage()->getUid() == 0 || trim($this->folderObject->getStorage()->getProcessingFolder()->getIdentifier(), '/') === trim($this->folderObject->getIdentifier(), '/'))) {
@@ -165,8 +171,15 @@ class FileListController {
                                }
                        }
                } catch (\TYPO3\CMS\Core\Resource\Exception\FolderDoesNotExistException $fileException) {
-                       // Set folder object to null and throw a message later on
-                       $this->folderObject = NULL;
+                       // Take the first object of the first storage
+                       $fileStorages = $GLOBALS['BE_USER']->getFileStorages();
+                       $fileStorage = reset($fileStorages);
+                       if ($fileStorage) {
+                               // Set folder object to null and throw a message later on
+                               $this->folderObject = $fileStorage->getRootLevelFolder();
+                       } else {
+                               $this->folderObject = NULL;
+                       }
                        $this->errorMessage = GeneralUtility::makeInstance('TYPO3\\CMS\\Core\\Messaging\\FlashMessage',
                                sprintf($GLOBALS['LANG']->getLL('folderNotFoundMessage', TRUE),
                                                htmlspecialchars($this->id)