Skip to content
Snippets Groups Projects
Commit 5fcaa182 authored by Friedemann Altrock's avatar Friedemann Altrock Committed by Stefan Bürk
Browse files

[BUGFIX] Fix fluid template paths to respect TypoScript order

Only add implicit default paths (Resources/Private/X) when they
are not explicitly configured via TypoScript, as they may have
been configured as an overwrite for another base path.

Resolves: #81099
Releases: main, 12.4, 11.5
Change-Id: I0fe4cb690aa253d5d9941fcfbe0a9c9063298547
Reviewed-on: https://review.typo3.org/c/Packages/TYPO3.CMS/+/80834


Tested-by: default avatarStefan Bürk <stefan@buerk.tech>
Reviewed-by: default avatarStefan Bürk <stefan@buerk.tech>
Tested-by: default avatarcore-ci <typo3@b13.com>
parent 20b65af2
Branches
Tags
No related merge requests found
...@@ -100,7 +100,11 @@ class TemplatePaths extends \TYPO3Fluid\Fluid\View\TemplatePaths ...@@ -100,7 +100,11 @@ class TemplatePaths extends \TYPO3Fluid\Fluid\View\TemplatePaths
foreach ($paths as $name => $defaultPaths) { foreach ($paths as $name => $defaultPaths) {
if (!empty($configuredPaths[$name])) { if (!empty($configuredPaths[$name])) {
$paths[$name] = array_merge($defaultPaths, ArrayUtility::sortArrayWithIntegerKeys((array)$configuredPaths[$name])); $configured = ArrayUtility::sortArrayWithIntegerKeys((array)$configuredPaths[$name]);
// calculate implicit default paths which have not been explicitly configured
$implicitDefaultPaths = array_diff($defaultPaths, $configured);
// prepend implicit default paths (which have not been found in configured paths), as fallbacks
$paths[$name] = array_merge($implicitDefaultPaths, $configured);
} }
} }
......
...@@ -258,4 +258,52 @@ final class TemplatePathsTest extends UnitTestCase ...@@ -258,4 +258,52 @@ final class TemplatePathsTest extends UnitTestCase
], ],
], $result); ], $result);
} }
/**
* @test
*/
public function getContextSpecificViewConfigurationRespectsTypoScriptConfiguredPaths(): void
{
$configurationManager = $this->createMock(ConfigurationManagerInterface::class);
$configurationManager->expects(self::once())->method('getConfiguration')->willReturn([
'plugin.' => [
'tx_test.' => [
'view.' => [
'templateRootPaths.' => [
'0' => 'base/Templates/',
'10' => 'test/Templates/',
],
'partialRootPaths.' => [
'0' => 'base/Partials/',
'10' => 'test/Partials/',
],
'layoutRootPaths.' => [
'0' => 'base/Layouts/',
'10' => 'test/Layouts/',
],
],
],
],
]);
$subject = $this->getAccessibleMock(TemplatePaths::class, ['getConfigurationManager', 'getExtensionPrivateResourcesPath', 'isBackendMode', 'isFrontendMode']);
$subject->expects(self::once())->method('getExtensionPrivateResourcesPath')->with('test')->willReturn('test/');
$subject->expects(self::once())->method('getConfigurationManager')->willReturn($configurationManager);
$subject->expects(self::once())->method('isBackendMode')->willReturn(false);
$subject->expects(self::once())->method('isFrontendMode')->willReturn(true);
$result = $subject->_call('getContextSpecificViewConfiguration', 'test');
self::assertSame([
'templateRootPaths' => [
'base/Templates/',
'test/Templates/',
],
'partialRootPaths' => [
'base/Partials/',
'test/Partials/',
],
'layoutRootPaths' => [
'base/Layouts/',
'test/Layouts/',
],
], $result);
}
} }
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment