Skip to content
Snippets Groups Projects
Commit 5c048a4c authored by Benjamin Franzke's avatar Benjamin Franzke Committed by Susanne Moog
Browse files

[BUGFIX] Fix recursive FLUIDTEMPLATE cObj's that use layoutRootPaths

FLUIDTEMPLATE variables may contain content elements (e.g. recursive
FLUIDTEMPLATE's) which may instantiate own TemplateViews
(e.g. StandaloneView).
A recursive StandaloneView will statically(!!) cache used TemplatesPaths
in \TYPO3Fluid\Fluid\View\Templates::resolvedFiles.

If StandaloneView is instantiated before, but the fluid layout path is
calculated after inner content objects are being rendering,
the altered statically cached `resolvedFiles` cache is used
and contains invalid layoutRootPaths.

Short term solution:
Defer the initialization of the StandaloneView (which flushes those
buggy caches) until all variables have been processed.

Change-Id: Idf053b3d0f0835a352790e0ed971344d67844bbc
Releases: master, 8.7
Resolves: #79760
Resolves: #82745
Reviewed-on: https://review.typo3.org/54416


Tested-by: default avatarTYPO3com <no-reply@typo3.com>
Reviewed-by: default avatarSebastian Hofer <sebastian.hofer@marit.ag>
Tested-by: default avatarSebastian Hofer <sebastian.hofer@marit.a...>
parent d7e1728e
Branches
Tags
No related merge requests found
......@@ -85,12 +85,14 @@ class FluidTemplateContentObject extends AbstractContentObject
*/
public function render($conf = [])
{
$parentView = $this->view;
$this->initializeStandaloneViewInstance();
if (!is_array($conf)) {
$conf = [];
}
$variables = $this->getContentObjectVariables($conf);
$variables = $this->contentDataProcessor->process($this->cObj, $conf, $variables);
$parentView = $this->view;
$this->initializeStandaloneViewInstance();
$this->setFormat($conf);
$this->setTemplate($conf);
......@@ -98,8 +100,6 @@ class FluidTemplateContentObject extends AbstractContentObject
$this->setPartialRootPath($conf);
$this->setExtbaseVariables($conf);
$this->assignSettings($conf);
$variables = $this->getContentObjectVariables($conf);
$variables = $this->contentDataProcessor->process($this->cObj, $conf, $variables);
$this->view->assignMultiple($variables);
......
......@@ -21,7 +21,19 @@ use TYPO3\CMS\Frontend\ContentObject\TextContentObject;
*/
class FluidTemplateContentObjectTest extends \TYPO3\TestingFramework\Core\Functional\FunctionalTestCase
{
protected $coreExtensionsToLoad = ['fluid'];
/**
* @var array
*/
protected $coreExtensionsToLoad = [
'fluid'
];
/**
* @var array
*/
protected $testExtensionsToLoad = [
'typo3/sysext/fluid/Tests/Functional/Fixtures/Extensions/fluid_test',
];
/**
* @test
......@@ -64,4 +76,52 @@ class FluidTemplateContentObjectTest extends \TYPO3\TestingFramework\Core\Functi
$this->assertEquals($expectedResult, $result);
}
/**
* @test
*/
public function renderWorksWithNestedFluidtemplateWithLayouts()
{
/** @var $tsfe \TYPO3\CMS\Frontend\Controller\TypoScriptFrontendController */
$tsfe = $this->createMock(\TYPO3\CMS\Frontend\Controller\TypoScriptFrontendController::class);
$GLOBALS['TSFE'] = $tsfe;
$configuration = [
'10' => 'FLUIDTEMPLATE',
'10.' => [
'template' => 'TEXT',
'template.' => [
'value' => '<f:layout name="BaseLayout"/><f:section name="main"><f:format.raw>{anotherFluidTemplate}</f:format.raw></f:section>'
],
'layoutRootPaths.' => [
'0' => 'EXT:fluid_test/Resources/Private/Layouts'
],
'variables.' => [
'anotherFluidTemplate' => 'FLUIDTEMPLATE',
'anotherFluidTemplate.' => [
'template' => 'TEXT',
'template.' => [
'value' => '<f:layout name="BaseLayout"/><f:section name="main"></f:section>'
],
'layoutRootPaths.' => [
'0' => 'EXT:fluid_test/Resources/Private/LayoutOverride/Layouts'
],
],
],
],
];
$expectedResult = 'DefaultLayoutLayoutOverride';
$contentObjectRenderer = new \TYPO3\CMS\Frontend\ContentObject\ContentObjectRenderer;
$contentObjectRenderer->setContentObjectClassMap([
'FLUIDTEMPLATE' => FluidTemplateContentObject::class,
'TEXT' => TextContentObject::class,
]);
$fluidTemplateContentObject = new \TYPO3\CMS\Frontend\ContentObject\ContentObjectArrayContentObject(
$contentObjectRenderer
);
$result = preg_replace('/\s+/', '', strip_tags($fluidTemplateContentObject->render($configuration)));
$this->assertEquals($expectedResult, $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