Bug #44518
closedCaching problem with Gifbuilder
100%
Description
I had a cachingproblem with the Gifbuilder. Everytime I cleared the cache, a new image was generated although the TS-setup wasn't changed.
Here my the TS-Code: file = GIFBUILDER
file{
quality = 100
XY = [10.w],[10.h]
format = png
10 = IMAGE
10{
file.import.data = register:ORIG_FILENAME
file.maxH = 760m
file.maxW = 940m
}
20 = IMAGE
20{
file = fileadmin/img/wasserT.png
offset = [10.w]/2 - 25, [10.h] - 45
}
}
(Without the second layer I hadn't the problem (without 20).)
In typo3/sysext/frontend/Classes/Imaging/GifBuilder.php
I figured out that the generated filename was different every run.
@ public function fileName($pre) {
...
// WARNING: In PHP5 I discovered that rendering with freetype of Japanese letters was totally corrupt.
// Not only the wrong glyphs are printed but also some memory stack overflow resulted in strange additional
// chars - and finally the reason for this investigation: The Bounding box data was changing all the time
// resulting in new images being generated all the time. With PHP4 it works fine.
return $this->tempPath . $pre . $meaningfulPrefix . \TYPO3\CMS\Core\Utility\GeneralUtility::shortMD5(serialize($this->setup)) . '.' . $this->extension();
}@
(the comment shows that the problem already appeared in a different way)
The problem is the md5hash of $this->setup. $this->setup is an array witch contains 2 objects ['BBOX']['originalFile'] and ['BBOX']['originalFile']. These objects are different after the cache was cleared.
My solution: copy $this->setup to $this->setupLight and remove these objects from setupLight. I've done this in:
@
public function start($conf, $data) {
...
// BBOX (the fileinfo) is to big and different each run: $this->fileName() generates a new file every run, because it uses a md5hash of this array
// ['BBOX']['originalFile'] and ['BBOX']['originalFile'] are Objects (to big and different each run)
// $this-setupLight is used now in $this->fileName()
//
$this->setupLight = $this->setup;
foreach ($sKeyArray as $theKey) {
$this->setupLight[$theKey . '.']['BBOX']['originalFile']='';
$this->setupLight[$theKey . '.']['BBOX']['processedFile']='';
}
//
// Get trivial data
$XY = \TYPO3\CMS\Core\Utility\GeneralUtility::intExplode(',', $this->setup['XY']);
$maxWidth = isset($this->setup['maxWidth.']) ? intval($this->cObj->stdWrap($this->setup['maxWidth'], $this->setup['maxWidth.'])) : intval($this->setup['maxWidth']);
$maxHeight = isset($this->setup['maxHeight.']) ? intval($this->cObj->stdWrap($this->setup['maxHeight'], $this->setup['maxHeight.'])) : intval($this->setup['maxHeight']);
$XY[0] = \TYPO3\CMS\Core\Utility\MathUtility::forceIntegerInRange($XY[0], 1, $maxWidth ? $maxWidth : 2000);
$XY[1] = \TYPO3\CMS\Core\Utility\MathUtility::forceIntegerInRange($XY[1], 1, $maxHeight ? $maxHeight : 2000);
$this->XY = $XY;
$this->w = $XY[0];
$this->h = $XY[1];
$this->OFFSET = \TYPO3\CMS\Core\Utility\GeneralUtility::intExplode(',', $this->setup['offset']);
// this sets the workArea
$this->setWorkArea($this->setup['workArea']);
// this sets the default to the current;
$this->defaultWorkArea = $this->workArea;
}
}
@
then I changed in function fileName():
return $this->tempPath . $pre . $meaningfulPrefix . \TYPO3\CMS\Core\Utility\GeneralUtility::shortMD5(serialize($this->setup)) . '.' . $this->extension();
to
return $this->tempPath . $pre . $meaningfulPrefix . \TYPO3\CMS\Core\Utility\GeneralUtility::shortMD5(serialize($this->setupLight)) . '.' . $this->extension();