[BUGFIX] Catch FileDoesNotExistException in InputLinkElement 22/51922/5
authorGeorg Ringer <georg.ringer@gmail.com>
Wed, 1 Mar 2017 22:37:41 +0000 (23:37 +0100)
committerMorton Jonuschat <m.jonuschat@mojocode.de>
Sat, 4 Mar 2017 19:13:48 +0000 (20:13 +0100)
If a file is linked which does not exist anymore, the UI
must not break.

Resolves: #80086
Releases: master
Change-Id: If95af9bf4b1e6e723e26e412ce7a29d8214fe411
Reviewed-on: https://review.typo3.org/51922
Tested-by: TYPO3com <no-reply@typo3.com>
Reviewed-by: Markus Klein <markus.klein@typo3.org>
Tested-by: Markus Klein <markus.klein@typo3.org>
Reviewed-by: Morton Jonuschat <m.jonuschat@mojocode.de>
Tested-by: Morton Jonuschat <m.jonuschat@mojocode.de>
typo3/sysext/backend/Classes/Form/Element/InputLinkElement.php

index e3c4468..5d0d214 100644 (file)
@@ -19,6 +19,8 @@ use TYPO3\CMS\Backend\Form\FieldWizard\OtherLanguageContent;
 use TYPO3\CMS\Backend\Utility\BackendUtility;
 use TYPO3\CMS\Core\Imaging\Icon;
 use TYPO3\CMS\Core\LinkHandling\LinkService;
+use TYPO3\CMS\Core\Resource\Exception\FileDoesNotExistException;
+use TYPO3\CMS\Core\Resource\Exception\FolderDoesNotExistException;
 use TYPO3\CMS\Core\Resource\File;
 use TYPO3\CMS\Core\Resource\Folder;
 use TYPO3\CMS\Core\Utility\GeneralUtility;
@@ -306,11 +308,20 @@ class InputLinkElement extends AbstractFormElement
         if (empty($itemValue)) {
             return [];
         }
-        $data = [];
+        $data = ['text' => '', 'icon' => ''];
+        $linkData = [];
         $typolinkService = GeneralUtility::makeInstance(TypoLinkCodecService::class);
         $linkParts = $typolinkService->decode($itemValue);
         $linkService = GeneralUtility::makeInstance(LinkService::class);
-        $linkData = $linkService->resolve($linkParts['url']);
+
+        try {
+            $linkData = $linkService->resolve($linkParts['url']);
+        } catch (FileDoesNotExistException $e) {
+            return $data;
+        } catch (FolderDoesNotExistException $e) {
+            return $data;
+        }
+
         switch ($linkData['type']) {
             case LinkService::TYPE_PAGE:
                 $pageRecord = BackendUtility::readPageAccess($linkData['pageuid'], '1=1');