[BUGFIX] Fix exception for folder move/copy between storages 09/57309/2
authorMathias Brodala <mbrodala@pagemachine.de>
Mon, 18 Jun 2018 13:35:22 +0000 (15:35 +0200)
committerSusanne Moog <susanne.moog@typo3.org>
Fri, 22 Jun 2018 20:01:48 +0000 (22:01 +0200)
This ensures that the user is shown the correct error message.

Resolves: #85302
Releases: master, 8.7
Change-Id: Ide2c1231fa1ec5bcbd710c1b3810253ce2bfe3c4
Reviewed-on: https://review.typo3.org/57309
Tested-by: TYPO3com <no-reply@typo3.com>
Reviewed-by: Susanne Moog <susanne.moog@typo3.org>
Tested-by: Susanne Moog <susanne.moog@typo3.org>
typo3/sysext/core/Classes/Resource/ResourceStorage.php
typo3/sysext/core/Classes/Utility/Exception/NotImplementedMethodException.php [new file with mode: 0644]
typo3/sysext/core/Classes/Utility/File/ExtendedFileUtility.php

index 4c79d86..a45c3a0 100644 (file)
@@ -20,6 +20,7 @@ use TYPO3\CMS\Core\Resource\Exception\ExistingTargetFileNameException;
 use TYPO3\CMS\Core\Resource\Exception\InvalidTargetFolderException;
 use TYPO3\CMS\Core\Resource\Index\FileIndexRepository;
 use TYPO3\CMS\Core\Resource\OnlineMedia\Helpers\OnlineMediaHelperRegistry;
+use TYPO3\CMS\Core\Utility\Exception\NotImplementedMethodException;
 use TYPO3\CMS\Core\Utility\GeneralUtility;
 use TYPO3\CMS\Core\Utility\PathUtility;
 use TYPO3\CMS\Extbase\Object\ObjectManager;
@@ -2085,11 +2086,11 @@ class ResourceStorage implements ResourceStorageInterface
      * @param string $newFolderName
      *
      * @return bool
-     * @throws \RuntimeException
+     * @throws NotImplementedMethodException
      */
     protected function moveFolderBetweenStorages(Folder $folderToMove, Folder $targetParentFolder, $newFolderName)
     {
-        throw new \RuntimeException('Not yet implemented', 1476046361);
+        throw new NotImplementedMethodException('Not yet implemented', 1476046361);
     }
 
     /**
@@ -2142,11 +2143,11 @@ class ResourceStorage implements ResourceStorageInterface
      * @param string $newFolderName
      *
      * @return bool
-     * @throws \RuntimeException
+     * @throws NotImplementedMethodException
      */
     protected function copyFolderBetweenStorages(Folder $folderToCopy, Folder $targetParentFolder, $newFolderName)
     {
-        throw new \RuntimeException('Not yet implemented.', 1476046386);
+        throw new NotImplementedMethodException('Not yet implemented.', 1476046386);
     }
 
     /**
diff --git a/typo3/sysext/core/Classes/Utility/Exception/NotImplementedMethodException.php b/typo3/sysext/core/Classes/Utility/Exception/NotImplementedMethodException.php
new file mode 100644 (file)
index 0000000..620a8c6
--- /dev/null
@@ -0,0 +1,26 @@
+<?php
+declare(strict_types = 1);
+namespace TYPO3\CMS\Core\Utility\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!
+ */
+
+/**
+ * Exception thrown if a method is not implemented yet.
+ *
+ * Note this extends from \RuntimeException to be backwards compatible with the
+ * formerly thrown \RuntimeException in the methods.
+ */
+class NotImplementedMethodException extends \RuntimeException
+{
+}
index bbbcb9a..4ccfce4 100644 (file)
@@ -39,6 +39,7 @@ use TYPO3\CMS\Core\Resource\Folder;
 use TYPO3\CMS\Core\Resource\ResourceFactory;
 use TYPO3\CMS\Core\Resource\ResourceStorage;
 use TYPO3\CMS\Core\Type\Exception\InvalidEnumerationValueException;
