[BUGFIX] Prevent ResourceDoesNotExistException 94/42594/2
authorAndre Hähnel <andre.haehnel@netresearch.de>
Fri, 9 Jan 2015 13:47:40 +0000 (14:47 +0100)
committerFrans Saris <franssaris@gmail.com>
Fri, 14 Aug 2015 14:10:29 +0000 (16:10 +0200)
An exception is thrown if the show info popup is opened by sys_file uid
for a file which does not exist anymore in filestorage.

This change marks the file as missing so no exception is thrown in
ElementInformationController but a error message is shown to the user
about the missing file.

Resolves: #64214
Releases: master, 6.2
Change-Id: I460013e21db149760a1b391d9cdbd68b6530d190
Reviewed-on: http://review.typo3.org/42594
Reviewed-by: Daniel Goerz <ervaude@gmail.com>
Tested-by: Daniel Goerz <ervaude@gmail.com>
Reviewed-by: Frans Saris <franssaris@gmail.com>
Tested-by: Frans Saris <franssaris@gmail.com>
typo3/sysext/backend/Classes/Template/DocumentTemplate.php
typo3/sysext/core/Classes/Resource/ResourceStorage.php

index b1189c2..19ffbc5 100644 (file)
@@ -568,8 +568,12 @@ function jumpToUrl(URL) {
         * @return string
         */
        public function getResourceHeader(\TYPO3\CMS\Core\Resource\ResourceInterface $resource, $tWrap = array('', ''), $enableClickMenu = TRUE) {
-               $path = $resource->getStorage()->getName() . $resource->getParentFolder()->getIdentifier();
-               $iconImgTag = IconUtility::getSpriteIconForResource($resource, array('title' => htmlspecialchars($path)));
+               try {
+                       $path = $resource->getStorage()->getName() . $resource->getParentFolder()->getIdentifier();
+                       $iconImgTag = IconUtility::getSpriteIconForResource($resource, array('title' => htmlspecialchars($path)));
+               } catch (\TYPO3\CMS\Core\Resource\Exception\ResourceDoesNotExistException $e) {
+                       $iconImgTag = '';
+               }
 
                if ($enableClickMenu && ($resource instanceof \TYPO3\CMS\Core\Resource\File)) {
                        $metaData = $resource->_getMetaData();
index 15bb468..8215e87 100644 (file)
@@ -603,10 +603,16 @@ class ResourceStorage implements ResourceStorageInterface {
                        $isMissing = $file->isMissing();
                }
 
+               if ($this->driver->fileExists($file->getIdentifier()) === FALSE) {
+                       $file->setMissing(TRUE);
+                       $isMissing = TRUE;
+               }
+
                // Check 4: Check the capabilities of the storage (and the driver)
                if ($isWriteCheck && ($isMissing || !$this->isWritable())) {
                        return FALSE;
                }
+
                // Check 5: "File permissions" of the driver (only when file isn't marked as missing)
                if (!$isMissing) {
                        $filePermissions = $this->driver->getPermissions($file->getIdentifier());
@@ -2154,6 +2160,7 @@ class ResourceStorage implements ResourceStorageInterface {
         * @throws Exception\InsufficientFolderAccessPermissionsException
         */
        public function getFolder($identifier, $returnInaccessibleFolderObject = FALSE) {
+
                $data = $this->driver->getFolderInfoByIdentifier($identifier);
                $folder = ResourceFactory::getInstance()->createFolderObject($this, $data['identifier'], $data['name']);