[BUGFIX] Message when trying to create existing folder 33/36733/7
authorMichael Oehlhof <typo3@oehlhof.de>
Sat, 7 Feb 2015 22:20:53 +0000 (23:20 +0100)
committerStefan Froemken <froemken@gmail.com>
Tue, 14 Jul 2015 08:39:11 +0000 (10:39 +0200)
Show a flash message when trying to create a folder with a name that
already exists.

Releases: master
Resolves: #14509
Change-Id: Ia293ea61a3a892103c9b82affe5f527f1c05b39e
Reviewed-on: http://review.typo3.org/36733
Reviewed-by: Nicole Cordes <typo3@cordes.co>
Tested-by: Nicole Cordes <typo3@cordes.co>
Reviewed-by: Georg Ringer <georg.ringer@gmail.com>
Tested-by: Georg Ringer <georg.ringer@gmail.com>
Reviewed-by: Stefan Froemken <froemken@gmail.com>
Tested-by: Stefan Froemken <froemken@gmail.com>
typo3/sysext/core/Classes/Resource/ResourceStorage.php
typo3/sysext/core/Classes/Utility/File/ExtendedFileUtility.php

index 28b9fa2..f7abdc6 100644 (file)
@@ -2090,10 +2090,11 @@ class ResourceStorage implements ResourceStorageInterface {
         *
         * @param string $folderName The new folder name
         * @param Folder $parentFolder (optional) the parent folder to create the new folder inside of. If not given, the root folder is used
-        *
+        * @return Folder
+        * @throws Exception\ExistingTargetFolderException
+        * @throws Exception\InsufficientFolderAccessPermissionsException
         * @throws Exception\InsufficientFolderWritePermissionsException
-        * @throws \InvalidArgumentException
-        * @return Folder The new folder object
+        * @throws \Exception
         */
        public function createFolder($folderName, Folder $parentFolder = NULL) {
                if ($parentFolder === NULL) {
@@ -2104,6 +2105,9 @@ class ResourceStorage implements ResourceStorageInterface {
                if (!$this->checkFolderActionPermission('add', $parentFolder)) {
                        throw new Exception\InsufficientFolderWritePermissionsException('You are not allowed to create directories in the folder "' . $parentFolder->getIdentifier() . '"', 1323059807);
                }
+               if ($this->driver->folderExists($folderName)) {
+                       throw new Exception\ExistingTargetFolderException('Folder "' . $folderName . '" already exists.', 1423347324);
+               }
 
                $this->emitPreFolderAddSignal($parentFolder, $folderName);
 
index f9e4f58..726ddde 100644 (file)
@@ -275,7 +275,7 @@ class ExtendedFileUtility extends BasicFileUtility {
                foreach ($this->getErrorMessages() as $msg) {
                        $flashMessage = GeneralUtility::makeInstance(
                                FlashMessage::class,
-                               htmlspecialchars($msg),
+                               $msg,
                                '',
                                FlashMessage::ERROR,
                                TRUE