Skip to content

Commit

Permalink
Merge pull request #4569 from neos/bugfix/fusionExceptionViewUsesWron…
Browse files Browse the repository at this point in the history
…gRequestWithoutControllerContext

BUGFIX: FusionExceptionView must use mocked controller context
  • Loading branch information
mhsdesign authored Sep 29, 2023
2 parents bdeb74b + a50a672 commit 4de3469
Showing 1 changed file with 8 additions and 5 deletions.
13 changes: 8 additions & 5 deletions Neos.Neos/Classes/View/FusionExceptionView.php
Original file line number Diff line number Diff line change
Expand Up @@ -102,9 +102,12 @@ class FusionExceptionView extends AbstractView
public function render()
{
$requestHandler = $this->bootstrap->getActiveRequestHandler();
$httpRequest = $requestHandler instanceof HttpRequestHandler
? $requestHandler->getHttpRequest()
: ServerRequest::fromGlobals();

if (!$requestHandler instanceof HttpRequestHandler) {
throw new \RuntimeException('The FusionExceptionView only works in web requests.', 1695975353);
}

$httpRequest = $requestHandler->getHttpRequest();

$siteDetectionResult = SiteDetectionResult::fromRequest($httpRequest);
$contentRepository = $this->contentRepositoryRegistry->get($siteDetectionResult->contentRepositoryId);
Expand Down Expand Up @@ -204,14 +207,14 @@ protected function getFusionRuntime(
$fusionConfiguration = $this->fusionService->createFusionConfigurationFromSite($site);

$fusionGlobals = FusionGlobals::fromArray([
'request' => $this->controllerContext->getRequest(),
'request' => $controllerContext->getRequest(),
'renderingModeName' => RenderingMode::FRONTEND
]);
$this->fusionRuntime = $this->runtimeFactory->createFromConfiguration(
$fusionConfiguration,
$fusionGlobals
);
$this->fusionRuntime->setControllerContext($this->controllerContext);
$this->fusionRuntime->setControllerContext($controllerContext);

if (isset($this->options['enableContentCache']) && $this->options['enableContentCache'] !== null) {
$this->fusionRuntime->setEnableContentCache($this->options['enableContentCache']);
Expand Down

0 comments on commit 4de3469

Please sign in to comment.