Skip to content

Commit

Permalink
[BUGFIX] Do not reuse TemplateView instance when reading available pa…
Browse files Browse the repository at this point in the history
…ge templates

Some change in TYPO3v12's Fluid dep has caused the TemplateParser to
hold on to invalid states of parsed templates. Likely has to do with the
many hoop-jumps the Fluid team has had to do since declaring that shared
ViewHelper instances is a totally valid use case.

I'm getting really tired of TYPO3's decisions as of late.
  • Loading branch information
NamelessCoder committed May 7, 2024
1 parent d6ed733 commit 654b993
Show file tree
Hide file tree
Showing 2 changed files with 4 additions and 2 deletions.
4 changes: 2 additions & 2 deletions Classes/Service/PageService.php
Original file line number Diff line number Diff line change
Expand Up @@ -229,8 +229,6 @@ public function getAvailablePageTemplateFiles(): array
$typoScript = $this->getPageConfiguration();
$output = [];

/** @var TemplateView $view */
$view = GeneralUtility::makeInstance(TemplateView::class);
foreach ((array) $typoScript as $extensionName => $group) {
if (!($group['enable'] ?? true)) {
continue;
Expand All @@ -251,6 +249,8 @@ public function getAvailablePageTemplateFiles(): array
continue;
}

/** @var TemplateView $view */
$view = GeneralUtility::makeInstance(TemplateView::class);
$view->getRenderingContext()->setTemplatePaths($templatePaths);
$view->getRenderingContext()->getViewHelperVariableContainer()->addOrUpdate(
FormViewHelper::SCOPE,
Expand Down
2 changes: 2 additions & 0 deletions Tests/Unit/Service/PageServiceTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -121,6 +121,8 @@ public function testGetAvailablePageTemplateFiles($typoScript, $expected): void
$instance->method('createTemplatePaths')->willReturn($templatePaths);
$instance->method('getPageConfiguration')->willReturn($typoScript);

// There are exactly 2 page template fixtures. We need to return exactly two mock instances of TemplateView.
GeneralUtility::addInstance(TemplateView::class, $templateView);
GeneralUtility::addInstance(TemplateView::class, $templateView);

$result = $instance->getAvailablePageTemplateFiles();
Expand Down

0 comments on commit 654b993

Please sign in to comment.