Review main Merged

72638[BUGFIX] Fix array access warnings in EditDocumentController

Robert Kärner CR +2 V +2 Easy +1 −1 updated 12/13/21, 14:10

Commit message

$this->firstEl is checked for !== null several times in
EditDocumentController, but it most certainly isn't, because
reset() returns false instead of null, if the array is empty.

This patch resolves this problem by setting $this->firstEl to
null, if reset($this->elementsData) returned false.

Review

  • Code review CR +2 Done
    • Benni Mack +2
    • Oliver Klee +1
    • Robert Kärner +1
    • Stefan Bürk +1
  • Verified V +2 Done
    • Benni Mack +2
    • Robert Kärner +1
    • core-ci +1 CI

Issues 1

Files 1

Review log 810

  1. Robert Kärner uploaded patch set 1 12/13/21, 07:04

  2. core-ci voted on patch set 1 V +1 12/13/21, 07:17 Core CI is happy: https://git.typo3.org/typo3/CI/cms/-/pipelines/21016

  3. Stefan Bürk commented on patch set 1 CR -1 12/13/21, 11:29

    EditDocumentController.php:1026

    That construct is not safe enough, as it would change the "first" element to null, if first element would be an "false" value. Even if this should be the case here, we should use a general construct which is save, as this could be reused or copied to other places. See: https://3v4l.org/og1nv Would suggest to use here this, which would return null for an empty array directly, and do not handle on first element data which could be false: ``` $this->firstEl = $this->elementsData ? reset($this->elementsData) : null; ```
  4. Stefan Bürk uploaded patch set 2 12/13/21, 12:18

  5. Stefan Bürk commented on patch set 2 CR +1 12/13/21, 12:19

    EditDocumentController.php:1026 Reply

    Done
  6. Robert Kärner commented on patch set 2 V +1 CR +1 12/13/21, 12:28

    EditDocumentController.php:1026 Reply

    Thank you for pushing the new patchset; I was busy until now. I agree that your solution is safer, good point.
  7. core-ci voted on patch set 2 V +1 12/13/21, 12:43 Core CI is happy: https://git.typo3.org/typo3/CI/cms/-/pipelines/21028

  8. Oliver Klee voted on patch set 2 CR +1 12/13/21, 13:37

  9. Benni Mack voted on patch set 2 V +2 CR +2 12/13/21, 14:09

  10. Benni Mack merged patch set 3 12/13/21, 14:10