[BUGFIX] Show FlashMessage if desired storage is not available 82/43282/6
authorMichael Oehlhof <typo3@oehlhof.de>
Sun, 13 Sep 2015 17:41:42 +0000 (19:41 +0200)
committerAnja Leichsenring <aleichsenring@ab-softlab.de>
Wed, 16 Sep 2015 13:43:07 +0000 (15:43 +0200)
This exception occured when a file reference from a storage was used
on a page and the extension which provides the storage was disabled
in the extension manager.

Now a FlashMessage is shown with the uid of the file reference.

Resolves: #69765
Releases: master
Change-Id: Ie6b30948af42a9f5cccab678601a21da4af8b35e
Reviewed-on: http://review.typo3.org/43282
Reviewed-by: Nicole Cordes <typo3@cordes.co>
Tested-by: Nicole Cordes <typo3@cordes.co>
Reviewed-by: Michael Oehlhof <typo3@oehlhof.de>
Tested-by: Michael Oehlhof <typo3@oehlhof.de>
Reviewed-by: Anja Leichsenring <aleichsenring@ab-softlab.de>
Tested-by: Anja Leichsenring <aleichsenring@ab-softlab.de>
typo3/sysext/backend/Classes/Utility/BackendUtility.php
typo3/sysext/core/Classes/Resource/ResourceFactory.php
typo3/sysext/frontend/Classes/Page/PageRepository.php

index 5141275..69f2680 100755 (executable)
@@ -1645,6 +1645,13 @@ class BackendUtility {
                                 * We just catch the exception here
                                 * Reasoning: There is nothing an editor or even admin could do
                                 */
+                       } catch (\InvalidArgumentException $e) {
+                               /**
+                                * The storage does not exist anymore
+                                * Log the exception message for admins as they maybe can restore the storage
+                                */
+                               $logMessage = $e->getMessage() . ' (table: "' . $tableName . '", fieldName: "' . $fieldName . '", referenceUid: ' . $referenceUid . ')';
+                               GeneralUtility::sysLog($logMessage, 'core', GeneralUtility::SYSLOG_SEVERITY_ERROR);
                        }
                }
 
index 9393380..f9bfa91 100644 (file)
@@ -551,9 +551,9 @@ class ResourceFactory implements ResourceFactoryInterface, \TYPO3\CMS\Core\Singl
         * @param int $uid The uid of the file usage (sys_file_reference) to instantiate.
         * @param array $fileReferenceData The record row from database.
         * @param bool $raw Whether to get raw results without performing overlays
-        *
-        * @throws \TYPO3\CMS\Core\Resource\Exception\ResourceDoesNotExistException
         * @return FileReference
+        * @throws \InvalidArgumentException
+        * @throws \TYPO3\CMS\Core\Resource\Exception\ResourceDoesNotExistException
         */
        public function getFileReferenceObject($uid, array $fileReferenceData = array(), $raw = FALSE) {
                if (!is_numeric($uid)) {
index cd0109e..0c82373 100644 (file)
@@ -15,6 +15,7 @@ namespace TYPO3\CMS\Frontend\Page;
  */
 
 use TYPO3\CMS\Core\Cache\CacheManager;
+use TYPO3\CMS\Core\Resource\Exception\FileDoesNotExistException;
 use TYPO3\CMS\Core\Resource\FileRepository;
 use TYPO3\CMS\Core\Utility\ExtensionManagementUtility;
 use TYPO3\CMS\Core\Utility\GeneralUtility;
@@ -1575,7 +1576,23 @@ class PageRepository {
                $currentId = !empty($element['uid']) ? $element['uid'] : 0;
 
                // Fetch the references of the default element
-               $references = $fileRepository->findByRelation($tableName, $fieldName, $currentId);
+               try {
+                       $references = $fileRepository->findByRelation($tableName, $fieldName, $currentId);
+               } catch (FileDoesNotExistException $e) {
+                       /**
+                        * We just catch the exception here
+                        * Reasoning: There is nothing an editor or even admin could do
+                        */
+                       return array();
+               } catch (\InvalidArgumentException $e) {
+                       /**
+                        * The storage does not exist anymore
+                        * Log the exception message for admins as they maybe can restore the storage
+                        */
+                       $logMessage = $e->getMessage() . ' (table: "' . $tableName . '", fieldName: "' . $fieldName . '", currentId: ' . $currentId . ')';
+                       GeneralUtility::sysLog($logMessage, 'core', GeneralUtility::SYSLOG_SEVERITY_ERROR);
+                       return array();
+               }
 
                $localizedId = NULL;
                if (isset($element['_LOCALIZED_UID'])) {