#93345Exception when image with 0 bytes is used for click enlarge
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 = 1must be set - User uploads an image file
test.jpgwhich 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
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
Related issues 2
History 1013
-
Jan Epper changed Related to #87784 <span data-processor="relativetime" data-value="2021-04-10T11:40:57+00:00" > 04/10/21, 11:40 </span>
-
B. Kausch commented <span data-processor="relativetime" data-value="2021-09-09T14:36:02+00:00" > 09/09/21, 14:36 </span>
Is there any chance this can be fixed? This bug is a nightmare, breaking the entire site after an upgrade…
-
Gerrit Code Review pushed patch set 1 for main to change 88895 status
NewUnder Review <span data-processor="relativetime" data-value="2025-04-01T21:07:56+00:00" > 04/01/25, 21:07 </span> -
Benni Mack commented and changed status
Under ReviewNeeds Feedback <span data-processor="relativetime" data-value="2025-04-10T09:31:07+00:00" > 04/10/25, 09:31 </span>This has been fixed in v13. Can anyone confirm?
-
Torben Hansen commented <span data-processor="relativetime" data-value="2025-04-11T07:23:21+00:00" > 04/11/25, 07:23 </span>
@benni I have tested the scenario following the steops from my initial report with TYPO3 v12 and v13, and the problem still persists.
-
Benni Mack commented <span data-processor="relativetime" data-value="2025-04-11T07:24:11+00:00" > 04/11/25, 07:24 </span>
Torben Hansen wrote in #note-6:
> @benni I have tested the scenario following the steops from my initial report with TYPO3 v12 and v13, and the problem still persists.Hey Torben,
can you provide a patch then? I feel like I’m missing something to reproduce this.
-
Gerrit Code Review pushed patch set 2 for main to change 88895 status
Needs FeedbackUnder Review <span data-processor="relativetime" data-value="2025-04-11T16:56:48+00:00" > 04/11/25, 16:56 </span> -
Gerrit Code Review pushed patch set 1 for 13.4 to change 89071 <span data-processor="relativetime" data-value="2025-04-11T17:15:22+00:00" > 04/11/25, 17:15 </span>
-
Benni Mack changed Related to #104559 <span data-processor="relativetime" data-value="2025-04-11T17:16:40+00:00" > 04/11/25, 17:16 </span>
-
Georg Ringer commented and changed status
Under ReviewResolved done0 %100 % <span data-processor="relativetime" data-value="2025-04-11T17:20:07+00:00" > 04/11/25, 17:20 </span>Applied in changeset commit:7b406b0e334ab4a96f31087eddd1e71f085376b5.
-
Benni Mack changed status
ResolvedClosed <span data-processor="relativetime" data-value="2025-12-02T14:33:52+00:00" > 12/02/25, 14:33 </span> -
Georg Ringer changed Duplicated by #102820 <span data-processor="relativetime" data-value="2026-09-28T20:39:53+00:00" > 09/28/26, 20:39 </span>
This seems to be the same or a similar bug like #87784. According to Adrian Dymorz from #87784 the issue disapperead so the issue has been closed and then reappeared again. I’ve recently also ran into this problem. If you replace the following code like Adrian Dymorz described it works again. But it’s not peramanent since the fix can be overwritten by an update. Unfortunatelly I’m not sure how to write a patch for this issue.
Here is the code that has to be replaced in file:
https://github.com/TYPO3/TYPO3.CMS/blob/189e065f957762283aa8d790c4a1c19d763c0eb8/typo3/sysext/frontend/Classes/ContentObject/ContentObjectRenderer.php#L4454
Old code:
New code:
Thanks to Adrian Dymorz for the solution