diff --git a/typo3/sysext/core/Classes/Page/AssetCollector.php b/typo3/sysext/core/Classes/Page/AssetCollector.php index d46b23eee7f94ef0c8b2608d99c2e73cddaf10d7..19581c8d4512aedb78857d21957b5916a8985982 100644 --- a/typo3/sysext/core/Classes/Page/AssetCollector.php +++ b/typo3/sysext/core/Classes/Page/AssetCollector.php @@ -121,14 +121,25 @@ class AssetCollector implements SingletonInterface return $this; } + /** + * @param string $fileName + * @param array $additionalInformation One dimensional hash map (array with non numerical keys) with scalar values + * @return AssetCollector + */ public function addMedia(string $fileName, array $additionalInformation): self { $existingAdditionalInformation = $this->media[$fileName] ?? []; - ArrayUtility::mergeRecursiveWithOverrule($existingAdditionalInformation, $additionalInformation); + ArrayUtility::mergeRecursiveWithOverrule($existingAdditionalInformation, $this->ensureAllValuesAreSerializable($additionalInformation)); $this->media[$fileName] = $existingAdditionalInformation; return $this; } + private function ensureAllValuesAreSerializable(array $additionalInformation): array + { + // Currently just filtering all non scalar values + return array_filter($additionalInformation, 'is_scalar'); + } + public function removeJavaScript(string $identifier): self { unset($this->javaScripts[$identifier]); diff --git a/typo3/sysext/core/Classes/Page/PageRenderer.php b/typo3/sysext/core/Classes/Page/PageRenderer.php index dc6110724e877d94ce358e0c29b2cd81e048f82c..60851ddc33f29cbfddf649df4d46d14c6660d0b7 100644 --- a/typo3/sysext/core/Classes/Page/PageRenderer.php +++ b/typo3/sysext/core/Classes/Page/PageRenderer.php @@ -323,11 +323,6 @@ class PageRenderer implements SingletonInterface */ protected $metaTagRegistry; - /** - * @var AssetCollector - */ - protected $assetCollector; - /** * @var FrontendInterface */ @@ -353,18 +348,16 @@ class PageRenderer implements SingletonInterface ]; $this->metaTagRegistry = GeneralUtility::makeInstance(MetaTagManagerRegistry::class); - $this->assetCollector = GeneralUtility::makeInstance(AssetCollector::class); $this->setMetaTag('name', 'generator', 'TYPO3 CMS'); } /** - * Set restored meta tag managers as singletons and asset collector + * Set restored meta tag managers as singletons * so that uncached plugins can use them to add or remove meta tags */ public function __wakeup() { GeneralUtility::setSingletonInstance(get_class($this->metaTagRegistry), $this->metaTagRegistry); - GeneralUtility::setSingletonInstance(get_class($this->assetCollector), $this->assetCollector); } /** @@ -1795,7 +1788,7 @@ class PageRenderer implements SingletonInterface $jsInline = ''; } // Use AssetRenderer to inject all JavaScripts and CSS files - $assetRenderer = GeneralUtility::makeInstance(AssetRenderer::class, $this->assetCollector); + $assetRenderer = GeneralUtility::makeInstance(AssetRenderer::class); $jsInline .= $assetRenderer->renderInlineJavaScript(true); $jsFooterInline .= $assetRenderer->renderInlineJavaScript(); $jsFiles .= $assetRenderer->renderJavaScript(true); diff --git a/typo3/sysext/extbase/Classes/Service/ImageService.php b/typo3/sysext/extbase/Classes/Service/ImageService.php index db04869669fcf21c175a196a42f66c7e167d156d..aff9de167de5a4f86b9541f1296df087093ee2f9 100644 --- a/typo3/sysext/extbase/Classes/Service/ImageService.php +++ b/typo3/sysext/extbase/Classes/Service/ImageService.php @@ -177,16 +177,22 @@ class ImageService implements \TYPO3\CMS\Core\SingletonInterface */ protected function setCompatibilityValues(ProcessedFile $processedImage): void { + $imageInfoValues = $this->getCompatibilityImageResourceValues($processedImage); if ( $this->environmentService->isEnvironmentInFrontendMode() && is_object($GLOBALS['TSFE']) ) { - $GLOBALS['TSFE']->lastImageInfo = $this->getCompatibilityImageResourceValues($processedImage); + // This is needed by \TYPO3\CMS\Frontend\Imaging\GifBuilder, + // but was never needed to be set in lastImageInfo. + // We set it for BC here anyway, as this TSFE property is deprecated anyway. + $imageInfoValues['originalFile'] = $processedImage->getOriginalFile(); + $imageInfoValues['processedFile'] = $processedImage; + $GLOBALS['TSFE']->lastImageInfo = $imageInfoValues; $GLOBALS['TSFE']->imagesOnPage[] = $processedImage->getPublicUrl(); } GeneralUtility::makeInstance(AssetCollector::class)->addMedia( $processedImage->getPublicUrl(), - $this->getCompatibilityImageResourceValues($processedImage) + $imageInfoValues ); } @@ -208,10 +214,6 @@ class ImageService implements \TYPO3\CMS\Core\SingletonInterface 3 => $processedImage->getPublicUrl(), 'origFile' => $originalFile->getPublicUrl(), 'origFile_mtime' => $originalFile->getModificationTime(), - // This is needed by \TYPO3\CMS\Frontend\Imaging\GifBuilder, - // in order for the setup-array to create a unique filename hash. - 'originalFile' => $originalFile, - 'processedFile' => $processedImage ]; } } diff --git a/typo3/sysext/frontend/Classes/ContentObject/ContentObjectRenderer.php b/typo3/sysext/frontend/Classes/ContentObject/ContentObjectRenderer.php index 99e24378a83d0173a9c1d9c4c03f7e3568ae7fd7..0e3dd3a1c5ab632324368b33f5e0f12dad6258ee 100644 --- a/typo3/sysext/frontend/Classes/ContentObject/ContentObjectRenderer.php +++ b/typo3/sysext/frontend/Classes/ContentObject/ContentObjectRenderer.php @@ -1056,9 +1056,11 @@ class ContentObjectRenderer implements LoggerAwareInterface } else { $source = $info[3]; } + // Remove file objects for AssetCollector, as it only allows to store scalar values + unset($info['originalFile'], $info['processedFile']); GeneralUtility::makeInstance(AssetCollector::class)->addMedia( $source, - $info ?? [] + $info ); $layoutKey = $this->stdWrap($conf['layoutKey'], $conf['layoutKey.']); diff --git a/typo3/sysext/frontend/Classes/Controller/TypoScriptFrontendController.php b/typo3/sysext/frontend/Classes/Controller/TypoScriptFrontendController.php index f242dd4e517ba7a6c04e13d9a73200852e2bcbf3..7c40e41f8d270c07150ced47d249961ddae837f8 100644 --- a/typo3/sysext/frontend/Classes/Controller/TypoScriptFrontendController.php +++ b/typo3/sysext/frontend/Classes/Controller/TypoScriptFrontendController.php @@ -2992,7 +2992,7 @@ class TypoScriptFrontendController implements LoggerAwareInterface } if (!empty($this->config['INTincScript_ext']['assetCollector'])) { /** @var AssetCollector $assetCollectorr */ - $assetCollector = unserialize($this->config['INTincScript_ext']['assetCollector'], ['allowed_classes' => false]); + $assetCollector = unserialize($this->config['INTincScript_ext']['assetCollector'], ['allowed_classes' => [AssetCollector::class]]); GeneralUtility::setSingletonInstance(AssetCollector::class, $assetCollector); } diff --git a/typo3/sysext/frontend/Classes/Http/RequestHandler.php b/typo3/sysext/frontend/Classes/Http/RequestHandler.php index 783d62fa3d234b6137fa8d9be8da7ed8890ae6f8..83e7d7689829aebe9b08acd3f1fd4acf44fc2daa 100644 --- a/typo3/sysext/frontend/Classes/Http/RequestHandler.php +++ b/typo3/sysext/frontend/Classes/Http/RequestHandler.php @@ -24,6 +24,7 @@ use TYPO3\CMS\Core\Core\Environment; use TYPO3\CMS\Core\Http\NullResponse; use TYPO3\CMS\Core\Http\Response; use TYPO3\CMS\Core\Information\Typo3Information; +use TYPO3\CMS\Core\Page\AssetCollector; use TYPO3\CMS\Core\Page\PageRenderer; use TYPO3\CMS\Core\Site\Entity\SiteLanguage; use TYPO3\CMS\Core\TimeTracker\TimeTracker; @@ -197,6 +198,8 @@ class RequestHandler implements RequestHandlerInterface if ($controller->isINTincScript()) { // Store the serialized pageRenderer in configuration $controller->config['INTincScript_ext']['pageRenderer'] = serialize($pageRenderer); + // Store the serialized AssetCollector in configuration + $controller->config['INTincScript_ext']['assetCollector'] = serialize(GeneralUtility::makeInstance(AssetCollector::class)); // Render complete page, keep placeholders for JavaScript and CSS return $pageRenderer->renderPageWithUncachedObjects($controller->config['INTincScript_ext']['divKey']); }