[BUGFIX] Adhere absRefPrefix for storages 89/38889/2
authorMarkus Klein <klein.t3@reelworx.at>
Thu, 23 Apr 2015 22:46:41 +0000 (00:46 +0200)
committerMarkus Klein <klein.t3@reelworx.at>
Thu, 30 Apr 2015 12:00:27 +0000 (14:00 +0200)
If plain images from local storages are rendered to FE,
absRefPrefix will now be applied correctly.

Resolves: #66496
Releases: master, 6.2
Change-Id: I9c7c4590d5ca53bb4669da383462dfa63f7ab3ab
Reviewed-on: http://review.typo3.org/38889
Reviewed-by: Benjamin Mack <benni@typo3.org>
Tested-by: Benjamin Mack <benni@typo3.org>
Reviewed-by: Jan Helke <typo3@helke.de>
Tested-by: Jan Helke <typo3@helke.de>
Reviewed-by: Markus Klein <klein.t3@reelworx.at>
Tested-by: Markus Klein <klein.t3@reelworx.at>
typo3/sysext/core/Configuration/DefaultConfiguration.php
typo3/sysext/frontend/Classes/Controller/TypoScriptFrontendController.php

index 22a5460..92b1f36 100644 (file)
@@ -787,7 +787,7 @@ return array(
                'defaultTypoScript_constants.' => array(),              // Lines of TS to include after a static template with the uid = the index in the array (Constants)
                'defaultTypoScript_setup' => '',                // String (textarea). Enter lines of default TypoScript, setup-field.
                'defaultTypoScript_setup.' => array(),          // Lines of TS to include after a static template with the uid = the index in the array (Setup)
-               'additionalAbsRefPrefixDirectories' => '',              // Enter additional directories to be prepended with absRefPrefix. Directories must be comma-separated. TYPO3 already prepends the following directories: typo3conf/ext/, fileadmin/
+               'additionalAbsRefPrefixDirectories' => '',              // Enter additional directories to be prepended with absRefPrefix. Directories must be comma-separated. TYPO3 already prepends the following directories: typo3/, typo3temp/, typo3conf/ext/ and all local storages
                'IPmaskMountGroups' => array( // This allows you to specify an array of IPmaskLists/fe_group-uids. If the REMOTE_ADDR of the user matches an IPmaskList, then the given fe_group is add to the gr_list. So this is an automatic mounting of a user-group. But no fe_user is logged in though! This feature is implemented for the default frontend user authentication and might not be implemented for alternative authentication services.
                        // array('IPmaskList_1','fe_group uid'), array('IPmaskList_2','fe_group uid')
                ),
index b789c1f..2b6e8e1 100644 (file)
@@ -25,6 +25,7 @@ use TYPO3\CMS\Core\Locking\Exception\LockAcquireWouldBlockException;
 use TYPO3\CMS\Core\Locking\Locker;
 use TYPO3\CMS\Core\Messaging\ErrorpageMessage;
 use TYPO3\CMS\Core\Page\PageRenderer;
+use TYPO3\CMS\Core\Resource\StorageRepository;
 use TYPO3\CMS\Core\TypoScript\Parser\TypoScriptParser;
 use TYPO3\CMS\Core\TypoScript\TemplateService;
 use TYPO3\CMS\Core\Utility\ArrayUtility;
@@ -3953,17 +3954,25 @@ class TypoScriptFrontendController {
                        '"typo3conf/ext/',
                        '"' . TYPO3_mainDir . 'contrib/',
                        '"' . TYPO3_mainDir . 'ext/',
-                       '"' . TYPO3_mainDir . 'sysext/',
-                       '"' . $GLOBALS['TYPO3_CONF_VARS']['BE']['fileadminDir'],
+                       '"' . TYPO3_mainDir . 'sysext/'
                );
                $replace = array(
                        '"' . $this->absRefPrefix . 'typo3temp/',
                        '"' . $this->absRefPrefix . 'typo3conf/ext/',
                        '"' . $this->absRefPrefix . TYPO3_mainDir . 'contrib/',
                        '"' . $this->absRefPrefix . TYPO3_mainDir . 'ext/',
-                       '"' . $this->absRefPrefix . TYPO3_mainDir . 'sysext/',
-                       '"' . $this->absRefPrefix . $GLOBALS['TYPO3_CONF_VARS']['BE']['fileadminDir'],
+                       '"' . $this->absRefPrefix . TYPO3_mainDir . 'sysext/'
                );
+               /** @var $storageRepository StorageRepository */
+               $storageRepository = GeneralUtility::makeInstance(StorageRepository::class);
+               $storages = $storageRepository->findAll();
+               foreach ($storages as $storage) {
+                       if ($storage->getDriverType() === 'Local' && $storage->isPublic() && $storage->isOnline()) {
+                               $folder = $storage->getPublicUrl($storage->getRootLevelFolder(), TRUE);
+                               $search[] = '"' . $folder;
+                               $replace[] = '"' . $this->absRefPrefix . $folder;
+                       }
+               }
                // Process additional directories
                $directories = GeneralUtility::trimExplode(',', $GLOBALS['TYPO3_CONF_VARS']['FE']['additionalAbsRefPrefixDirectories'], TRUE);
                foreach ($directories as $directory) {