Skip to content

Commit

Permalink
[BUGFIX] Fix fluid template paths to respect TypoScript order
Browse files Browse the repository at this point in the history
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/+/80835
Tested-by: Stefan Bürk <stefan@buerk.tech>
Tested-by: core-ci <typo3@b13.com>
Reviewed-by: Stefan Bürk <stefan@buerk.tech>
  • Loading branch information
fwg authored and sbuerk committed Sep 1, 2023
1 parent 64859ce commit f2f79d9
Show file tree
Hide file tree
Showing 2 changed files with 53 additions and 1 deletion.
6 changes: 5 additions & 1 deletion typo3/sysext/fluid/Classes/View/TemplatePaths.php
Expand Up @@ -109,7 +109,11 @@ protected function getContextSpecificViewConfiguration($extensionKey)

foreach ($paths as $name => $defaultPaths) {
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);
}
}

Expand Down
48 changes: 48 additions & 0 deletions typo3/sysext/fluid/Tests/Unit/View/TemplatePathsTest.php
Expand Up @@ -266,4 +266,52 @@ public function getContextSpecificViewConfigurationDoesNotResolveFromTypoScriptA
],
], $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 comments on commit f2f79d9

Please sign in to comment.