[BUGFIX] Catch FileDoesNotExistException during persisting records 86/58286/2
authorGeorg Ringer <georg.ringer@gmail.com>
Sat, 15 Sep 2018 17:17:34 +0000 (19:17 +0200)
committerWouter Wolters <typo3@wouterwolters.nl>
Thu, 20 Sep 2018 17:38:28 +0000 (19:38 +0200)
Catch an exception which is thrown if a file of a sys_file_reference
relation does not exist anymore.

Resolves: #86267
Releases: master
Change-Id: Ie50ae07845964346bcd8e042a6a3d62a1e8084d3
Reviewed-on: https://review.typo3.org/58286
Tested-by: TYPO3com <no-reply@typo3.com>
Reviewed-by: Frans Saris <franssaris@gmail.com>
Reviewed-by: Christian Kuhn <lolli@schwarzbu.ch>
Tested-by: Christian Kuhn <lolli@schwarzbu.ch>
Reviewed-by: Wouter Wolters <typo3@wouterwolters.nl>
Tested-by: Wouter Wolters <typo3@wouterwolters.nl>
typo3/sysext/core/Classes/Resource/Filter/FileExtensionFilter.php

index 6e3d463..dfd2b95 100644 (file)
@@ -16,6 +16,7 @@ namespace TYPO3\CMS\Core\Resource\Filter;
 
 use TYPO3\CMS\Core\DataHandling\DataHandler;
 use TYPO3\CMS\Core\Resource\Driver\DriverInterface;
+use TYPO3\CMS\Core\Resource\Exception\FileDoesNotExistException;
 use TYPO3\CMS\Core\Resource\ResourceFactory;
 use TYPO3\CMS\Core\Utility\GeneralUtility;
 use TYPO3\CMS\Core\Utility\PathUtility;
@@ -63,13 +64,17 @@ class FileExtensionFilter
                 }
                 $parts = GeneralUtility::revExplode('_', $value, 2);
                 $fileReferenceUid = $parts[count($parts) - 1];
-                $fileReference = ResourceFactory::getInstance()->getFileReferenceObject($fileReferenceUid);
-                $file = $fileReference->getOriginalFile();
-                if ($this->isAllowed($file->getExtension())) {
-                    $cleanValues[] = $value;
-                } else {
-                    // Remove the erroneously created reference record again
-                    $dataHandler->deleteAction('sys_file_reference', $fileReferenceUid);
+                try {
+                    $fileReference = ResourceFactory::getInstance()->getFileReferenceObject($fileReferenceUid);
+                    $file = $fileReference->getOriginalFile();
+                    if ($this->isAllowed($file->getExtension())) {
+                        $cleanValues[] = $value;
+                    } else {
+                        // Remove the erroneously created reference record again
+                        $dataHandler->deleteAction('sys_file_reference', $fileReferenceUid);
+                    }
+                } catch (FileDoesNotExistException $e) {
+                    // do nothing
                 }
             }
         }