diff --git a/typo3/sysext/core/Documentation/Changelog/master/Breaking-83256-RemovedLockFilePathFunctionality.rst b/typo3/sysext/core/Documentation/Changelog/master/Breaking-83256-RemovedLockFilePathFunctionality.rst new file mode 100644 index 0000000000000000000000000000000000000000..c3acf3a882d0f19e71feb461cddf91c7b52ad301 --- /dev/null +++ b/typo3/sysext/core/Documentation/Changelog/master/Breaking-83256-RemovedLockFilePathFunctionality.rst @@ -0,0 +1,51 @@ +.. include:: ../../Includes.txt + +===================================================== +Breaking: #83256 - Removed lockFilePath functionality +===================================================== + +See :issue:`83256` + +Description +=========== + +The TypoScript option :typoscript:`config.lockFilePath` has been removed, which was possible to allow TypoScript +:typoscript:`stdWrap.filelist` to use a different base directory than fileadmin/ (which was the default). + +However, :typoscript:`stdWrap.filelist` now checks for valid local FAL storages (File Abstraction Layer), which can +now be used if multiple storages are in use. + +Thus, the following PHP property has been removed: + +* :php:`TYPO3\CMS\Frontend\Controller\TypoScriptFrontendController->lockFilePath + +The following PHP method has been removed: + +* :php:`TYPO3\CMS\Frontend\ContentObject\ContentObjectRenderer->clean_directory()` + + +Impact +====== + +Setting :typoscript:`config.lockFilePath` has no effect anymore. + +Accessing or setting :php:`TYPO3\CMS\Frontend\Controller\TypoScriptFrontendController->lockFilePath` will trigger +a PHP notice. + +Calling :php:`TYPO3\CMS\Frontend\ContentObject\ContentObjectRenderer->clean_directory()` will trigger a PHP fatal error. + + +Affected Installations +====================== + +Any installation using the PHP method/property or having config.lockFilePath set to a specific non-FAL folder, +and using stdWrap.filelist functionality. + + +Migration +========= + +If the TypoScript option was set to a different folder than a FAL storage, ensure to set a local FAL storage +to this folder. + +.. index:: Frontend, TypoScript, PartiallyScanned diff --git a/typo3/sysext/frontend/Classes/ContentObject/ContentObjectRenderer.php b/typo3/sysext/frontend/Classes/ContentObject/ContentObjectRenderer.php index 754b0ac9a4c8ee2a93d6774e6224ed8253aedfa4..83fb59abd34156b8c11c1f93f1be1d24e86b8a89 100644 --- a/typo3/sysext/frontend/Classes/ContentObject/ContentObjectRenderer.php +++ b/typo3/sysext/frontend/Classes/ContentObject/ContentObjectRenderer.php @@ -37,6 +37,7 @@ use TYPO3\CMS\Core\Resource\FileReference; use TYPO3\CMS\Core\Resource\Folder; use TYPO3\CMS\Core\Resource\ProcessedFile; use TYPO3\CMS\Core\Resource\ResourceFactory; +use TYPO3\CMS\Core\Resource\StorageRepository; use TYPO3\CMS\Core\Service\DependencyOrderingService; use TYPO3\CMS\Core\Service\MarkerBasedTemplateService; use TYPO3\CMS\Core\TimeTracker\TimeTracker; @@ -3067,15 +3068,28 @@ class ContentObjectRenderer if ($data === '') { return ''; } - $data_arr = explode('|', $data); + list($possiblePath, $ext_list, $sorting, $reverse, $useFullPath) = GeneralUtility::trimExplode('|', $data); // read directory: // MUST exist! $path = ''; - if ($this->getTypoScriptFrontendController()->lockFilePath) { - // Cleaning name..., only relative paths accepted. - $path = $this->clean_directory($data_arr[0]); - // See if path starts with lockFilePath, the additional '/' is needed because clean_directory gets rid of it - $path = GeneralUtility::isFirstPartOfStr($path . '/', $this->getTypoScriptFrontendController()->lockFilePath) ? $path : ''; + // proceeds if no '//', '..' or '\' is in the $theFile + if (GeneralUtility::validPathStr($possiblePath)) { + // Removes all dots, slashes and spaces after a path. + $possiblePath = preg_replace('/[\\/\\. ]*$/', '', $possiblePath); + if (!GeneralUtility::isAbsPath($possiblePath) && @is_dir($possiblePath)) { + // Now check if it matches one of the FAL storages + $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); + if (GeneralUtility::isFirstPartOfStr($possiblePath . '/', $folder)) { + $path = $possiblePath; + break; + } + } + } + } } if (!$path) { return ''; @@ -3084,8 +3098,7 @@ class ContentObjectRenderer 'files' => [], 'sorting' => [] ]; - $ext_list = strtolower(GeneralUtility::uniqueList($data_arr[1])); - $sorting = trim($data_arr[2]); + $ext_list = strtolower(GeneralUtility::uniqueList($ext_list)); // Read dir: $d = @dir($path); if (is_object($d)) { @@ -3126,7 +3139,7 @@ class ContentObjectRenderer } // Sort if required if (!empty($items['sorting'])) { - if (strtolower(trim($data_arr[3])) !== 'r') { + if (strtolower($reverse) !== 'r') { asort($items['sorting']); } else { arsort($items['sorting']); @@ -3135,37 +3148,15 @@ class ContentObjectRenderer if (!empty($items['files'])) { // Make list reset($items['sorting']); - $fullPath = trim($data_arr[4]); $list_arr = []; foreach ($items['sorting'] as $key => $v) { - $list_arr[] = $fullPath ? $path . '/' . $items['files'][$key] : $items['files'][$key]; + $list_arr[] = $useFullPath ? $path . '/' . $items['files'][$key] : $items['files'][$key]; } return implode(',', $list_arr); } return ''; } - /** - * Cleans $theDir for slashes in the end of the string and returns the new path, if it exists on the server. - * - * @param string $theDir Absolute path to directory - * @return string The directory path if it existed as was valid to access. - * @access private - * @see filelist() - */ - public function clean_directory($theDir) - { - // proceeds if no '//', '..' or '\' is in the $theFile - if (GeneralUtility::validPathStr($theDir)) { - // Removes all dots, slashes and spaces after a path... - $theDir = preg_replace('/[\\/\\. ]*$/', '', $theDir); - if (!GeneralUtility::isAbsPath($theDir) && @is_dir($theDir)) { - return $theDir; - } - } - return ''; - } - /** * Passes the input value, $theValue, to an instance of "\TYPO3\CMS\Core\Html\HtmlParser" * together with the TypoScript options which are first converted from a TS style array diff --git a/typo3/sysext/frontend/Classes/Controller/TypoScriptFrontendController.php b/typo3/sysext/frontend/Classes/Controller/TypoScriptFrontendController.php index 06f0bc9e1815820cce44a669aaede28fd239de2b..ab205b42b4d4d0a0e84fc842840142177d9e879b 100644 --- a/typo3/sysext/frontend/Classes/Controller/TypoScriptFrontendController.php +++ b/typo3/sysext/frontend/Classes/Controller/TypoScriptFrontendController.php @@ -482,12 +482,6 @@ class TypoScriptFrontendController implements LoggerAwareInterface */ public $absRefPrefix = ''; - /** - * Lock file path - * @var string - */ - public $lockFilePath = ''; - /** * <A>-tag parameters * @var string @@ -3208,8 +3202,6 @@ class TypoScriptFrontendController implements LoggerAwareInterface } else { $this->absRefPrefix = ''; } - $this->lockFilePath = '' . $this->config['config']['lockFilePath']; - $this->lockFilePath = $this->lockFilePath ?: $GLOBALS['TYPO3_CONF_VARS']['BE']['fileadminDir']; $this->ATagParams = trim($this->config['config']['ATagParams']) ? ' ' . trim($this->config['config']['ATagParams']) : ''; $this->initializeSearchWordDataInTsfe(); // linkVars diff --git a/typo3/sysext/install/Configuration/ExtensionScanner/Php/MethodCallMatcher.php b/typo3/sysext/install/Configuration/ExtensionScanner/Php/MethodCallMatcher.php index d18ce5c4bfa10464df9b6b6a23ba739aa7c57344..8e5988fc5df541f2c36fc10c44a76e7ea761a86c 100644 --- a/typo3/sysext/install/Configuration/ExtensionScanner/Php/MethodCallMatcher.php +++ b/typo3/sysext/install/Configuration/ExtensionScanner/Php/MethodCallMatcher.php @@ -1521,4 +1521,11 @@ return [ 'Breaking-83122-RemovedStdWrapOptionTCAselectItem.rst', ], ], + 'TYPO3\CMS\Frontend\ContentObject\ContentObjectRenderer->clean_directory' => [ + 'numberOfMandatoryArguments' => 0, + 'maximumNumberOfArguments' => 0, + 'restFiles' => [ + 'Breaking-83256-RemovedLockFilePathFunctionality.rst', + ], + ], ]; diff --git a/typo3/sysext/install/Configuration/ExtensionScanner/Php/PropertyPublicMatcher.php b/typo3/sysext/install/Configuration/ExtensionScanner/Php/PropertyPublicMatcher.php index 39099230fb56568da899cfbd7927a5414e87865d..9532841dc3fd917a4c91b9f1d985b7a647d76b55 100644 --- a/typo3/sysext/install/Configuration/ExtensionScanner/Php/PropertyPublicMatcher.php +++ b/typo3/sysext/install/Configuration/ExtensionScanner/Php/PropertyPublicMatcher.php @@ -219,6 +219,11 @@ return [ 'Breaking-81460-DeprecateGetByTagOnCacheFrontends.rst', ], ], + 'TYPO3\CMS\Frontend\Controller\TypoScriptFrontendController->lockFilePath' => [ + 'restFiles' => [ + 'Breaking-83256-RemovedLockFilePathFunctionality.rst', + ], + ], // Deprecated public properties 'TYPO3\CMS\Frontend\Page\PageRepository->workspaceCache' => [ diff --git a/typo3/sysext/t3editor/Resources/Private/tsref.xml b/typo3/sysext/t3editor/Resources/Private/tsref.xml index f2ccb938f8ccbd0d8b7568e14b14e6158a312c36..dc5c4313cb10b3e7403cdfb7642f11f81242e61e 100644 --- a/typo3/sysext/t3editor/Resources/Private/tsref.xml +++ b/typo3/sysext/t3editor/Resources/Private/tsref.xml @@ -541,11 +541,6 @@ locale_all = da_DK]]></description> <default><![CDATA[ ]]></default> </property> - <property name="lockFilePath" type="string"> - <description><![CDATA[This is used to lock paths to be "inside" this path. -Used by "filelist" in stdWrap]]></description> - <default><![CDATA[fileadmin/]]></default> - </property> <property name="message_page_is_being_generated" type="string"> <description><![CDATA[Alternative HTML message that appears if a page is being generated. Normally when a page is being generated a temporary copy is stored in the cache-table with an expire-time of 30 seconds. diff --git a/typo3/sysext/t3editor/Resources/Public/JavaScript/Mode/typoscript/typoscript.js b/typo3/sysext/t3editor/Resources/Public/JavaScript/Mode/typoscript/typoscript.js index e45785d75be4c2f53fa20671f372fa6ffab497dd..261b1247c8bcdd52c20259a7d26c342654475794 100644 --- a/typo3/sysext/t3editor/Resources/Public/JavaScript/Mode/typoscript/typoscript.js +++ b/typo3/sysext/t3editor/Resources/Public/JavaScript/Mode/typoscript/typoscript.js @@ -542,7 +542,6 @@ 'locale_all': kw('locale_all'), 'localNesting': kw('localNesting'), 'locationData': kw('locationData'), - 'lockFilePath': kw('lockFilePath'), 'lockToIP': kw('lockToIP'), 'login': B, 'loginUser': A,