[BUGFIX] File browser fails on inexistent expandFolder 83/26883/3
authorMario Rimann <mario.rimann@typo3.org>
Wed, 18 Dec 2013 09:17:30 +0000 (10:17 +0100)
committerMarkus Klein <klein.t3@mfc-linz.at>
Thu, 16 Jan 2014 21:48:43 +0000 (22:48 +0100)
If a user browsed to a directory "foo" and re-opens the file-
browser later, the same directory is shown expanded.

In case the directory has been moved/renamed/deleted in the
meantime, the user gets an exception due to the inexistent
directory.

This change just adds a try/catch block around to handle that
situation.

Change-Id: I39aab6be46aec1d3f1f365e5d5f5455aca9b3aa2
Resolves: #50266
Releases: 6.2, 6.1, 6.0
Reviewed-on: https://review.typo3.org/26883
Reviewed-by: Markus Klein
Tested-by: Markus Klein
typo3/sysext/recordlist/Classes/Browser/ElementBrowser.php

index 811c857..0987ba5 100644 (file)
@@ -1171,7 +1171,15 @@ class ElementBrowser {
                // Create upload/create folder forms, if a path is given
                if ($this->expandFolder) {
                        $this->selectedFolder = FALSE;
-                       $fileOrFolderObject = \TYPO3\CMS\Core\Resource\ResourceFactory::getInstance()->retrieveFileOrFolderObject($this->expandFolder);
+
+                       // 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
+                       };
+
                        if ($fileOrFolderObject instanceof \TYPO3\CMS\Core\Resource\Folder) {
                                // It's a folder
                                $this->selectedFolder = $fileOrFolderObject;