Issue Bug Closed

#93345Exception when image with 0 bytes is used for click enlarge

Torben Hansen 01/22/21, 10:38 updated 12/02/25, 14:33

Description

This edge case issue occurred after a TYPO3 8.7 to 10.4 migration.

How to reproduce:

  • TypoScript Constant styles.content.textmedia.linkWrap.lightboxEnabled = 1 must be set
  • User uploads an image file test.jpg which has a size of 0 bytes
  • User uses the uploaded image in a image content element
  • User sets the file width or height in the content element to a various integer (e.g. 100)
  • User selects the “Click-Enlarge” option

Opening the page with the image content element will result in an exception.

PHP Catchable Fatal Error: Object of class TYPO3\CMS\Core\Resource\FileReference could not be converted to string in /path/to/typo3/typo3_src-10.4.12/typo3/sysext/frontend/Classes/ContentObject/ContentObjectRenderer.php line 4454

Reason:
https://github.com/TYPO3/TYPO3.CMS/blob/master/typo3/sysext/frontend/Classes/ContentObject/ContentObjectRenderer.php#L3999

isImage() returns false since the file is 0 bytes and then the FilePathSanitizer tries to typecast the file variable (which is a FileReference) to a string.

Reviews 2