[BUGFIX] Catch exceptions for inaccessible storages 62/36562/6
authorPhilipp Gampe <philipp.gampe@typo3.org>
Sun, 1 Feb 2015 10:46:51 +0000 (11:46 +0100)
committerAlexander Opitz <opitz.alexander@googlemail.com>
Tue, 28 Jul 2015 08:31:43 +0000 (10:31 +0200)
A storage might be (temporary or permanently) not available in the
current file system. Then it should be displayed as inaccessible
(offline).
Catch all exceptions while trying to fetch permissions for any related
folders.
Only display paste icons for browsable storages.

Resolves: #64714
Releases: master, 6.2
Change-Id: I803d1d2dad919fefebf9b37c60b40a7a440bc6d5
Reviewed-on: http://review.typo3.org/36562
Reviewed-by: Markus Klein <markus.klein@typo3.org>
Tested-by: Markus Klein <markus.klein@typo3.org>
Reviewed-by: Ingo Schmitt <is@marketing-factory.de>
Reviewed-by: Daniel Goerz <ervaude@gmail.com>
Reviewed-by: Alexander Opitz <opitz.alexander@googlemail.com>
Tested-by: Alexander Opitz <opitz.alexander@googlemail.com>
typo3/sysext/backend/Classes/Utility/IconUtility.php
typo3/sysext/core/Classes/Resource/Driver/LocalDriver.php
typo3/sysext/core/Classes/Resource/Exception/ResourcePermissionsException.php [new file with mode: 0644]
typo3/sysext/core/Classes/Resource/Folder.php
typo3/sysext/core/Classes/Resource/ResourceStorage.php

index 5584850..3e57a49 100644 (file)
@@ -765,6 +765,7 @@ class IconUtility {
 
                                // if locked add overlay
                                if ($resource instanceof \TYPO3\CMS\Core\Resource\InaccessibleFolder ||
+                                       !$resource->getStorage()->isBrowsable() ||
                                        !$resource->getStorage()->checkFolderActionPermission('add', $resource)
                                ) {
                                        $overlays['status-overlay-locked'] = array();
index 725adcd..4aeb0f8 100644 (file)
@@ -1174,13 +1174,13 @@ class LocalDriver extends AbstractHierarchicalFilesystemDriver {
         *
         * @param string $identifier
         * @return array
-        * @throws \RuntimeException
+        * @throws Exception\ResourcePermissionsException
         */
        public function getPermissions($identifier) {
                $path = $this->getAbsolutePath($identifier);
                $permissionBits = fileperms($path);
                if ($permissionBits === FALSE) {
-                       throw new \RuntimeException('Error while fetching permissions for ' . $path, 1319455097);
+                       throw new Exception\ResourcePermissionsException('Error while fetching permissions for ' . $path, 1319455097);
                }
                return array(
                        'r' => (bool)is_readable($path),
diff --git a/typo3/sysext/core/Classes/Resource/Exception/ResourcePermissionsException.php b/typo3/sysext/core/Classes/Resource/Exception/ResourcePermissionsException.php
new file mode 100644 (file)
index 0000000..d0c9538
--- /dev/null
@@ -0,0 +1,23 @@
+<?php
+namespace TYPO3\CMS\Core\Resource\Exception;
+
+/*
+ * This file is part of the TYPO3 CMS project.
+ *
+ * It is free software; you can redistribute it and/or modify it under
+ * the terms of the GNU General Public License, either version 2
+ * of the License, or any later version.
+ *
+ * For the full copyright and license information, please read the
+ * LICENSE.txt file that was distributed with this source code.
+ *
+ * The TYPO3 project - inspiring people to share!
+ */
+
+/**
+ * An exception when something is wrong with fetching the permissions for a file or a folder.
+ *
+ * Extending \RuntimeException for backwards compatibility.
+ */
+class ResourcePermissionsException extends \RuntimeException {
+}
index 43acc2c..d59965d 100644 (file)
@@ -373,7 +373,11 @@ class Folder implements FolderInterface {
         * @return bool
         */
        public function checkActionPermission($action) {
-               return $this->getStorage()->checkFolderActionPermission($action, $this);
+               try {
+                       return $this->getStorage()->checkFolderActionPermission($action, $this);
+               } catch (Exception\ResourcePermissionsException $e) {
+                       return FALSE;
+               }
        }
 
        /**
index 94120c0..5d12cc2 100644 (file)
@@ -2684,6 +2684,10 @@ class ResourceStorage implements ResourceStorageInterface {
                                $this->processingFolder = GeneralUtility::makeInstance(
                                        InaccessibleFolder::class, $this, $processingFolder, $processingFolder
                                );
+                       } catch(Exception\ResourcePermissionsException $e) {
+                               $this->processingFolder = GeneralUtility::makeInstance(
+                                       InaccessibleFolder::class, $this, $processingFolder, $processingFolder
+                               );
                        }
                }
                return $this->processingFolder;