Review main Merged

71477[BUGFIX] Avoid $GLOBALS['TYPO3_REQUEST'] warning in Clipboard

Christian Kuhn CR +2 V +2 Easy +11 −1 updated 10/07/21, 12:32

Commit message

Functional test ext:felogin
ContentVisibleFieldsTest::loginFormContainsExpectedFields
indirectly calls $GLOBALS['TYPO3_REQUEST'] of
Clipboard::initializeClipboard().

Clipboard class does multiple things: It is a 'repository'
to find out which items are in the clipboard, and it helps
with rendering. The 'repository' part does not need $request.

Functional tests call initializeClipboard() without handing
over a request object and without preparing a request
as $GLOBALS['TYPO3_REQUEST']. While they could actively
init a request, they shouldn't need to do so.

The patch adds a fallback so clipboard class does not emit
a warning if neither $request is given nor $GLOBALS['TYPO3_REQUEST']
is set.

An according @todo is added to further streamline the code.

Review

  • Code review CR +2 Done
    • Benjamin Franzke +2
    • Stefan Bürk +1
  • Verified V +2 Done
    • Benjamin Franzke +2
    • Stefan Bürk +1
    • core-ci +1 CI

Issues 1

Files 1

Review log 1922

  1. Christian Kuhn uploaded patch set 1 10/06/21, 21:34

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

  3. core-ci voted on patch set 1 V +1 10/06/21, 21:47 Core CI is happy: https://gitlab.typo3.org/typo3/CI/cms/-/pipelines/17704

  4. Christian Kuhn commented on patch set 1 CR -1 10/06/21, 21:55

    not 100% sure on this one. will re-visit, soon.
  5. Stefan Bürk commented on patch set 1 10/06/21, 22:05

    Reply

    ack.
  6. Christian Kuhn commented on patch set 1 CR 0 10/07/21, 10:49

    I'd actually go with this for now: $this->request is used in some set() and get() methods, which are only called when clipboard is actively used. Having $this->request null as fallback will kill these calls, but that can't happen when clipboard is actively used in BE scope. I try to fix an init() issue here, when clipboard is only instantiated as dependency, but not actively used. The todo note already says this needs another change, so imho that's fine for now.
  7. Oli Bartsch commented on patch set 1 10/07/21, 10:51

    Clipboard.php:818

    Could we add a guard clause here to early return with an empty string, in case $request is NULL?
  8. Christian Kuhn uploaded patch set 2 10/07/21, 11:07

  9. Christian Kuhn commented on patch set 2 10/07/21, 11:07

    Clipboard.php:818 Reply

    Done
  10. Oliver Klee voted on patch set 2 CR +1 10/07/21, 11:18

  11. core-ci voted on patch set 2 V +1 10/07/21, 11:24 Core CI is happy: https://gitlab.typo3.org/typo3/CI/cms/-/pipelines/17729

  12. Stefan Bürk commented on patch set 2 CR +1 10/07/21, 11:31

    Clipboard.php:818 Reply

    Had the same in mind for my ack on your -1. Ack to throw that RuntimeException instead of returning an empty string here.
  13. Oli Bartsch voted on patch set 2 V +1 CR +1 10/07/21, 11:35

  14. Stefan Bürk voted on patch set 2 V +1 10/07/21, 11:35

  15. Benjamin Franzke commented on patch set 2 CR -1 10/07/21, 11:40

    Hey, can we have an example where this fails in CLI? Is that with user specific commands that use DataHandler, or how can that be triggered?
  16. Christian Kuhn commented on patch set 2 10/07/21, 11:42

    Reply

    my use case came from testing, not from cli. i'm just assuming this may add trouble on cli.
  17. Christian Kuhn uploaded patch set 3 10/07/21, 12:13

  18. Benjamin Franzke voted on patch set 3 V +1 CR +1 10/07/21, 12:15

  19. Stefan Bürk voted on patch set 3 V +1 CR +1 10/07/21, 12:24

  20. core-ci voted on patch set 3 V +1 10/07/21, 12:30 Core CI is happy: https://gitlab.typo3.org/typo3/CI/cms/-/pipelines/17735

  21. Benjamin Franzke voted on patch set 3 V +2 CR +2 10/07/21, 12:32

  22. Benjamin Franzke merged patch set 4 10/07/21, 12:32