From f25b5fc840f7693ac2274934a4b63455285d2ffb Mon Sep 17 00:00:00 2001 From: Mathias Brodala Date: Tue, 21 May 2024 15:13:36 +0200 Subject: [PATCH] [BUGFIX] Forward request to Fluid preview renderer See https://docs.typo3.org/c/typo3/cms-core/main/en-us/Changelog/12.0/Breaking-98377-FluidStandaloneViewDoesNotCreateAnExtbaseRequestAnymore.html --- Classes/Indexer/Indexer.php | 9 +++++++++ Classes/Preview/FluidPreviewRenderer.php | 10 ++++++++-- .../RequestAwarePreviewRendererInterface.php | 13 +++++++++++++ Classes/Utility/TsfeUtility.php | 2 ++ 4 files changed, 32 insertions(+), 2 deletions(-) create mode 100644 Classes/Preview/RequestAwarePreviewRendererInterface.php diff --git a/Classes/Indexer/Indexer.php b/Classes/Indexer/Indexer.php index 664b1ea..258b6d5 100644 --- a/Classes/Indexer/Indexer.php +++ b/Classes/Indexer/Indexer.php @@ -6,6 +6,7 @@ use PAGEmachine\Searchable\LinkBuilder\PageLinkBuilder; use PAGEmachine\Searchable\Preview\DefaultPreviewRenderer; use PAGEmachine\Searchable\Preview\PreviewRendererInterface; +use PAGEmachine\Searchable\Preview\RequestAwarePreviewRendererInterface; use PAGEmachine\Searchable\Query\BulkQuery; use PAGEmachine\Searchable\Query\UpdateQuery; use PAGEmachine\Searchable\Service\ExtconfService; @@ -244,6 +245,10 @@ public function run() { TsfeUtility::createTSFE($this->config['siteIdentifier'] ?? null, $this->language); + if (is_a($this->previewRenderer, RequestAwarePreviewRendererInterface::class)) { + $this->previewRenderer->setRequest($GLOBALS['TYPO3_REQUEST']); + } + $bulkSize = ($this->config['bulkSize'] ?? null) ?: 20; $counter = 0; @@ -287,6 +292,10 @@ public function runUpdate() { TsfeUtility::createTSFE($this->config['siteIdentifier'] ?? null, $this->language); + if (is_a($this->previewRenderer, RequestAwarePreviewRendererInterface::class)) { + $this->previewRenderer->setRequest($GLOBALS['TYPO3_REQUEST']); + } + $bulkSize = ($this->config['bulkSize'] ?? null) ?: 20; $counter = 0; diff --git a/Classes/Preview/FluidPreviewRenderer.php b/Classes/Preview/FluidPreviewRenderer.php index 17aea0f..16a86b2 100644 --- a/Classes/Preview/FluidPreviewRenderer.php +++ b/Classes/Preview/FluidPreviewRenderer.php @@ -1,10 +1,12 @@ prepareView(); } + public function setRequest(ServerRequestInterface $request): void + { + $this->view->setRequest($request); + } /** * Renders the preview diff --git a/Classes/Preview/RequestAwarePreviewRendererInterface.php b/Classes/Preview/RequestAwarePreviewRendererInterface.php new file mode 100644 index 0000000..90785fc --- /dev/null +++ b/Classes/Preview/RequestAwarePreviewRendererInterface.php @@ -0,0 +1,13 @@ +getMajorVersion() < 12) { $frontendController->getConfigArray($request); + } else { + $GLOBALS['TYPO3_REQUEST'] = $frontendController->getFromCache($GLOBALS['TYPO3_REQUEST']); } $GLOBALS['TSFE'] = $frontendController;