Review main Merged

94530[BUGFIX] Guard undefined array key in ImageProcessingInstructions

Garvin Hicking CR +2 V +2 Normal +177 −2 updated 06/26/26, 11:50

Commit message

Even though `ImageProcessingInstructions` is declared internal API,
and the `GraphicalFunctions->resize()` method is too, data passed
to the public method `GraphicslFunctions->imageMagickConvert()`
can pass along `$options` to the image processing instructions.

If these options contain a `['crop' => '']` definition, this
leads to an "undefined array key warning" in the evaluation.

This is now fixed by guarding for an empty string, and also
guarding for a "wrong" string format with a wrong amount
of separating commas now.

Tests to cover more input variants are added to prove the
patch and prevent further regressions.

Review

  • Code review CR +2 Done
    • Garvin Hicking +2
    • Oliver Klee +1
    • Oliver Hader +1
    • Ravi Sachaniya +1
    • Simon Schaufelberger +1
  • Verified V +2 Done
    • Garvin Hicking +2
    • Oliver Klee +1
    • Oliver Hader +1
    • Ravi Sachaniya +1
    • Simon Schaufelberger +1
    • core-ci +1 CI

Issues 2

Files 2

Review log 1213

  1. Garvin Hicking uploaded patch set 1 06/18/26, 18:00

  2. core-ci voted on patch set 1 V +1 06/18/26, 18:08 Core CI is happy: https://git.typo3.org/typo3/CI/cms/-/pipelines/103641

  3. Oliver Klee voted on patch set 1 CR +1 V +1 06/18/26, 19:24

  4. Ravi Sachaniya voted on patch set 1 CR +1 V +1 06/22/26, 05:32

  5. Simon Schaufelberger voted on patch set 1 CR +1 V +1 06/22/26, 08:32

  6. Oliver Hader commented on patch set 1 V +1 06/22/26, 10:55

    ImageProcessingInstructions.php:326

    What about using a combination directly - this way, the new `elseif` branch could be omitted. ``` if (is_string($options['crop']) && $options['crop'] !== '') { ```
  7. Garvin Hicking commented on patch set 1 06/22/26, 11:14

    ImageProcessingInstructions.php:326 Reply

    The problem there is the indentation of it - I need a dedicated upper-level "unset(...)" one without the json_decode on top of it. Otherwise the later "insteanceof Area" would be non-matching and then I'd have an additional "else" branch at the end. So I figured an explicit "else" at the top would be more readable.
  8. Oliver Hader commented on patch set 1 CR +1 06/22/26, 11:48

    ImageProcessingInstructions.php:326 Reply

    In any way, the code reads fine...
  9. Garvin Hicking commented on patch set 1 CR +2 V +2 06/22/26, 14:07

    thx! 😊
  10. Garvin Hicking merged patch set 2 06/22/26, 14:19

  11. Benjamin Franzke commented on patch set 2 06/25/26, 10:36

    @garvin@hick.ing Can you explain why https://forge.typo3.org/issues/103351 is related? Did it introduce the problem? (It seems the json_encode/explode existed before)
  12. Garvin Hicking commented on patch set 2 06/25/26, 11:05

    Reply

    The relation to 103351 was just because in that patch the cropping values were also sanitized, but not completely. I have not checked whether the bug was introduced there - I only saw that the cropping calculations in there was unified and centralized there, and so I related it as a "hint, hint - look at why this was already once refactored".
  13. Garvin Hicking commented on patch set 2 06/26/26, 11:50

    Please note a late-backport to 13.4 was also made.