[BUGFIX] BackendUtility: Skip rendering thumbnails for anything but files 09/44709/2
authorMorton Jonuschat <m.jonuschat@mojocode.de>
Fri, 13 Nov 2015 19:17:52 +0000 (20:17 +0100)
committerMorton Jonuschat <m.jonuschat@mojocode.de>
Fri, 13 Nov 2015 19:26:29 +0000 (20:26 +0100)
If the stored value in a group field with type file/file_reference is a
folder the thumbCode() method skips rendering a thumbnail for that
resource. This avoids fatal error as the interface of e.g. a Folder is
different to that of a File, missing the ::isMissing() method.

Resolves: #66045
Releases: master, 6.2
Change-Id: I29b75dec0173cc2423583a9cf42ff56ca81ce7d3
Reviewed-on: https://review.typo3.org/44709
Reviewed-by: Wouter Wolters <typo3@wouterwolters.nl>
Reviewed-by: Morton Jonuschat <m.jonuschat@mojocode.de>
Tested-by: Morton Jonuschat <m.jonuschat@mojocode.de>
typo3/sysext/backend/Classes/Utility/BackendUtility.php

index cc43e6b..6d80afe 100644 (file)
@@ -17,6 +17,7 @@ namespace TYPO3\CMS\Backend\Utility;
 use TYPO3\CMS\Backend\Utility\IconUtility;
 use TYPO3\CMS\Core\Database\RelationHandler;
 use TYPO3\CMS\Core\Messaging\FlashMessage;
+use TYPO3\CMS\Core\Resource\AbstractFile;
 use TYPO3\CMS\Core\Resource\File;
 use TYPO3\CMS\Core\Resource\ProcessedFile;
 use TYPO3\CMS\Core\Resource\ResourceFactory;
@@ -1579,6 +1580,12 @@ class BackendUtility {
                        foreach ($fileReferences as $fileReferenceObject) {
                                $fileObject = $fileReferenceObject->getOriginalFile();
 
+                               // Skip the resource if it's not of type AbstractFile. One case where this can happen if the
+                               // storage has been externally modified and the field value now points to a folder
+                               // instead of a file.
+                               if (!$fileObject instanceof AbstractFile) {
+                                       continue;
+                               }
                                if ($fileObject->isMissing()) {
                                        $flashMessage = \TYPO3\CMS\Core\Resource\Utility\BackendUtility::getFlashMessageForMissingFile($fileObject);
                                        $thumbData .= $flashMessage->render();