+use TYPO3\CMS\Core\Utility\Exception\NotImplementedMethodException;
 use TYPO3\CMS\Core\Utility\GeneralUtility;
 use TYPO3\CMS\Lang\LanguageService;
 
@@ -684,7 +685,7 @@ class ExtendedFileUtility extends BasicFileUtility
             } catch (ExistingTargetFileNameException $e) {
                 $this->writeLog(2, 1, 112, 'File "%s" already exists in folder "%s"!', [$sourceFileObject->getIdentifier(), $targetFolderObject->getIdentifier()]);
                 $this->addMessageToFlashMessageQueue('FileUtility.FileAlreadyExistsInFolder', [$sourceFileObject->getIdentifier(), $targetFolderObject->getIdentifier()]);
-            } catch (\BadMethodCallException $e) {
+            } catch (NotImplementedMethodException $e) {
                 $this->writeLog(3, 1, 128, 'The function to copy a file between storages is not yet implemented', []);
                 $this->addMessageToFlashMessageQueue('FileUtility.TheFunctionToCopyAFileBetweenStoragesIsNotYetImplemented');
             } catch (\RuntimeException $e) {
@@ -715,7 +716,7 @@ class ExtendedFileUtility extends BasicFileUtility
             } catch (ExistingTargetFolderException $e) {
                 $this->writeLog(2, 1, 123, 'Target "%s" already exists!', [$targetFolderObject->getIdentifier()]);
                 $this->addMessageToFlashMessageQueue('FileUtility.TargetAlreadyExists', [$targetFolderObject->getIdentifier()]);
-            } catch (\BadMethodCallException $e) {
+            } catch (NotImplementedMethodException $e) {
                 $this->writeLog(3, 1, 129, 'The function to copy a folder between storages is not yet implemented', []);
                 $this->addMessageToFlashMessageQueue('FileUtility.TheFunctionToCopyAFolderBetweenStoragesIsNotYetImplemented');
             } catch (\RuntimeException $e) {
@@ -779,7 +780,7 @@ class ExtendedFileUtility extends BasicFileUtility
             } catch (ExistingTargetFileNameException $e) {
                 $this->writeLog(3, 1, 112, 'File "%s" already exists in folder "%s"!', [$sourceFileObject->getIdentifier(), $targetFolderObject->getIdentifier()]);
                 $this->addMessageToFlashMessageQueue('FileUtility.FileAlreadyExistsInFolder', [$sourceFileObject->getIdentifier(), $targetFolderObject->getIdentifier()]);
-            } catch (\BadMethodCallException $e) {
+            } catch (NotImplementedMethodException $e) {
                 $this->writeLog(3, 1, 126, 'The function to move a file between storages is not yet implemented', []);
                 $this->addMessageToFlashMessageQueue('FileUtility.TheFunctionToMoveAFileBetweenStoragesIsNotYetImplemented');
             } catch (\RuntimeException $e) {
@@ -814,7 +815,7 @@ class ExtendedFileUtility extends BasicFileUtility
             } catch (ExistingTargetFolderException $e) {
                 $this->writeLog(3, 1, 123, 'Target "%s" already exists!', [$targetFolderObject->getIdentifier()]);
                 $this->addMessageToFlashMessageQueue('FileUtility.TargetAlreadyExists', [$targetFolderObject->getIdentifier()]);
-            } catch (\BadMethodCallException $e) {
+            } catch (NotImplementedMethodException $e) {
                 $this->writeLog(3, 1, 127, 'The function to move a folder between storages is not yet implemented', []);
                 $this->addMessageToFlashMessageQueue('FileUtility.TheFunctionToMoveAFolderBetweenStoragesIsNotYetImplemented', []);
             } catch (\RuntimeException $e) {