[BUGFIX] Proper error handling of ResourceDoesNotExistException
[Packages/TYPO3.CMS.git] / typo3 / sysext / core / Classes / Utility / File / ExtendedFileUtility.php
index fe61c50..76df9e9 100644 (file)
@@ -17,6 +17,8 @@ namespace TYPO3\CMS\Core\Utility\File;
 use TYPO3\CMS\Backend\Utility\BackendUtility;
 use TYPO3\CMS\Backend\Utility\IconUtility;
 use TYPO3\CMS\Core\Messaging\FlashMessage;
+use TYPO3\CMS\Core\Messaging\FlashMessageService;
+use TYPO3\CMS\Core\Resource\Exception\ResourceDoesNotExistException;
 use TYPO3\CMS\Core\Resource\File;
 use TYPO3\CMS\Core\Utility\GeneralUtility;
 
@@ -390,7 +392,20 @@ class ExtendedFileUtility extends \TYPO3\CMS\Core\Utility\File\BasicFileUtility
                }
                // Example indentifier for $cmds['data'] => "4:mypath/tomyfolder/myfile.jpg"
                // for backwards compatibility: the combined file identifier was the path+filename
-               $fileObject = $this->getFileObject($cmds['data']);
+               try {
+                       $fileObject = $this->getFileObject($cmds['data']);
+               } catch (ResourceDoesNotExistException $ex) {
+                       $flashMessage = GeneralUtility::makeInstance(
+                               'TYPO3\\CMS\\Core\\Messaging\\FlashMessage',
+                               sprintf( $GLOBALS['LANG']->sL('LLL:EXT:lang/locallang_core.xlf:message.description.fileNotFound'), $cmds['data']),
+                               $GLOBALS['LANG']->sL('LLL:EXT:lang/locallang_core.xlf:message.header.fileNotFound'),
+                               FlashMessage::ERROR,
+                               TRUE
+                       );
+                       $this->addFlashMessage($flashMessage);
+
+                       return FALSE;
+               }
                // @todo implement the recycler feature which has been removed from the original implementation
                // checks to delete the file
                if ($fileObject instanceof File) {