[BUGFIX] BackendUtility: Skip rendering thumbnails for anything but files 40/38240/7
authorAndreas Allacher <andreas.allacher@gmx.at>
Thu, 26 Mar 2015 13:26:08 +0000 (14:26 +0100)
committerMorton Jonuschat <m.jonuschat@mojocode.de>
Fri, 13 Nov 2015 19:02:59 +0000 (20:02 +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.

Change-Id: Iedf4b5e5b17d0310811bb862c131cd70e988e72f
Resolves: #66045
Releases: master, 6.2
Reviewed-on: https://review.typo3.org/38240
Reviewed-by: Frank N├Ągler <frank.naegler@typo3.org>
Reviewed-by: Daniel Goerz <ervaude@gmail.com>
Tested-by: Daniel Goerz <ervaude@gmail.com>
Reviewed-by: Morton Jonuschat <m.jonuschat@mojocode.de>
Tested-by: Morton Jonuschat <m.jonuschat@mojocode.de>
typo3/sysext/backend/Classes/Utility/BackendUtility.php

index 1969c6a..0986aed 100755 (executable)
@@ -25,6 +25,7 @@ use TYPO3\CMS\Core\FormProtection\FormProtectionFactory;
 use TYPO3\CMS\Core\Imaging\Icon;
 use TYPO3\CMS\Core\Imaging\IconFactory;
 use TYPO3\CMS\Core\Messaging\FlashMessage;
+use TYPO3\CMS\Core\Resource\AbstractFile;
 use TYPO3\CMS\Core\Resource\Exception\ResourceDoesNotExistException;
 use TYPO3\CMS\Core\Resource\File;
 use TYPO3\CMS\Core\Resource\ProcessedFile;
@@ -1769,6 +1770,12 @@ class BackendUtility
                     try {
                         /** @var File $fileObject */
                         $fileObject = ResourceFactory::getInstance()->retrieveFileOrFolderObject($fileName);
+                        // 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();