Commit 39797983 authored by Benni Mack's avatar Benni Mack Committed by Andreas Fernandez
Browse files

[BUGFIX] Make GifBuilder calculation of filename hash faster

The GifBuilder calculation does not need all of setup
to calculate the values for the filename.

Therefore, only the relevant parameters are used, making
the shortMD5 call faster, according to the ticket author.

Resolves: #64158
Releases: master
Change-Id: I9ffd1e1f8a14c8f3904e83f251122225562de606
Reviewed-on: https://review.typo3.org/c/Packages/TYPO3.CMS/+/62234

Reviewed-by: Susanne Moog's avatarSusanne Moog <look@susi.dev>
Reviewed-by: default avatarGuido Schmechel <guido.schmechel@brandung.de>
Reviewed-by: Andreas Fernandez's avatarAndreas Fernandez <a.fernandez@scripting-base.de>
Tested-by: Susanne Moog's avatarSusanne Moog <look@susi.dev>
Tested-by: default avatarTYPO3com <noreply@typo3.com>
Tested-by: Andreas Fernandez's avatarAndreas Fernandez <a.fernandez@scripting-base.de>
parent 29af6f5c
......@@ -711,7 +711,6 @@ class GifBuilder extends GraphicalFunctions
*/
public function fileName($pre)
{
/** @var \TYPO3\CMS\Core\Utility\File\BasicFileUtility $basicFileFunctions */
$basicFileFunctions = GeneralUtility::makeInstance(BasicFileUtility::class);
$filePrefix = implode('_', array_merge($this->combinedTextStrings, $this->combinedFileNames));
$filePrefix = $basicFileFunctions->cleanFileName(ltrim($filePrefix, '.'));
......@@ -719,7 +718,21 @@ class GifBuilder extends GraphicalFunctions
// shorten prefix to avoid overly long file names
$filePrefix = substr($filePrefix, 0, 100);
return 'typo3temp/' . $pre . $filePrefix . '_' . GeneralUtility::shortMD5(serialize($this->setup)) . '.' . $this->extension();
// 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
$hashInputForFileName = [
array_keys($this->setup),
$filePrefix,
$this->im,
$this->w,
$this->h,
$this->map,
$this->workArea,
$this->combinedTextStrings,
$this->combinedFileNames,
$this->data
];
return 'typo3temp/' . $pre . $filePrefix . '_' . GeneralUtility::shortMD5(json_encode($hashInputForFileName)) . '.' . $this->extension();
}
/**
......
Supports Markdown
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment