Review main Merged

87567[BUGFIX] Ensure AVIF files are only written when format is supported

Garvin Hicking CR +2 V +2 Normal +95 −5 updated 01/02/25, 20:30

Commit message

The implementation with #105704 contained a bug that did not properly
check if 'avif' writing support was enabled, and did not trigger
the proper fallback chain.

This is moved now so that an 'avif' target file format is checked
in both cases:

a) For generic 'web' format, keeping an existing AVIF file and
   resizing it. Note this fallback is currently only used in
   legacy cases.

b) For the specific 'avif' output format.

Tests are added to ensure this works.

A coupled bug #105847 is fixed to ensure that when the
conversion of a format fails, the actually used file extension
will be persisted to the processed file. This scenario only really
happens with the current AVIF implementation, which is why
this bugfix is not made independently.

Without this bugfix, when a file like "test.jpg" should
be converted to "test.avif", but no AVIF processing is
available (GraphicsMagick), the resulting file would be
stored as "csm_test_4815162342.avif" - containing
JPEG contents though. With this fix, the file will be
persisted as "csm_test_4815162342.avif.jpg" to also
indicate a processing fallback chain took place.

Review

  • Code review CR +2 Done
    • Garvin Hicking +2
    • Stefan Bürk +1
    • Sebastian Iffland +1
    • Benni Mack +1
  • Verified V +2 Done
    • Garvin Hicking +2
    • Stefan Bürk +1
    • Oliver Hader +1
    • Benni Mack +1
    • core-ci +1 CI

Issues 3

Files 5

Review log 1923

  1. Garvin Hicking uploaded patch set 1 12/19/24, 09:08

  2. core-ci voted on patch set 1 V -1 12/19/24, 09:16 Core CI is not happy: https://git.typo3.org/typo3/CI/cms/-/pipelines/71436

  3. Garvin Hicking uploaded patch set 2 V -1 12/19/24, 09:17

  4. core-ci voted on patch set 2 V +1 12/19/24, 09:24 Core CI is happy: https://git.typo3.org/typo3/CI/cms/-/pipelines/71437

  5. Sebastian Iffland commented on patch set 2 12/19/24, 09:30

    GraphicalFunctions.php:353

    Q: What if? - "web-compatible" case applied - 'avif' format applied - `$this->avifSupportAvailable()` is true (L338 effective) Then the $targetFileExtension is set to 'avif' which will lead to return null here because not in `$this->imageFileExt`, if I read right.
  6. Garvin Hicking commented on patch set 2 12/19/24, 09:51

    GraphicalFunctions.php:353 Reply

    Thank you for reading/checking this intensively. In this case, the DefaultConfiguration sets imagefile_ext to contain 'avif' actually, and should be evaluated to enhance `$this->imageFileExt` in the constructor of GraphicalFunctions. So "this should work, I hope"(tm) ;)
  7. Sebastian Iffland commented on patch set 2 CR +1 12/19/24, 10:55

    GraphicalFunctions.php:353 Reply

    OK, got it. Indeed that will work in the end if `$GLOBALS['TYPO3_CONF_VARS']['GFX']['imagefile_ext']` was provided with 'avif'. Thanks for clarification!
  8. Garvin Hicking uploaded patch set 3 CR +1 V +1 12/21/24, 14:24

  9. core-ci voted on patch set 3 V +1 12/21/24, 14:31 Core CI is happy: https://git.typo3.org/typo3/CI/cms/-/pipelines/71526

  10. Garvin Hicking commented on patch set 3 12/21/24, 14:53

    I've updated this patch to fix the bug I noticed. In a follow-up for v14 I would like to streamline this further, especially removing the "gif_or_jpeg" method plus removing the default values in `$imageFileExt` of the class, so that it will become more clear that the TYPO3_CONF_VARS imagefile_ext is the actual source of that array.
  11. Sebastian Iffland voted on patch set 3 CR +1 01/02/25, 06:26

  12. Stefan Bürk commented on patch set 3 CR -1 01/02/25, 11:49

    Reviewing ...
  13. Stefan Bürk uploaded patch set 4 CR +1 V +1 01/02/25, 13:50

  14. Stefan Bürk commented on patch set 4 01/02/25, 13:51

    Reply

    Done
  15. Stefan Bürk voted on patch set 4 CR +1 V +1 01/02/25, 13:53

  16. core-ci voted on patch set 4 V +1 01/02/25, 13:57 Core CI is happy: https://git.typo3.org/typo3/CI/cms/-/pipelines/71827

  17. Sebastian Iffland voted on patch set 4 CR +1 01/02/25, 14:39

  18. Sebastian Iffland commented on patch set 4 01/02/25, 14:42

    Just an idea…

    GraphicalFunctions.php:350

    What about direct assign check result to variable? Probably better in reading (IMO). ``` } elseif ($targetFileExtension === 'avif') { // Outside the "web-compatible" case above, we also need to check if a // specific output format can be written. // For now, only AVIF has special support check handling. $useFallback = !$this->avifSupportAvailable(); } ```
  19. Garvin Hicking commented on patch set 4 01/02/25, 15:35

    GraphicalFunctions.php:350 Reply

    I see your point, thank you! However I personally find it harder to read to have negated variable assignments. Thats a matter of taste of course, so I hope you won't mind to keep it like the current form maybe? that makes it easier for me to fix bugs in this if I introduced one ;-)
  20. Benni Mack voted on patch set 4 CR +1 V +1 01/02/25, 16:11

  21. Garvin Hicking voted on patch set 4 CR +2 V +2 01/02/25, 16:26

  22. Garvin Hicking merged patch set 5 01/02/25, 16:36

  23. Oliver Hader voted on patch set 5 V +1 01/02/25, 20:30