[BUGFIX] Catch exceptions in LinkBrowser 23/51923/3
authorGeorg Ringer <georg.ringer@gmail.com>
Wed, 1 Mar 2017 22:57:32 +0000 (23:57 +0100)
committerMorton Jonuschat <m.jonuschat@mojocode.de>
Sat, 4 Mar 2017 02:23:03 +0000 (03:23 +0100)
If a folder or file is linked which does not exist, the UI must not
break.

Resolves: #80087
Releases: master
Change-Id: I9027234065c33f68db6af24f1dae9735d46d2584
Reviewed-on: https://review.typo3.org/51923
Tested-by: TYPO3com <no-reply@typo3.com>
Reviewed-by: Wouter Wolters <typo3@wouterwolters.nl>
Reviewed-by: Markus Klein <markus.klein@typo3.org>
Tested-by: Markus Klein <markus.klein@typo3.org>
Reviewed-by: Joerg Boesche <typo3@joergboesche.de>
Reviewed-by: Morton Jonuschat <m.jonuschat@mojocode.de>
Tested-by: Morton Jonuschat <m.jonuschat@mojocode.de>
typo3/sysext/core/Classes/LinkHandling/FileLinkHandler.php
typo3/sysext/core/Classes/LinkHandling/FolderLinkHandler.php

index 787e395..e111d7a 100644 (file)
@@ -14,6 +14,7 @@ namespace TYPO3\CMS\Core\LinkHandling;
  *
  * The TYPO3 project - inspiring people to share!
  */
+use TYPO3\CMS\Core\Resource\Exception\FileDoesNotExistException;
 use TYPO3\CMS\Core\Resource\ResourceFactory;
 use TYPO3\CMS\Core\Utility\GeneralUtility;
 
@@ -74,7 +75,12 @@ class FileLinkHandler implements LinkHandlingInterface
         } else {
             $fileId = $data['identifier'];
         }
-        return ['file' => $this->getResourceFactory()->getFileObject($fileId)];
+        try {
+            $file = $this->getResourceFactory()->getFileObject($fileId);
+        } catch (FileDoesNotExistException $e) {
+            $file = null;
+        }
+        return ['file' => $file];
     }
 
     /**
index ef63adf..9b24d26 100644 (file)
@@ -14,6 +14,7 @@ namespace TYPO3\CMS\Core\LinkHandling;
  *
  * The TYPO3 project - inspiring people to share!
  */
+use TYPO3\CMS\Core\Resource\Exception\FolderDoesNotExistException;
 use TYPO3\CMS\Core\Resource\ResourceFactory;
 use TYPO3\CMS\Core\Utility\GeneralUtility;
 
@@ -61,7 +62,12 @@ class FolderLinkHandler implements LinkHandlingInterface
     public function resolveHandlerData(array $data): array
     {
         $combinedIdentifier = ($data['storage'] ?? '0') . ':' . $data['identifier'];
-        return ['folder' => $this->getResourceFactory()->getFolderObjectFromCombinedIdentifier($combinedIdentifier)];
+        try {
+            $folder = $this->getResourceFactory()->getFolderObjectFromCombinedIdentifier($combinedIdentifier);
+        } catch (FolderDoesNotExistException $e) {
+            $folder = null;
+        }
+        return ['folder' => $folder];
     }
 
     /**