[BUGFIX] Outdated resource pointers crash for TCA type group 62/53562/2
authorOliver Hader <oliver@typo3.org>
Wed, 19 Jul 2017 12:24:46 +0000 (14:24 +0200)
committerSusanne Moog <susanne.moog@typo3.org>
Mon, 24 Jul 2017 05:28:41 +0000 (07:28 +0200)
Using TCA type "group" with internal_type "folder" crashes in
the backend if existing resource pointers have been moved in
the filesystem (e.g. renamed or deleted).

Resolves: #81918
Releases: master, 8.7, 7.6
Change-Id: I1aadee90d1fe81cd821cc3df594351dbfc101482
Reviewed-on: https://review.typo3.org/53562
Tested-by: TYPO3com <no-reply@typo3.com>
Reviewed-by: Susanne Moog <susanne.moog@typo3.org>
Tested-by: Susanne Moog <susanne.moog@typo3.org>
typo3/sysext/backend/Classes/Form/FormDataProvider/TcaGroup.php

index 5b60b59..d1e076f 100644 (file)
@@ -18,6 +18,7 @@ use TYPO3\CMS\Backend\Clipboard\Clipboard;
 use TYPO3\CMS\Backend\Form\FormDataProviderInterface;
 use TYPO3\CMS\Backend\Utility\BackendUtility;
 use TYPO3\CMS\Core\Database\RelationHandler;
+use TYPO3\CMS\Core\Resource\Exception;
 use TYPO3\CMS\Core\Resource\Folder;
 use TYPO3\CMS\Core\Resource\ResourceFactory;
 use TYPO3\CMS\Core\Utility\GeneralUtility;
@@ -79,12 +80,15 @@ class TcaGroup implements FormDataProviderInterface
                 foreach ($fileList as $uidOrPath) {
                     $item = [
                         'uidOrPath' => $uidOrPath,
+                        'title' => $uidOrPath,
                     ];
-                    if (MathUtility::canBeInterpretedAsInteger($uidOrPath)) {
-                        $fileObject = $fileFactory->getFileObject($uidOrPath);
-                        $item['title'] = $fileObject->getName();
-                    } else {
-                        $item['title'] = $uidOrPath;
+                    try {
+                        if (MathUtility::canBeInterpretedAsInteger($uidOrPath)) {
+                            $fileObject = $fileFactory->getFileObject($uidOrPath);
+                            $item['title'] = $fileObject->getName();
+                        }
+                    } catch (Exception $exception) {
+                        continue;
                     }
                     $items[] = $item;
                 }
@@ -180,13 +184,18 @@ class TcaGroup implements FormDataProviderInterface
                 // Simple list of folders
                 $folderList = GeneralUtility::trimExplode(',', $databaseRowFieldContent, true);
                 foreach ($folderList as $folder) {
-                    if ($folder) {
+                    if (empty($folder)) {
+                        continue;
+                    }
+                    try {
                         $folderObject = ResourceFactory::getInstance()->retrieveFileOrFolderObject($folder);
                         if ($folderObject instanceof Folder) {
                             $items[] = [
                                 'folder' => $folder,
                             ];
                         }
+                    } catch (Exception $exception) {
+                        continue;
                     }
                 }
             } else {