Bug #89004

Image processing (on scaling) runs repeatedly for the same image on every page load

Added by Dalibor Hrtánek 4 months ago. Updated 18 days ago.

Should have
Image Cropping
Target version:
Start date:
Due date:
% Done:


TYPO3 Version:
PHP Version:
Is Regression:
Sprint Focus:


Hi there,

I am using the f:uri.image viewhelper in my news plugin's fluid template to generate images in 4 sizes for different devices/screens, which is placed in data-attributes of the image tag and loaded by javascript lazy loading, e.g.

{f:uri.image(src: '{image}', cropVariant: 'extrasmall', maxWidth: 768)}

This will generate a thumbnail in "_processed_" folder and related record in "sys_file_processedfile" table.
If the original image is smaller than the requested maxWidth, no processed image (resource) is created in the filesystem and the record in "sys_file_processedfile" table has empty "identifier" field instead of the filename of the processed image file.
It was working fine, but since this fix:
I started to have issues with processed images, which are using original image (do not have resized copy in processed dir, because original is small enough already).
This issue has already been described in: https://forge.typo3.org/issues/86947, which has been resolved, but I think the real problem still remained.

If you check the database specification for "sys_file_processedfile" table, you will see the default value for identifier is empty string:

identifier varchar(512) DEFAULT '' NOT NULL,

and I think the empty string value is assigned exactly when processed images are using original image (and does not have own identifier).

Then when my f:uri.image ViewHelper asks ImageService to process the image, the processing should NOT be done again, if the very same image has already been processed with the very same processingInstructions (width/height) before.
The processing is not done again, if the function isProcessed() of the ProcessedFile class returns true and this happens correctly for processed images, that have not empty identifier.
BUT it incorrectly returns false for processed images that are using original image and it is because of the change in usesOriginalFile method in: https://github.com/TYPO3/TYPO3.CMS/blob/master/typo3/sysext/core/Classes/Resource/ProcessedFile.php

    public function usesOriginalFile()
        return $this->identifier === null || $this->identifier === $this->originalFile->getIdentifier();

Where double equation mark (simple comparison) has been changed to triple (strong type comparison).
Processed images that are using original image have empty string as identifier in the database (instead of null) and therefore this condition is no longer met with strict type comparison and the original image is constantly re-processing - database records are being updated and the file is rewritten in the file system with every (uncached) page load.

I suggest to change back to weaker == comparison or fix the database specification to use NULL as default for identifier of "sys_file_processedfile" table, but that will not fix old records without some update script.



#1 Updated by Dalibor Hrtánek 4 months ago

  • TYPO3 Version changed from 10 to 8

#2 Updated by Riccardo De Contardi 18 days ago

This issue seems still valid on 9.5.11

Also available in: Atom PDF