[BUGFIX] RTE: Magic Images are put in root folder 23/19623/2
authorBenjamin Mack <benni@typo3.org>
Sat, 23 Mar 2013 15:28:59 +0000 (16:28 +0100)
committerSteffen Ritter <info@rs-websystems.de>
Fri, 5 Apr 2013 19:51:57 +0000 (21:51 +0200)
Due to some problems when find the magic folder, currently
all files from the RTE are put in the root directory of the TYPO3
installation.

However, RTE should use the default upload folder of the user
by default.

Resolves: #46605
Releases: 6.1, 6.0
Change-Id: I4f9f6606bccdeefde563d243a2ad1c9311c6ae81
Reviewed-on: https://review.typo3.org/19623
Reviewed-by: Steffen Ritter
Tested-by: Steffen Ritter
typo3/sysext/core/Classes/Resource/ResourceFactory.php
typo3/sysext/core/Classes/Resource/Service/MagicImageService.php

index a6b54f2..f8fa0d7 100644 (file)
@@ -351,7 +351,11 @@ class ResourceFactory implements \TYPO3\CMS\Core\SingletonInterface {
                        // We only got a path: Go into backwards compatibility mode and
                        // use virtual Storage (uid=0)
                        $storageUid = 0;
-                       $folderIdentifier = substr($parts[0], strlen(PATH_site));
+                       $folderIdentifier = $parts[0];
+                       // make sure to not use an absolute path, and remove PATH_site if it is prepended
+                       if (\TYPO3\CMS\Core\Utility\GeneralUtility::isFirstPartOfStr($folderIdentifier, PATH_site)) {
+                               $folderIdentifier = substr($parts[0], strlen(PATH_site));
+                       }
                }
                return $this->getStorageObject($storageUid)->getFolder($folderIdentifier);
        }
index cbdb99c..be382cc 100644 (file)
@@ -48,13 +48,19 @@ class MagicImageService {
         * @return \TYPO3\CMS\Core\Resource\Folder
         */
        protected function getMagicFolder($targetFolderCombinedIdentifier) {
-               $fileFactory = \TYPO3\CMS\Core\Resource\ResourceFactory::getInstance();
-               // @todo Proper exception handling is missing here
-               if ($targetFolderCombinedIdentifier) {
-                       $magicFolder = $fileFactory->getFolderObjectFromCombinedIdentifier($targetFolderCombinedIdentifier);
-               }
-               if (empty($magicFolder) || !$magicFolder instanceof \TYPO3\CMS\Core\Resource\Folder) {
-                       $magicFolder = $fileFactory->getFolderObjectFromCombinedIdentifier($GLOBALS['TYPO3_CONF_VARS']['BE']['RTE_imageStorageDir']);
+               // check if the input is already a folder
+               if ($targetFolderCombinedIdentifier instanceof \TYPO3\CMS\Core\Resource\Folder) {
+                       $magicFolder = $targetFolderCombinedIdentifier;
+               } else {
+                       $fileFactory = \TYPO3\CMS\Core\Resource\ResourceFactory::getInstance();
+
+                       // @todo Proper exception handling is missing here
+                       if ($targetFolderCombinedIdentifier) {
+                               $magicFolder = $fileFactory->getFolderObjectFromCombinedIdentifier($targetFolderCombinedIdentifier);
+                       }
+                       if (empty($magicFolder) || !$magicFolder instanceof \TYPO3\CMS\Core\Resource\Folder) {
+                               $magicFolder = $fileFactory->getFolderObjectFromCombinedIdentifier($GLOBALS['TYPO3_CONF_VARS']['BE']['RTE_imageStorageDir']);
+                       }
                }
                return $magicFolder;
        }