Review main Merged

80812[BUGFIX] Respect crop of FileReference objects in getImgResource

Friedemann Altrock CR +2 V +2 Easy +29 −1 updated 09/08/23, 15:06

Commit message

ContentObjectRenderer::getImgResource is used for the content objects
IMAGE, IMG_RESOURCE, as well as GIFBUILDER to process images.

When it is passed a FileReference object, it should respect the crop
settings of this reference, same as when it is passed a reference UID
plus the treatIdAsReference config.

Review

  • Code review CR +2 Done
    • Stefan Bürk +2
    • Nikita Hovratov +1
  • Verified V +2 Done
    • Stefan Bürk +2
    • Oliver Klee +1
    • Nikita Hovratov +1
    • core-ci +1 CI

Issues 1

Files 3

Review log 1823

  1. Friedemann Altrock uploaded patch set 1 08/31/23, 14:24

  2. core-ci voted on patch set 1 V +1 08/31/23, 14:31 Core CI is happy: https://git.typo3.org/typo3/CI/cms/-/pipelines/46108

  3. Friedemann Altrock updated the commit message in patch set 2 V +1 08/31/23, 14:51

  4. core-ci voted on patch set 2 V +1 08/31/23, 14:58 Core CI is happy: https://git.typo3.org/typo3/CI/cms/-/pipelines/46110

  5. Oliver Klee commented on patch set 2 08/31/23, 15:34

    Can we cover this with a regression test?
  6. Benjamin Franzke uploaded patch set 3 V +1 09/01/23, 05:54

  7. Benjamin Franzke commented on patch set 3 09/01/23, 05:54

    Reply

    Done
  8. Benjamin Franzke uploaded patch set 4 CR +1 V +1 09/01/23, 05:58

  9. core-ci voted on patch set 3 V +1 09/01/23, 06:02 Core CI is happy: https://git.typo3.org/typo3/CI/cms/-/pipelines/46123

  10. core-ci voted on patch set 4 V +1 09/01/23, 06:06 Core CI is happy: https://git.typo3.org/typo3/CI/cms/-/pipelines/46124

  11. Friedemann Altrock commented on patch set 4 09/01/23, 07:59

    Reply

    Somebody got up early ;)
  12. Nikita Hovratov uploaded patch set 5 CR +1 V +1 09/01/23, 08:16

  13. Nikita Hovratov voted on patch set 5 V +1 CR +1 09/01/23, 08:17

  14. core-ci voted on patch set 5 V +1 09/01/23, 08:23 Core CI is happy: https://git.typo3.org/typo3/CI/cms/-/pipelines/46126

  15. Benjamin Franzke commented on patch set 5 09/01/23, 08:25

    ContentObjectRenderer.php:3715

    @Nikita: I don't have a strong opinion here, but `!== null` is/was sufficient here (all code paths that assigned to `$fileReference` actually returned a `FileReference`) and is slightly (but only very slightly, so it probably doesn't matter) faster. See https://gist.github.com/KVytyagov/57509333daaac69eb980777c7d28ea18 but with `instanceof` it looks like we could think of a possibility that `$fileReference` is referencing another type, not just `null`. What do you think?
  16. Nikita Hovratov commented on patch set 5 09/01/23, 08:38

    ContentObjectRenderer.php:3715 Reply

    Technically you are right. I changed it only in favor of better code readability. Less cognitive load for a "truthy" comparison instead of "is not". Also it is more robust against future code changes / refactoring.
  17. Friedemann Altrock commented on patch set 5 09/01/23, 08:42

    ContentObjectRenderer.php:3715 Reply

  18. Nikita Hovratov commented on patch set 5 09/01/23, 08:46

    ContentObjectRenderer.php:3715 Reply

    We changed it here to !== null from isset($fileReference)
  19. Oliver Klee commented on patch set 5 09/01/23, 08:51

    ContentObjectRenderer.php:3715 Reply

    Yep, cognitive load it is, and also it makes the type more specific for static analysis (the latter in many cases, but not all). In general, I hence recommend using instanceof instead of !== null.
  20. Oliver Klee voted on patch set 5 V +1 09/01/23, 08:52

  21. Oliver Klee commented on patch set 5 09/01/23, 10:33

    ContentObjectRenderer.php:3715 Reply

    Done
  22. Stefan Bürk commented on patch set 5 V +2 CR +2 09/08/23, 14:50

    ContentObjectRenderer.php:3715 Reply

    Going to merge this now. Technical, all flavours are valid. Postponing the needed bugfix because of this discussion, which needs to be done globally anyway, is not reasonable. Note: This does not reflect my opionion on this discussion or any decision on the discussion topic in generall.
  23. Stefan Bürk merged patch set 6 09/08/23, 15:06