From d1bf1a06d8906a55a29e42831afcd07ff3efc7af Mon Sep 17 00:00:00 2001 From: Claus Due <claus@namelesscoder.net> Date: Fri, 18 Nov 2016 17:38:24 +0100 Subject: [PATCH] [BUGFIX] Fix regression in RenderingContext::__construct w/o View This patch fixes a regression after https://review.typo3.org/#/c/50590/ which unfortunately caused some custom implementations (e.g. static info tables extension) to fail with a PHP fatal error. Change-Id: I61f7327208e20a973471fbfed02fe83c00d3995c Resolves: #78746 Releases: master Reviewed-on: https://review.typo3.org/50708 Tested-by: TYPO3com <no-reply@typo3.com> Reviewed-by: Christian Kuhn <lolli@schwarzbu.ch> Tested-by: Christian Kuhn <lolli@schwarzbu.ch> Tested-by: Riccardo De Contardi <erredeco@gmail.com> Reviewed-by: Andreas Fernandez <typo3@scripting-base.de> Tested-by: Andreas Fernandez <typo3@scripting-base.de> --- .../Core/Rendering/RenderingContext.php | 20 +++++++++++++++---- 1 file changed, 16 insertions(+), 4 deletions(-) diff --git a/typo3/sysext/fluid/Classes/Core/Rendering/RenderingContext.php b/typo3/sysext/fluid/Classes/Core/Rendering/RenderingContext.php index 7b0554becf59..09a927eed0f3 100644 --- a/typo3/sysext/fluid/Classes/Core/Rendering/RenderingContext.php +++ b/typo3/sysext/fluid/Classes/Core/Rendering/RenderingContext.php @@ -24,10 +24,13 @@ use TYPO3\CMS\Fluid\Core\Parser\SyntaxTree\Expression\LegacyNamespaceExpressionN use TYPO3\CMS\Fluid\Core\Variables\CmsVariableProvider; use TYPO3\CMS\Fluid\Core\ViewHelper\ViewHelperResolver; use TYPO3\CMS\Fluid\View\TemplatePaths; +use TYPO3Fluid\Fluid\Core\Compiler\TemplateCompiler; use TYPO3Fluid\Fluid\Core\Parser\Configuration; use TYPO3Fluid\Fluid\Core\Parser\SyntaxTree\Expression\CastingExpressionNode; use TYPO3Fluid\Fluid\Core\Parser\SyntaxTree\Expression\MathExpressionNode; use TYPO3Fluid\Fluid\Core\Parser\SyntaxTree\Expression\TernaryExpressionNode; +use TYPO3Fluid\Fluid\Core\Parser\TemplateParser; +use TYPO3Fluid\Fluid\Core\ViewHelper\ViewHelperInvoker; use TYPO3Fluid\Fluid\Core\ViewHelper\ViewHelperVariableContainer; use TYPO3Fluid\Fluid\View\ViewInterface; @@ -117,12 +120,21 @@ class RenderingContext extends \TYPO3Fluid\Fluid\Core\Rendering\RenderingContext */ public function __construct(ViewInterface $view = null) { - parent::__construct($view); + if ($view !== null) { + // Note: if $view is received here this indicates internal framework instancing + // and it is safe to call the parent constructor. Custom, non-view-providing + // usages will only perform the initialisation below (which is sufficient mind you!) + parent::__construct($view); + } else { + // Reproduced partial initialisation from parent::__construct; minus the custom + // implementations we attach below. + $this->setTemplateParser(new TemplateParser()); + $this->setTemplateCompiler(new TemplateCompiler()); + $this->setViewHelperInvoker(new ViewHelperInvoker()); + $this->setViewHelperVariableContainer(new ViewHelperVariableContainer()); + } $objectManager = GeneralUtility::makeInstance(ObjectManager::class); - if ($view) { - $this->view = $view; - } $this->setTemplatePaths($objectManager->get(TemplatePaths::class)); $this->setViewHelperResolver($objectManager->get(ViewHelperResolver::class)); $this->setVariableProvider($objectManager->get(CmsVariableProvider::class)); -- GitLab