Skip to content

Commit

Permalink
[BUGFIX] Use serialized variant of setup in GifBuilder hash
Browse files Browse the repository at this point in the history
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 <typo3@b13.com>
Tested-by: Andreas Nedbal <andy@pixelde.su>
Reviewed-by: Andreas Nedbal <andy@pixelde.su>
  • Loading branch information
pixeldesu committed Sep 21, 2023
1 parent b87e32a commit ae91f46
Showing 1 changed file with 6 additions and 3 deletions.
9 changes: 6 additions & 3 deletions typo3/sysext/frontend/Classes/Imaging/GifBuilder.php
Expand Up @@ -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;
Expand Down Expand Up @@ -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,
Expand Down

0 comments on commit ae91f46

Please sign in to comment.