Bug #63519

sys_file_processedfile rows contain zero dimensions

Added by Ralf Zimmermann 8 months ago. Updated 3 months ago.

Status:Resolved Start date:2014-12-02
Priority:Must have Due date:
Assigned To:- % Done:

100%

Category:File Abstraction Layer (FAL) Spent time: -
Target version:-
TYPO3 Version:6.2 Is Regression:No
PHP Version:5.3 Sprint Focus:On Location Sprint
Complexity:medium

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


Related issues

related to Core - Task #64643: Remove feature enable_typo3temp_db_tracking Resolved 2015-01-30
related to Core - Bug #62400: Lot of entries in sys_file_processed with name=NULL and i... Rejected 2014-10-22
related to Core - Bug #65842: Cropping Images in GIFBUILDER is broken since TYPO3 CMS 6... Resolved 2015-03-19

Associated revisions

Revision c5b7a0d9
Added by Morton Jonuschat 3 months ago

[BUGFIX] Temporary filename collision in imageMagickConvert()

Add more entropy to the temporary filename used by imageMagickConvert()
to ensure different processing configurations resulting in the same
output dimensions get different temporary names.

In combination with LocalDriver moving the temporary file to a different
location and file_exists_typo3temp_file() having a 30s window where it
doesn't detect the moved file (when the user enabled
$TYPO3_CONF_VARS['GFX']['enable_typo3temp_db_tracking']) this
leads to entries in the sys_processed_file table with a width and
height of 0, thus referencing the original file and resulting in
unscaled images showing in the frontend.

Resolves: #65842
Resolves: #63519
Resolves: #60215
Related: #65378
Releases: 6.2
Change-Id: I42748d0899bf1e24f9f92f2e55802d64309c5704
Reviewed-on: http://review.typo3.org/39373
Reviewed-by: Stephan Großberndt <>
Reviewed-by: Frans Saris <>
Reviewed-by: Andreas Fernandez <>
Tested-by: Andreas Fernandez <>
Reviewed-by: Markus Klein <>
Tested-by: Markus Klein <>

History

#1 Updated by Ralf Zimmermann 8 months ago

I forgot to mention this happens if GFX[enable_typo3temp_db_tracking] = 1

#2 Updated by Ingo Schmitt 7 months ago

  • Sprint Focus set to On Location Sprint

#3 Updated by Ingo Schmitt 6 months ago

  • Complexity set to medium

#4 Updated by Ingo Schmitt 6 months ago

We should check, if this is still present after applying 64643. Because GFX[enable_typo3temp_db_tracking] is removed.

#5 Updated by Bjoern Jacob 6 months ago

#64643 removes GFX[enable_typo3temp_db_tracking] only for 7.x. So the bug is still in 6.2 present.

#6 Updated by Gerrit Code Review 3 months ago

  • Status changed from New to Under Review

Patch set 1 for branch master of project Packages/TYPO3.CMS has been pushed to the review server.
It is available at http://review.typo3.org/39372

#7 Updated by Gerrit Code Review 3 months ago

Patch set 1 for branch TYPO3_6-2 of project Packages/TYPO3.CMS has been pushed to the review server.
It is available at http://review.typo3.org/39373

#8 Updated by Gerrit Code Review 3 months ago

Patch set 2 for branch TYPO3_6-2 of project Packages/TYPO3.CMS has been pushed to the review server.
It is available at http://review.typo3.org/39373

#9 Updated by Gerrit Code Review 3 months ago

Patch set 3 for branch TYPO3_6-2 of project Packages/TYPO3.CMS has been pushed to the review server.
It is available at http://review.typo3.org/39373

#10 Updated by Morton Jonuschat 3 months ago

  • Status changed from Under Review to Resolved
  • % Done changed from 0 to 100

Also available in: Atom PDF