Review main Merged

71435[BUGFIX] Fix undefined key when reverting redirects

Robert Kärner CR +2 V +2 Easy +1 −1 updated 10/05/21, 10:25

Commit message

A neccessary check is added to prevent
the undefined array key warning on PHP 8.0

Review

  • Code review CR +2 Done
    • Benjamin Franzke +2
    • Andreas Kienast +2
    • Oliver Klee +1
    • Nikita Hovratov +1
  • Verified V +2 Done
    • Benjamin Franzke +2
    • Andreas Kienast +2
    • Nikita Hovratov +1
    • core-ci +1 CI

Issues 1

Files 1

Review log 2225

  1. Robert Kärner uploaded patch set 1 10/05/21, 07:29

  2. Oli Bartsch commented on patch set 1 10/05/21, 07:35

    RecordHistory.php:173

    Could we use `$insertsDeletes[$field] ?? false` instead of the magic empty() ?
  3. core-ci voted on patch set 1 V +1 10/05/21, 07:46 Core CI is happy: https://gitlab.typo3.org/typo3/CI/cms/-/pipelines/17601

  4. Robert Kärner commented on patch set 1 10/05/21, 07:51

    RecordHistory.php:173 Reply

    I agree that we should use language features instead of functions. I've also considered this, but opted out because we would have to write ```if (!($insertsDeletes[$field] ?? false)) {``` instead, and this looks uglier in my eyes and is a bit more complicated to understand at a first glance. What's your opinion on that?
  5. Robert Kärner uploaded patch set 2 10/05/21, 08:39

  6. Robert Kärner commented on patch set 2 10/05/21, 08:40

    RecordHistory.php:173 Reply

    Let's go for your suggestion, as it's more performant too.
  7. Benjamin Franzke commented on patch set 1 10/05/21, 08:41

    RecordHistory.php:173 Reply

    No: if (($insertsDeletes[$field] ?? null) === null) would be better
  8. Benjamin Franzke uploaded patch set 3 10/05/21, 08:45

  9. Benjamin Franzke commented on patch set 3 10/05/21, 08:45

    RecordHistory.php:173 Reply

    Done
  10. Robert Kärner voted on patch set 3 V +1 CR +1 10/05/21, 08:47

  11. Benjamin Franzke commented on patch set 3 10/05/21, 08:48

    RecordHistory.php:176

    We could also remove the IF and rather write: $insertsDeletes[$field] = ($insertsDeletes[$field] ?? 0) + ($value['action'] === 'insert' ? 1 : -1);
  12. core-ci voted on patch set 3 V +1 10/05/21, 09:00 Core CI is happy: https://gitlab.typo3.org/typo3/CI/cms/-/pipelines/17604

  13. Andreas Kienast commented on patch set 3 CR -1 10/05/21, 09:02

    RecordHistory.php:173

    why not `!isset($insertsDeletes[$field])`?
  14. Robert Kärner commented on patch set 3 10/05/21, 09:27

    RecordHistory.php:173 Reply

    That would work, as we're only dealing with integers. The only falsey value is 0, and all array values of 0 are unset in previous loop passes.
  15. Nikita Hovratov commented on patch set 3 10/05/21, 09:43

    RecordHistory.php:173 Reply

    In my eyes either use empty($var) or !($var ?? false). This is 1:1 the same as before without the warning.
  16. Robert Kärner uploaded patch set 4 10/05/21, 09:46

  17. Robert Kärner commented on patch set 4 10/05/21, 09:49

    RecordHistory.php:173 Reply

    I just pushed a new patchset with Andreas' suggestion before reading Nikitas comment.

    RecordHistory.php:176 Reply Unresolved

    This is shorter and would work, but I'm undecided. It kinda hides the intention.
  18. Nikita Hovratov commented on patch set 4 10/05/21, 09:58

    RecordHistory.php:173 Reply

    Using isset is not exactly the same as before, but more like the intended behaviour. So it's fine by me, too.
  19. Nikita Hovratov voted on patch set 4 V +1 CR +1 10/05/21, 09:58

  20. core-ci voted on patch set 4 V +1 10/05/21, 10:02 Core CI is happy: https://gitlab.typo3.org/typo3/CI/cms/-/pipelines/17605

  21. Robert Kärner commented on patch set 4 10/05/21, 10:04

    RecordHistory.php:173 Reply

    Done
  22. Oliver Klee voted on patch set 4 CR +1 10/05/21, 10:15

  23. Andreas Kienast voted on patch set 4 V +2 CR +2 10/05/21, 10:23

  24. Andreas Kienast merged patch set 5 10/05/21, 10:23

  25. Benjamin Franzke voted on patch set 5 V +2 CR +2 10/05/21, 10:25