[BUGFIX] Fix exception for folder move/copy between storages 58/57258/5
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 19:47:40 +0000 (21:47 +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/57258
Reviewed-by: Nicole Cordes <typo3@cordes.co>
Reviewed-by: Mathias Brodala <mbrodala@pagemachine.de>
Tested-by: TYPO3com <no-reply@typo3.com>
Reviewed-by: Willi Wehmeier <wwwehmeier@gmail.com>
Tested-by: Willi Wehmeier <wwwehmeier@gmail.com>
Reviewed-by: Stefan Neufeind <typo3.neufeind@speedpartner.de>
Tested-by: Stefan Neufeind <typo3.neufeind@speedpartner.de>
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 83ae106..d59c25e 100644 (file)
@@ -22,6 +22,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;
@@ -2061,11 +2062,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);
     }
 
     /**
@@ -2118,11 +2119,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 b9466ac..fd8c0dd 100644 (file)
@@ -40,6 +40,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;
 
 /**
@@ -662,7 +663,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) {
@@ -693,7 +694,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) {
@@ -757,7 +758,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) {
@@ -792,7 +793,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) {