[BUGFIX] Catch exception when linked file is deleted 67/41467/2
authorBenjamin Mack <benni@typo3.org>
Thu, 16 Jul 2015 13:34:37 +0000 (15:34 +0200)
committerStefan Neufeind <typo3.neufeind@speedpartner.de>
Thu, 16 Jul 2015 15:54:48 +0000 (17:54 +0200)
If a file is linked in the RTE, and the file is deleted afterwards
an exception is thrown, thus making it impossible to change
the link.

Instead, the popup should show up without selecting anything.

Resolves: #66624
Releases: master, 6.2
Change-Id: Iec985b0202002a2c906b4cee43cd4e27e496d4fb
Reviewed-on: http://review.typo3.org/41467
Reviewed-by: Georg Ringer <georg.ringer@gmail.com>
Tested-by: Georg Ringer <georg.ringer@gmail.com>
Reviewed-by: Stefan Neufeind <typo3.neufeind@speedpartner.de>
Tested-by: Stefan Neufeind <typo3.neufeind@speedpartner.de>
typo3/sysext/recordlist/Classes/Browser/ElementBrowser.php

index 8a70a88..eab4578 100644 (file)
@@ -2258,16 +2258,26 @@ class ElementBrowser {
                        if (!StringUtility::beginsWith($href, 'file://') && strpos($href, 'file:') !== FALSE) {
                                $rel = substr($href, strpos($href, 'file:') + 5);
                                $rel = rawurldecode($rel);
-                               // resolve FAL-api "file:UID-of-sys_file-record" and "file:combined-identifier"
-                               $fileOrFolderObject = ResourceFactory::getInstance()->retrieveFileOrFolderObject($rel);
-                               if ($fileOrFolderObject instanceof Folder) {
-                                       $info['act'] = 'folder';
-                                       $info['value'] = $fileOrFolderObject->getCombinedIdentifier();
-                               } elseif ($fileOrFolderObject instanceof File) {
-                                       $info['act'] = 'file';
-                                       $info['value'] = $fileOrFolderObject->getUid();
-                               } else {
-                                       $info['value'] = $rel;
+                               try {
+                                       // resolve FAL-api "file:UID-of-sys_file-record" and "file:combined-identifier"
+                                       $fileOrFolderObject = ResourceFactory::getInstance()->retrieveFileOrFolderObject($rel);
+                                       if ($fileOrFolderObject instanceof Folder) {
+                                               $info['act'] = 'folder';
+                                               $info['value'] = $fileOrFolderObject->getCombinedIdentifier();
+                                       } elseif ($fileOrFolderObject instanceof File) {
+                                               $info['act'] = 'file';
+                                               $info['value'] = $fileOrFolderObject->getUid();
+                                       } else {
+                                               $info['value'] = $rel;
+                                       }
+                               } catch (Exception\FileDoesNotExistException $e) {
+                                       // file was deleted or any other reason, don't select any item
+                                       if (MathUtility::canBeInterpretedAsInteger($rel)) {
+                                               $info['act'] = 'file';
+                                       } else {
+                                               $info['act'] = 'folder';
+                                       }
+                                       $info['value'] = '';
                                }
                        } elseif (StringUtility::beginsWith($href, $siteUrl)) {
                                // If URL is on the current frontend website: