[BUGFIX] Prevent ResourceDoesNotExistException in ElementInformationControler 29/35929/12
authorAndre Hähnel <andre.haehnel@netresearch.de>
Fri, 9 Jan 2015 13:47:40 +0000 (14:47 +0100)
committerFrans Saris <franssaris@gmail.com>
Wed, 12 Aug 2015 20:17:52 +0000 (22:17 +0200)
If the show info popup is opened by sys_file uid for a file does not
exist anymore in filestorage an exception is thrown.

This changes marks the file as missing so no exception is thrown
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/35929
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 43808b2..d697b74 100644 (file)
@@ -612,8 +612,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 3602e40..1752076 100644 (file)
@@ -572,10 +572,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());
@@ -2173,6 +2179,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']);