Review main Merged

72104[BUGFIX] Fix undefined array key errors in ContentObjectRenderer

Chris Müller CR +2 V +2 Easy +2 −2 updated 11/10/21, 12:25

Commit message

Review

  • Code review CR +2 Done
    • Christian Kuhn +2
    • Nikita Hovratov +1
  • Verified V +2 Done
    • Christian Kuhn +2
    • Nikita Hovratov +1
    • core-ci +1 CI

Issues 1

Files 1

Review log 1315

  1. Chris Müller uploaded patch set 1 11/09/21, 19:10

  2. core-ci voted on patch set 1 V +1 11/09/21, 19:23 Core CI is happy: https://git.typo3.org/typo3/CI/cms/-/pipelines/19084

  3. Christian Kuhn voted on patch set 1 V +1 CR +1 11/09/21, 19:25

  4. Nikita Hovratov voted on patch set 1 CR +1 11/09/21, 21:24

  5. Oli Bartsch commented on patch set 1 11/09/21, 21:45

    ContentObjectRenderer.php:5969

    This looks like change in behaviour. The exact replacement would be "$conf[$property] ?? false".
  6. Christian Kuhn commented on patch set 1 11/09/21, 22:06

    ContentObjectRenderer.php:5969 Reply

    really? even if that array key is accessed in the if-body?
  7. Chris Müller commented on patch set 1 11/10/21, 06:58

    ContentObjectRenderer.php:5969 Reply

    Hmm, after thinking about that: In principle, $conf[$property] can have the value "null" which is set and then throws a type error, as the 3rd argument of str_replace() must be a string or an array. So I think, this edge case is not covered, and should be like Oliver said. But don't know, if the value of a property can be null.
  8. Nikita Hovratov commented on patch set 1 11/10/21, 09:12

    ContentObjectRenderer.php:5969 Reply

    @Chris if $conf[$property] is set as null, isset would return false. This is the reason array key existance should be checked by array_key_exists instead (in general). But for this one what Oli means, is that before it was the truthy value of the array entry. Technically correct replacement would be: !empty($conf[$property]) or $conf[$property] ?? false We use the last one more often. People say it's faster than to call a function.
  9. Christian Kuhn commented on patch set 1 11/10/21, 10:12

    ContentObjectRenderer.php:5969 Reply

    so we update patch to use null coalescence?
  10. Nikita Hovratov uploaded patch set 2 11/10/21, 11:30

  11. Nikita Hovratov commented on patch set 2 11/10/21, 11:30

    ContentObjectRenderer.php:5969 Reply

    Done
  12. Nikita Hovratov voted on patch set 2 V +1 CR +1 11/10/21, 11:32

  13. core-ci voted on patch set 2 V +1 11/10/21, 11:41 Core CI is happy: https://git.typo3.org/typo3/CI/cms/-/pipelines/19121

  14. Christian Kuhn voted on patch set 2 V +2 CR +2 11/10/21, 12:25

  15. Christian Kuhn merged patch set 3 11/10/21, 12:25