[FOLLOWUP][BUGFIX] Catch exceptions for inaccessible storages 45/42045/2
authorAlexander Opitz <opitz.alexander@googlemail.com>
Tue, 28 Jul 2015 15:18:01 +0000 (17:18 +0200)
committerPhilipp Gampe <philipp.gampe@typo3.org>
Tue, 28 Jul 2015 15:36:23 +0000 (17:36 +0200)
Change naming of exception to ResourcePermissionsUnavailableException
and use exception hierarchy as for other exceptions.

Resolves: #64714
Releases: master
Change-Id: Ia65f2708096418c8291545517d0154d5855bdd23
Reviewed-on: http://review.typo3.org/42045
Reviewed-by: Helmut Hummel <helmut.hummel@typo3.org>
Tested-by: Helmut Hummel <helmut.hummel@typo3.org>
Reviewed-by: Philipp Gampe <philipp.gampe@typo3.org>
Tested-by: Philipp Gampe <philipp.gampe@typo3.org>
typo3/sysext/core/Classes/Resource/Driver/LocalDriver.php
typo3/sysext/core/Classes/Resource/Exception/ResourcePermissionsException.php [deleted file]
typo3/sysext/core/Classes/Resource/Exception/ResourcePermissionsUnavailableException.php [new file with mode: 0644]
typo3/sysext/core/Classes/Resource/Folder.php
typo3/sysext/core/Classes/Resource/ResourceStorage.php
typo3/sysext/core/Documentation/Changelog/master/Breaking-64714-CatchExceptionsForInaccessibleStorages.rst [new file with mode: 0644]

index 4aeb0f8..1a11cb7 100644 (file)
@@ -1174,13 +1174,13 @@ class LocalDriver extends AbstractHierarchicalFilesystemDriver {
         *
         * @param string $identifier
         * @return array
-        * @throws Exception\ResourcePermissionsException
+        * @throws Exception\ResourcePermissionsUnavailableException
         */
        public function getPermissions($identifier) {
                $path = $this->getAbsolutePath($identifier);
                $permissionBits = fileperms($path);
                if ($permissionBits === FALSE) {
-                       throw new Exception\ResourcePermissionsException('Error while fetching permissions for ' . $path, 1319455097);
+                       throw new Exception\ResourcePermissionsUnavailableException('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
deleted file mode 100644 (file)
index d0c9538..0000000
+++ /dev/null
@@ -1,23 +0,0 @@
-<?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 {
-}
diff --git a/typo3/sysext/core/Classes/Resource/Exception/ResourcePermissionsUnavailableException.php b/typo3/sysext/core/Classes/Resource/Exception/ResourcePermissionsUnavailableException.php
new file mode 100644 (file)
index 0000000..3a2f129
--- /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 ResourcePermissionsUnavailableException extends \TYPO3\CMS\Core\Resource\Exception {
+}
index d59965d..9038756 100644 (file)
@@ -375,7 +375,7 @@ class Folder implements FolderInterface {
        public function checkActionPermission($action) {
                try {
                        return $this->getStorage()->checkFolderActionPermission($action, $this);
-               } catch (Exception\ResourcePermissionsException $e) {
+               } catch (Exception\ResourcePermissionsUnavailableException $e) {
                        return FALSE;
                }
        }
index 5d12cc2..8a156d1 100644 (file)
@@ -2684,7 +2684,7 @@ class ResourceStorage implements ResourceStorageInterface {
                                $this->processingFolder = GeneralUtility::makeInstance(
                                        InaccessibleFolder::class, $this, $processingFolder, $processingFolder
                                );
-                       } catch(Exception\ResourcePermissionsException $e) {
+                       } catch(Exception\ResourcePermissionsUnavailableException $e) {
                                $this->processingFolder = GeneralUtility::makeInstance(
                                        InaccessibleFolder::class, $this, $processingFolder, $processingFolder
                                );
diff --git a/typo3/sysext/core/Documentation/Changelog/master/Breaking-64714-CatchExceptionsForInaccessibleStorages.rst b/typo3/sysext/core/Documentation/Changelog/master/Breaking-64714-CatchExceptionsForInaccessibleStorages.rst
new file mode 100644 (file)
index 0000000..94528f5
--- /dev/null
@@ -0,0 +1,26 @@
+=============================================================
+Breaking: #64714 - Catch exceptions for inaccessible storages
+=============================================================
+
+Description
+===========
+
+Changing \TYPO3\CMS\Core\Resource\Exception\ResourcePermissionsUnavailableException to extend from \TYPO3\CMS\Core\Resource\Exception instead of \RuntimeExtension
+
+
+Impact
+======
+
+If a call to \TYPO3\CMS\Core\Resource\Driver\LocalDriver->getPermissions() throws an exception and your extension catches \RuntimeExtension it breaks on permission read errors.
+
+
+Migration
+=========
+
+To write a compatible extension you can do following in your catch block:
+
+       } catch(\RuntimeException $e) {
+               // Do exception handling
+       } catch(\TYPO3\CMS\Core\Resource\Exception\ResourcePermissionsUnavailableException $e) {
+               // Do same exception handling
+       }