[BUGFIX] RTE Linking with file upload fails when no folder is selected 23/27323/3
authorStanislas Rolland <typo3@sjbr.ca>
Tue, 4 Feb 2014 15:58:17 +0000 (10:58 -0500)
committerStanislas Rolland <typo3@sjbr.ca>
Thu, 6 Feb 2014 00:11:21 +0000 (01:11 +0100)
Solution: Catch exceptions raised when the potential target folder or
the default user upload folder does not exist.

Resolves: #48512
Releases: 6.2
Change-Id: Ic0218f218b045562d0ea5499ac0440848ddf3028
Reviewed-on: https://review.typo3.org/27323
Reviewed-by: Stanislas Rolland
Tested-by: Stanislas Rolland
typo3/sysext/rtehtmlarea/Classes/BrowseLinks.php

index 5816324..0b96d0f 100644 (file)
@@ -556,23 +556,28 @@ class BrowseLinks extends \TYPO3\CMS\Recordlist\Browser\ElementBrowser {
                                        }
                                }
                                // Get the selected folder
+                               $selectedFolder = FALSE;
                                if ($this->expandFolder) {
-                                       $selectedFolder = FALSE;
-                                       $fileOrFolderObject = \TYPO3\CMS\Core\Resource\ResourceFactory::getInstance()->retrieveFileOrFolderObject($this->expandFolder);
+                                       try {
+                                               $fileOrFolderObject = \TYPO3\CMS\Core\Resource\ResourceFactory::getInstance()->retrieveFileOrFolderObject($this->expandFolder);
+                                       } catch (\Exception $e) {
+                                               // No path is selected
+                                       }
                                        if ($fileOrFolderObject instanceof \TYPO3\CMS\Core\Resource\Folder) {
-                                               // it's a folder
+                                               // It's a folder
                                                $selectedFolder = $fileOrFolderObject;
                                        } elseif ($fileOrFolderObject instanceof \TYPO3\CMS\Core\Resource\FileInterface) {
-                                               // it's a file
-                                               // @todo: find the parent folder, right now done a bit ugly, because the file does not
-                                               // support finding the parent folder of a file on purpose
-                                               $folderIdentifier = dirname($fileOrFolderObject->getIdentifier());
-                                               $selectedFolder = $fileOrFolderObject->getStorage()->getFolder($folderIdentifier);
+                                               // It's a file
+                                               $selectedFolder = $fileOrFolderObject->getParentFolder();
                                        }
                                }
                                // If no folder is selected, get the user's default upload folder
                                if (!$selectedFolder) {
-                                       $selectedFolder = $GLOBALS['BE_USER']->getDefaultUploadFolder();
+                                       try {
+                                               $selectedFolder = $GLOBALS['BE_USER']->getDefaultUploadFolder();
+                                       } catch (\Exception $e) {
+                                               // The configured default user folder does not exist
+                                       }
                                }
                                // Build the file upload and folder creation forms
                                $uploadForm = '';