Skip to content

Commit

Permalink
[BUGFIX] Prevent TYPO3v11 controllerContext deprecation notice
Browse files Browse the repository at this point in the history
When using flux 10.0.10 on TYPO3v11, the deprecation log is full of
> TYPO3 Deprecation Notice:
> Setting request from controllerContext in class
> TYPO3\CMS\Fluid\Core\Rendering\RenderingContext is deprecated.
> Use setRequest() directly.
> in typo3/sysext/fluid/Classes/Core/Rendering/RenderingContext.php line 205

The deprecation notice is only triggered when the context has no request yet.

To get rid of this notice, we simply set the request before setting the
controller context.
  • Loading branch information
cweiske authored and NamelessCoder committed Dec 9, 2024
1 parent e238a82 commit b0573ba
Showing 1 changed file with 4 additions and 4 deletions.
8 changes: 4 additions & 4 deletions Classes/Builder/RenderingContextBuilder.php
Original file line number Diff line number Diff line change
Expand Up @@ -48,6 +48,10 @@ public function buildRenderingContextFor(
$pluginName
);

if (method_exists($renderingContext, 'setRequest')) {
$renderingContext->setRequest($request);
}

if (method_exists($renderingContext, 'getControllerContext')) {
/** @var ControllerContext $controllerContext */
$controllerContext = $this->buildControllerContext($request);
Expand All @@ -60,10 +64,6 @@ public function buildRenderingContextFor(
}
}

if (method_exists($renderingContext, 'setRequest')) {
$renderingContext->setRequest($request);
}

if (method_exists($renderingContext, 'setControllerAction')) {
$renderingContext->setControllerAction($controllerActionName);
}
Expand Down

0 comments on commit b0573ba

Please sign in to comment.