[BUGFIX] RTE: Magic Images are put in root folder 24/19224/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:49:50 +0000 (21:49 +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/19224
Reviewed-by: Wouter Wolters
Reviewed-by: Felix Nagel
Tested-by: Felix Nagel
Reviewed-by: Tom Ruether
Reviewed-by: Stefan Neufeind
Reviewed-by: Alexander Opitz
Tested-by: Alexander Opitz
Reviewed-by: Steffen Ritter
Tested-by: Steffen Ritter
typo3/sysext/core/Classes/Resource/ResourceFactory.php
typo3/sysext/core/Classes/Resource/Service/MagicImageService.php

index 54f17a2..c13bd1d 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);
        }
@@ -459,4 +463,4 @@ class ResourceFactory implements \TYPO3\CMS\Core\SingletonInterface {
 }
 
 
-?>
\ No newline at end of file
+?>
index bbc0907..ee62ad4 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;
        }
@@ -112,4 +118,4 @@ class MagicImageService {
 }
 
 
-?>
\ No newline at end of file
+?>