Review main Merged

71505[BUGFIX] Prevent undefined key warnings in ProductionExceptionHandler

Robert Kärner CR +2 V +2 Easy +10 −10 updated 10/08/21, 16:41

Commit message

Access to $GLOBALS['BE_USER'] must be protected by the
neccessary fallbacks, as no backend user might be logged
in when an exception is thrown in the frontend.

Review

  • Code review CR +2 Done
    • Benni Mack +2
    • Oli Bartsch +1
    • Oliver Klee +1
    • Robert Kärner +1
  • Verified V +2 Done
    • Benni Mack +2
    • Oli Bartsch +1
    • core-ci +1 CI

Issues 1

Files 2

Review log 2733

Show 68 earlier messages
  1. Robert Kärner uploaded patch set 1 10/08/21, 09:32

  2. core-ci voted on patch set 1 V +1 10/08/21, 09:52 Core CI is happy: https://gitlab.typo3.org/typo3/CI/cms/-/pipelines/17807

  3. Oliver Klee voted on patch set 1 CR +1 10/08/21, 10:06

  4. Oli Bartsch commented on patch set 1 10/08/21, 13:37

    AbstractExceptionHandler.php:144

    This could then be: if ($backendUser !== null) When adding the return type (see the other comment) we could remove all the isset() checks, since we are sure about the actual object.

    AbstractExceptionHandler.php:197

    We might want to add the return type "?BackendUserAuthentication" here.

    ProductionExceptionHandler.php:110

    Since this class extends the AbstractExceptionHandler, we could also use the getter method here: if (($backendUser = $this->getBackendUser()) !== null) { return $backendUser->user['uid'] > 0; }
  5. Robert Kärner commented on patch set 1 10/08/21, 13:43

    AbstractExceptionHandler.php:197 Reply

    Sounds good, I'll take care of that.
  6. Robert Kärner uploaded patch set 2 10/08/21, 13:50

  7. Robert Kärner commented on patch set 2 10/08/21, 13:51

    AbstractExceptionHandler.php:144 Reply

    Done

    AbstractExceptionHandler.php:197 Reply

    Done

    ProductionExceptionHandler.php:110 Reply

    Done
  8. core-ci voted on patch set 2 V -1 10/08/21, 13:54 Core CI is not happy: https://gitlab.typo3.org/typo3/CI/cms/-/pipelines/17821

  1. Oliver Klee commented on patch set 2 10/08/21, 13:55

    ProductionExceptionHandler.php:110

    Please let's not have assigments in conditions (as this tends to confuse the reader). Shall I fix it?
  2. Oliver Klee commented on patch set 2 10/08/21, 14:01

    (The build failure is about an unused import.)
  3. Oli Bartsch commented on patch set 2 10/08/21, 14:03

    ProductionExceptionHandler.php:110 Reply

    Yes, would be fine for me.
  4. Oliver Klee commented on patch set 2 CR -1 10/08/21, 14:05

    Okay, on it.
  5. Robert Kärner commented on patch set 2 10/08/21, 14:06

    Reply

    Ahh, I forgot to check the imports. Good to know this is checked.

    ProductionExceptionHandler.php:110 Reply

    Alright, I went with Oliver Bartsch's suggestion there. I still have the project open, let me push a new patchset real quick.
  6. Robert Kärner commented on patch set 2 10/08/21, 14:06

    Reply

    Alright, your turn. ;)
  7. Oliver Klee uploaded patch set 3 10/08/21, 14:10

  8. Oliver Klee commented on patch set 3 10/08/21, 14:11

    ProductionExceptionHandler.php:110 Reply

    Done
  9. core-ci voted on patch set 3 V +1 10/08/21, 14:25 Core CI is happy: https://gitlab.typo3.org/typo3/CI/cms/-/pipelines/17822

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

  11. Oliver Klee voted on patch set 3 CR +1 10/08/21, 14:49

  12. Oli Bartsch commented on patch set 3 10/08/21, 14:51

    Will update

    AbstractExceptionHandler.php:145

    $backendUser can only be null or BackendUserAuthentication. Therefore checking for "NULL" should be faster.

    AbstractExceptionHandler.php:149

    This is now a change in behaviour since workspace=0 is valid. Actually I meant to completely drop the if clause.
  13. Oli Bartsch uploaded patch set 4 10/08/21, 14:55

  14. Oli Bartsch uploaded patch set 5 10/08/21, 14:57

  15. Oliver Klee commented on patch set 5 10/08/21, 15:01

    AbstractExceptionHandler.php:145 Reply

    I don't know whether this has any relevant performance impact. However, I think this better communicates the intent behind the code to the reader. Please let's leave as is. (I once read an article explaining this, but I don't have it bookmarked and cannot find it anymore.)
  16. Oliver Klee commented on patch set 5 10/08/21, 15:02

    AbstractExceptionHandler.php:145 Reply

    Oliver, would you be find with changing this back to use the instanceof?
  17. core-ci voted on patch set 4 V +1 10/08/21, 15:16 Core CI is happy: https://gitlab.typo3.org/typo3/CI/cms/-/pipelines/17826

  18. Oli Bartsch uploaded patch set 6 10/08/21, 15:16

  19. Oli Bartsch commented on patch set 6 V +1 CR +1 10/08/21, 15:17

    AbstractExceptionHandler.php:145 Reply

    Done

    AbstractExceptionHandler.php:149 Reply

    Done
  20. core-ci voted on patch set 5 V +1 10/08/21, 15:17 Core CI is happy: https://gitlab.typo3.org/typo3/CI/cms/-/pipelines/17827

  21. Robert Kärner commented on patch set 6 CR +1 10/08/21, 15:20

    AbstractExceptionHandler.php:145 Reply

    Just to give you some feedback: My personal preference would be !== null, as I see this more often and using it in my own projects, but I‘m fine with instanceof too.
  22. core-ci voted on patch set 6 V +1 10/08/21, 15:34 Core CI is happy: https://gitlab.typo3.org/typo3/CI/cms/-/pipelines/17830

  23. Oliver Klee voted on patch set 6 CR +1 10/08/21, 15:48

  24. Benni Mack voted on patch set 6 V +2 CR +2 10/08/21, 16:41

  25. Benni Mack merged patch set 7 10/08/21, 16:41