From ae91f466f514994ea48c2298464ee7f58a398805 Mon Sep 17 00:00:00 2001 From: Andreas Nedbal Date: Thu, 21 Sep 2023 00:13:00 +0200 Subject: [PATCH] [BUGFIX] Use serialized variant of setup in GifBuilder hash If generated images used the exact X/Y coordinates all time (as in one documentation example) the initial image would always be reused. Serializing the setup array using ConfigurationService::serialize keeps performance but includes enough data to never reuse similarly positioned mask images. Resolves: #97212 Releases: main, 12.4 Change-Id: Ic9e02e8c082cc68a9eecf4e9b1b2bc6d770e1d17 Reviewed-on: https://review.typo3.org/c/Packages/TYPO3.CMS/+/81142 Tested-by: core-ci Tested-by: Andreas Nedbal Reviewed-by: Andreas Nedbal --- typo3/sysext/frontend/Classes/Imaging/GifBuilder.php | 9 ++++++--- 1 file changed, 6 insertions(+), 3 deletions(-) diff --git a/typo3/sysext/frontend/Classes/Imaging/GifBuilder.php b/typo3/sysext/frontend/Classes/Imaging/GifBuilder.php index 7ddccf5125fb..1b14216d7107 100644 --- a/typo3/sysext/frontend/Classes/Imaging/GifBuilder.php +++ b/typo3/sysext/frontend/Classes/Imaging/GifBuilder.php @@ -22,6 +22,7 @@ use TYPO3\CMS\Core\Resource\Exception; use TYPO3\CMS\Core\Resource\File; use TYPO3\CMS\Core\Resource\ProcessedFile; +use TYPO3\CMS\Core\Resource\Service\ConfigurationService; use TYPO3\CMS\Core\Utility\ArrayUtility; use TYPO3\CMS\Core\Utility\File\BasicFileUtility; use TYPO3\CMS\Core\Utility\GeneralUtility; @@ -711,10 +712,12 @@ public function fileName($pre) // shorten prefix to avoid overly long file names $filePrefix = substr($filePrefix, 0, 100); - // Only take relevant parameters to ease the pain for json_encode and make the final string short - // so shortMD5 is not as slow. see https://forge.typo3.org/issues/64158 + $configurationService = GeneralUtility::makeInstance(ConfigurationService::class); + + // we use ConfigurationService::serialize here to use as much of $this->setup as possible, + // but preventing inclusion of objects that could cause problems with json_encode $hashInputForFileName = [ - array_keys($this->setup), + $configurationService->serialize($this->setup), $filePrefix, $this->im, $this->XY,