Review main Merged

77252[TASK] Provide current content object as request attribute

Helmut Hummel CR +2 V +2 Normal +101 −90 updated 07/25/24, 10:17

Commit message

Extbase ConfigurationManager as stateful singleton
object is updated within extbase bootstrap for
each plugin call. This is ugly, but since
ConfigurationManager can be injected to other
extbase services, which can be injected itself,
it is very hard to get rid of.

However, ConfigurationManager is also abused to
"park" the current ContentObjectRenderer instance
in this "convenient" singleton. The current
content object renderer instance can then be retrieved
at extbase runtime using getContentObject().

The form extension uses this at a couple of places
to move the ContentObjectRenderer data around. The
ConfigurationManager should however not be a source
of such data, and our main "state" object in the
framework is the request (which ConfigurationManager
needs as well, but that's a different patch).

To allow a deprecation of getContentObject() in
ConfigurationManager, the patch changes the codebase
to attach the current content object as request attribute
instead. This is a bit fiddly as well since
ContentObjectRenderer can be recursive (cObj rendering other
cObj again), but the change at least makes this state more
obvious, and we're pretty confident the situation will
further relax and become more transparent with continued
ContentObjectRenderer refactorings. Some of these
have been prepared in v12 already and we'll see
more on this with v13.

The patch does the main refactoring, deprecating
getContentObject() will follow with another patch.
The patch does not add the attribute at all places
where ContentObjectRenderer instances are created,
more may follow later. The main goal of this patch
is to create the main infrastructure and to not break
the form extension.

Review

  • Code review CR +2 Done
    • Christian Kuhn +2
    • Stefan Bürk +1
    • Benni Mack +1
  • Verified V +2 Done
    • Christian Kuhn +2
    • Stefan Bürk +1
    • Benni Mack +1
    • core-ci +1 CI

Issues 1

Files 18

Review log 4059

Show 2034 earlier messages
  1. Helmut Hummel uploaded patch set 1 01/03/23, 17:03

  2. core-ci voted on patch set 1 V -1 01/03/23, 17:17 Core CI is not happy: https://git.typo3.org/typo3/CI/cms/-/pipelines/35445

  3. Oliver Klee commented on patch set 1 01/07/23, 09:08

    Typo: obsolte -> obsolete
  4. Christian Kuhn rebased onto patch set 2 V -1 04/16/23, 18:38

  5. Christian Kuhn updated the commit message in patch set 3 04/16/23, 18:40

  6. Christian Kuhn commented on patch set 2 04/16/23, 18:40

    Reply

    Done
  7. core-ci voted on patch set 2 V -1 04/16/23, 19:47 Core CI is not happy: https://git.typo3.org/typo3/CI/cms/-/pipelines/40762

  8. core-ci voted on patch set 3 V -1 04/16/23, 19:47 Core CI is not happy: https://git.typo3.org/typo3/CI/cms/-/pipelines/40763

  9. Benni Mack commented on patch set 3 04/17/23, 07:20

    GifBuilder.php:120

    this is not necessary, I think
  10. Christian Kuhn commented on patch set 3 04/17/23, 09:15

    ContentObjectRenderer.php:485

    this is correct: we're setting the attribute whenever the request is hand over, so in setRequest(), too. it's ok to not do this in getRequest() to not do it more often than needed. however, we might want to get rid of the 3rd argument here, and force using setRequest() before start() instead, since that's more easy and avoids the overlap with setRequest(). i'll add an according @todo.
  11. Christian Kuhn uploaded patch set 4 V -1 04/17/23, 09:58

  12. Christian Kuhn uploaded patch set 5 04/17/23, 10:09

  13. Christian Kuhn uploaded patch set 6 04/17/23, 10:14

  14. core-ci voted on patch set 5 V -1 04/17/23, 10:21 Core CI is not happy: https://git.typo3.org/typo3/CI/cms/-/pipelines/40794

  15. core-ci voted on patch set 6 V -1 04/17/23, 10:32 Core CI is not happy: https://git.typo3.org/typo3/CI/cms/-/pipelines/40795

  16. Christian Kuhn uploaded patch set 7 V -1 04/17/23, 10:53

  17. Christian Kuhn uploaded patch set 8 04/17/23, 11:03

  18. core-ci voted on patch set 7 V -1 04/17/23, 11:09 Core CI is not happy: https://git.typo3.org/typo3/CI/cms/-/pipelines/40796

  19. core-ci voted on patch set 8 V -1 04/17/23, 11:16 Core CI is not happy: https://git.typo3.org/typo3/CI/cms/-/pipelines/40797

  20. core-ci voted on patch set 4 V -1 04/17/23, 11:24 Core CI is not happy: https://git.typo3.org/typo3/CI/cms/-/pipelines/40793

  21. Christian Kuhn uploaded patch set 9 V -1 04/17/23, 12:13

  22. Christian Kuhn uploaded patch set 10 04/17/23, 12:20

  23. core-ci voted on patch set 9 V -1 04/17/23, 12:25 Core CI is not happy: https://git.typo3.org/typo3/CI/cms/-/pipelines/40800

  24. core-ci voted on patch set 10 V +1 04/17/23, 12:27 Core CI is happy: https://git.typo3.org/typo3/CI/cms/-/pipelines/40801

  25. Christian Kuhn commented on patch set 10 04/17/23, 15:04

    ContentObjectRenderer.php:421

    i will change this approach: adding the attribute within setRequest() forces us to have getRequest() public, so creators can fetch the new request object again. it will be better if a creator adds the attribute itself (and thus has the new request), and then calls setRequest(). this will allow us to make getRequest() protected later, which is the way to go, since COR should be a data sink and not a provider. with v13, we should strive for having in COR-factory, which takes care of that - this is currently problematic since there are too many places that don't have the request at hand, so this needs further streamlining in v13 to not introduce an ugly factory right now.
  26. Christian Kuhn uploaded patch set 11 V +1 04/17/23, 16:00

  27. core-ci voted on patch set 11 V -1 04/17/23, 16:27 Core CI is not happy: https://git.typo3.org/typo3/CI/cms/-/pipelines/40817

  28. Christian Kuhn uploaded patch set 12 V -1 04/18/23, 09:08

  29. Christian Kuhn commented on patch set 11 04/18/23, 09:08

    GifBuilder.php:120 Reply

    unsure. removed it for now.
  30. Christian Kuhn uploaded patch set 13 04/18/23, 09:17

  31. core-ci voted on patch set 12 V -1 04/18/23, 09:25 Core CI is not happy: https://git.typo3.org/typo3/CI/cms/-/pipelines/40857

  32. Christian Kuhn uploaded patch set 14 04/18/23, 10:03

  33. core-ci voted on patch set 13 V -1 04/18/23, 10:11 Core CI is not happy: https://git.typo3.org/typo3/CI/cms/-/pipelines/40858

  34. core-ci voted on patch set 14 V +1 04/18/23, 10:12 Core CI is happy: https://git.typo3.org/typo3/CI/cms/-/pipelines/40861

  1. Christian Kuhn updated the commit message in patch set 15 V +1 04/18/23, 10:33

  2. Christian Kuhn uploaded patch set 16 04/18/23, 10:37

  3. core-ci voted on patch set 15 V +1 04/18/23, 10:41 Core CI is happy: https://git.typo3.org/typo3/CI/cms/-/pipelines/40862

  4. core-ci voted on patch set 16 V +1 04/18/23, 10:45 Core CI is happy: https://git.typo3.org/typo3/CI/cms/-/pipelines/40863

  5. Christian Kuhn uploaded patch set 17 V +1 04/18/23, 10:46

  6. Christian Kuhn updated the commit message in patch set 18 04/18/23, 10:50

  7. core-ci voted on patch set 17 V +1 04/18/23, 10:53 Core CI is happy: https://git.typo3.org/typo3/CI/cms/-/pipelines/40864

  8. core-ci voted on patch set 18 V +1 04/18/23, 10:58 Core CI is happy: https://git.typo3.org/typo3/CI/cms/-/pipelines/40865

  9. Oli Bartsch commented on patch set 18 04/18/23, 11:20

    Bootstrap.php:112

    Shouldn't this always be set - Not only in case $this->cObj is NULL?
  10. Christian Kuhn commented on patch set 18 04/18/23, 11:42

    Bootstrap.php:112 Reply

    I think no, at least for now: Ihis case is mainly BE usage. In FE, the attribute has been attached by cObj VH or by TSFE already. I'd only extend this if really needed and I currently see no sign we do, but I may be wrong. If it turns out to be important, I'd check getAttribute() so see if it returns null, and only then attach it. And then trigger_error() the case "cObj NOT null, but no attribute given". Unsure if we should really do this already, so I'd tend to not. What do you think?
  11. Stefan Bürk commented on patch set 18 04/18/23, 12:47

    UriBuilder.php:177

    Would the `currentContentObject` attribute not be missing, if we run into this fallback ? Sure, extbase request should be set properly before hand ....
  12. Christian Kuhn commented on patch set 18 04/18/23, 13:14

    Bootstrap.php:112 Reply

    Ack

    UriBuilder.php:177 Reply

    Yeah. We don't have the cObj at this point, though. ext:form gets this right, though (i hope). getContentObject() on ConfigurationManager will be deprecated and not deleted. So when not setting the request here, one should also continue to use getContentObject(), and fetching the cObj from ConfigurationManager should be a rather seldom case in the first place.
  13. Stefan Bürk commented on patch set 18 04/18/23, 13:16

    UriBuilder.php:177 Reply

    Ack. Just thought about the same.
  14. Christian Kuhn commented on patch set 18 04/18/23, 13:16

    note the goal of this patch is not to have the 'currentContentObject' *everywhere*. Current target is getting rid of getContentObject() from ConfigurationManager. We'll later see if and where this may be further needed.
  15. Stefan Bürk voted on patch set 18 V +1 CR +1 04/18/23, 13:21

  16. Stefan Bürk voted on patch set 18 V 0 CR 0 04/18/23, 13:21

  17. Christian Kuhn uploaded patch set 19 V +1 04/18/23, 13:23

  18. Stefan Bürk voted on patch set 19 V +1 CR +1 04/18/23, 13:25

  19. core-ci voted on patch set 19 V +1 04/18/23, 13:30 Core CI is happy: https://git.typo3.org/typo3/CI/cms/-/pipelines/40875

  20. Benni Mack voted on patch set 19 V +1 CR +1 04/18/23, 14:16

  21. Christian Kuhn voted on patch set 19 V +1 CR +1 04/18/23, 14:19

  22. Christian Kuhn voted on patch set 19 V +2 CR +2 04/18/23, 14:19

  23. Christian Kuhn merged patch set 20 04/18/23, 14:20

  24. Markus Klein commented on patch set 20 07/23/24, 13:56

    ConfirmationFinisher.php:103

    This causes a regression, see: https://forge.typo3.org/issues/104462
  25. Christian Kuhn commented on patch set 20 07/25/24, 10:17

    ConfirmationFinisher.php:103 Reply

    Done