Skip to content

Commit f7a36ae

Browse files
committed
[BUGFIX] Ensure trailing slash for PAGEVIEW paths
Since `paths` are used to generate paths for partials and layouts, it must be ensured that each path ends with a slash. Resolves: #105646 Releases: main, 13.4 Change-Id: I296e2571082fb15d324155f6cf822dfdf4be7bba Reviewed-on: https://review.typo3.org/c/Packages/TYPO3.CMS/+/87156 Reviewed-by: Andreas Nedbal <andy@pixelde.su> Tested-by: Christian Kuhn <lolli@schwarzbu.ch> Tested-by: core-ci <typo3@b13.com> Reviewed-by: Christian Kuhn <lolli@schwarzbu.ch> Tested-by: Simon Praetorius <simon@praetorius.me> Reviewed-by: Simon Praetorius <simon@praetorius.me> Tested-by: Andreas Nedbal <andy@pixelde.su>
1 parent bc80217 commit f7a36ae

File tree

5 files changed

+25
-3
lines changed

5 files changed

+25
-3
lines changed

typo3/sysext/frontend/Classes/ContentObject/PageViewContentObject.php

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -19,6 +19,7 @@
1919

2020
use TYPO3\CMS\Core\Page\PageLayoutResolver;
2121
use TYPO3\CMS\Core\TypoScript\TypoScriptService;
22+
use TYPO3\CMS\Core\Utility\PathUtility;
2223
use TYPO3\CMS\Core\View\ViewFactoryData;
2324
use TYPO3\CMS\Core\View\ViewFactoryInterface;
2425
use TYPO3\CMS\Frontend\ContentObject\Exception\ContentRenderingException;
@@ -83,14 +84,15 @@ public function render($conf = []): string
8384
1724601907
8485
);
8586
}
87+
$paths = array_map(PathUtility::sanitizeTrailingSeparator(...), $conf['paths.']);
8688
$viewFactoryData = new ViewFactoryData(
8789
// @todo: Do discuss: Rename 'paths.' to 'templateRootPaths.' again?
88-
templateRootPaths: $conf['paths.'],
90+
templateRootPaths: $paths,
8991
// @todo: We should *still* allow setting both partialRootPaths and layoutRootPaths, and only fall back to
9092
// [templateRootPaths]/Partials and [templateRootPaths]/Layouts if not set. And the fallback should be
9193
// advertised as best practice.
92-
partialRootPaths: array_map(static fn(string $path): string => $path . 'Partials/', $conf['paths.']),
93-
layoutRootPaths: array_map(static fn(string $path): string => $path . 'Layouts/', $conf['paths.']),
94+
partialRootPaths: array_map(static fn(string $path): string => $path . 'Partials/', $paths),
95+
layoutRootPaths: array_map(static fn(string $path): string => $path . 'Layouts/', $paths),
9496
request: $this->request,
9597
);
9698
$view = $this->viewFactory->create($viewFactoryData);

typo3/sysext/frontend/Tests/Functional/ContentObject/PageViewContentObjectTest.php

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -96,4 +96,18 @@ public function assignReservedVariableNameInTypoScriptThrowsInvalidArgumentExcep
9696
self::expectExceptionMessage(sprintf('Cannot use reserved name "%s" as variable name in PAGEVIEW.', $variableName));
9797
$this->executeFrontendSubRequest((new InternalRequest())->withPageId(self::ROOT_PAGE_ID));
9898
}
99+
100+
#[Test]
101+
public function pathsCanBeSpecifiedWithoutTrailingSlash(): void
102+
{
103+
$this->setUpFrontendRootPage(
104+
self::ROOT_PAGE_ID,
105+
[
106+
'EXT:frontend/Tests/Functional/Fixtures/Extensions/test_fluidpagerendering/Configuration/TypoScript/withoutTrailingSlash.typoscript',
107+
]
108+
);
109+
$response = $this->executeFrontendSubRequest((new InternalRequest())->withPageId(self::ROOT_PAGE_ID));
110+
self::assertStringContainsString('You are on page Fluid Root Page', (string)$response->getBody());
111+
self::assertStringContainsString('This is content from the test partial.', (string)$response->getBody());
112+
}
99113
}
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,4 @@
1+
page = PAGE
2+
page.10 = PAGEVIEW
3+
page.10.paths.100 = EXT:test_fluidpagerendering/Resources/Private/Templates
4+

typo3/sysext/frontend/Tests/Functional/Fixtures/Extensions/test_fluidpagerendering/Resources/Private/Templates/Pages/Standard.html

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3,4 +3,5 @@
33
<f:section name="content">
44
This is a standard page with no content.
55
page-layout-identifier-{page.pageLayout.identifier}
6+
<f:render partial="TestPartial" />
67
</f:section>
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
This is content from the test partial.

0 commit comments

Comments
 (0)