Bug #63519
closedsys_file_processedfile rows contain zero dimensions
100%
Description
There is an error with the scaling process if the same picture is placed multiple times on the same page.
Some rows from table sys_file_processedfile contain zero values for width and height although the serialized configuration contains settings for width and height.
The LocalDriver moves the temporary (scaled) file after scaling but the GraphicalFunctions (scaling process)
assumes (on the basis of a database query) at the next time that the temporary file exists and try to get the image dimensions on a not existing file.
Nothing is returned and a zero value reaches the Database.
... \TYPO3\CMS\Core\Resource\Processing\LocalImageProcessor::processTask() 60: $helper = $this->getHelperByTaskName($task->getName()); 62: $result = $helper->process($task);
\TYPO3\CMS\Core\Resource\Processing\LocalCropScaleMaskHelper::process() 75: $result = $gifBuilder->imageMagickConvert( $originalFileName, $configuration['fileExtension'], $configuration['width'], $configuration['height'], $configuration['additionalParameters'], $configuration['frame'], $options );
\TYPO3\CMS\Core\Imaging\GraphicalFunctions::imageMagickConvert() 2258: $output = $this->absPrefix . $this->tempPath . 'pics/' . $this->filenamePrefix . $theOutputName . '.' . $newExt;
$output contains the temporary filename like /var/www/basisbox.local/htdocs/typo3temp/pics/5e0e4724b9.jpg
\TYPO3\CMS\Core\Imaging\GraphicalFunctions::file_exists_typo3temp_file()
This function look into the database for a entry that contain the temporary filepath ($output).
If the entry exist no scaling will be performed because there is already an temporary file.
2261: if ($this->dontCheckForExistingTempFile || !$this->file_exists_typo3temp_file($output, $imagefile)) { 2262: $this->imageMagickExec($imagefile, $output, $command, $frame); 2263: } 2264: if (file_exists($output)) {
After the file_exists_typo3temp_file() check, we check the existence of the temporary file again and return its dimensions.
If the file does not exist, nothing will be returned.
Back to the processTask
\TYPO3\CMS\Core\Resource\Processing\LocalImageProcessor::processTask() 73: $task->getTargetFile()->updateWithLocalFile($result['filePath']);
After the scaling the scaled file will be added to the storage
$result['filePath'] contain the temporary filepath eg. /var/www/basisbox.local/htdocs/typo3temp/pics/5e0e4724b9.jpg
\TYPO3\CMS\Core\Resource\ProcessedFile::updateWithLocalFile() 181: $addedFile = $this->storage->updateProcessedFile($filePath, $this);
\TYPO3\CMS\Core\Resource\ResourceStorage::updateProcessedFile() 1118: $fileIdentifier = $this->driver->addFile($localFilePath, $this->getProcessingFolder()->getIdentifier(), $processedFile->getName());
\TYPO3\CMS\Core\Resource\Driver\LocalDriver::addFile() 662: $result = rename($localFilePath, $targetPath);
At this point the temporary file /var/www/basisbox.local/htdocs/typo3temp/pics/5e0e4724b9.jpg will be moved to another location.
The next scaling process will fail because
\TYPO3\CMS\Core\Imaging\GraphicalFunctions::file_exists_typo3temp_file()
find a database record that contains this filename.
The process don't render the file again because
\TYPO3\CMS\Core\Imaging\GraphicalFunctions::imageMagickConvert()
2264: if (file_exists($output)) {
don't find the file and return nothing and the sys_file_processedfile row will be filled with height = 0 and width = 0