Review main Merged

79519[BUGFIX] Avoid circular reference of COR and ServerRequest

Helmut Hummel CR +2 V +2 Normal +36 −31 updated 08/02/23, 14:31

Commit message

While the initial idea to store the current ContentObjectRender
(cObj) instance in a request attribute, to pass it along to code
that requires both, the request and a cObj, is solid, we missed
that cObj itself does not require to hold the request as attribute.

The patch changes this: The request attribute is only set
for ContentObjects, as these are actually responsible for
rendering and eventually evaluating a request or the cObj
instance.

This makes sure, that an instance of cObj is available for
Extbase plugins as well as for Fluid view helpers, which can
access the request via RenderingContext.

By changing the concept slightly, all places that previously added
the cObj to the request can be removed in favor of doing so only
in AbstractContentObject and ContentObjectRenderer::callUserFunction.
The latter is at least required for TypoScript using the old way of
calling Extbase plugins with USER and it's userFunc property.

The circular reference is now removed, by not passing the request
that contains the cObj attribute to the cObj itself. This means:

* When a cObj is available, one can obtain the request using its getter
* Such request objects, do NOT contain an attribute containing the cObj
* The cObj request attribute can now be obtained in all content objects
  (such as EXTBASEPLUGIN or FLUIDTEMPLATE) and user functions, that are
  called from be ContentObjectRenderer.

Review

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

Issues 3

Files 9

Review log 1827

Show 12 earlier messages
  1. Helmut Hummel uploaded patch set 1 06/27/23, 11:04

  2. core-ci voted on patch set 1 V -1 06/27/23, 11:15 Core CI is not happy: https://git.typo3.org/typo3/CI/cms/-/pipelines/43021

  1. Helmut Hummel uploaded patch set 2 V -1 06/27/23, 11:38

  2. core-ci voted on patch set 2 V +1 06/27/23, 11:46 Core CI is happy: https://git.typo3.org/typo3/CI/cms/-/pipelines/43024

  3. Helmut Hummel marked it work in progress 06/27/23, 12:13

  4. Helmut Hummel uploaded patch set 3 V +1 06/30/23, 17:10

  5. core-ci voted on patch set 3 V -1 06/30/23, 17:17 Core CI is not happy: https://git.typo3.org/typo3/CI/cms/-/pipelines/43158

  6. Helmut Hummel uploaded patch set 4 V -1 06/30/23, 17:41

  7. core-ci voted on patch set 4 V +1 06/30/23, 17:55 Core CI is happy: https://git.typo3.org/typo3/CI/cms/-/pipelines/43161

  8. Helmut Hummel uploaded patch set 5 V +1 07/01/23, 10:20

  9. core-ci voted on patch set 5 V +1 07/01/23, 10:28 Core CI is happy: https://git.typo3.org/typo3/CI/cms/-/pipelines/43181

  10. Helmut Hummel rebased onto patch set 6 V +1 07/06/23, 12:45

  11. core-ci voted on patch set 6 V +1 07/06/23, 13:08 Core CI is happy: https://git.typo3.org/typo3/CI/cms/-/pipelines/43732

  12. Helmut Hummel marked it ready for review 07/31/23, 17:06

  13. Benni Mack voted on patch set 6 CR +1 08/01/23, 11:10

  14. Christian Kuhn commented on patch set 6 CR -1 08/02/23, 09:02

    looking at it.
  15. Benjamin Franzke commented on patch set 6 08/02/23, 10:48

    In order to fix this issue this sounds good to me and valid in general, but… I just want to make one additional statement (that does for sure not block this bugfix at all, but speaks about v13). `currentContentObject` is *not* a proper request attriubute at all. All request attributes *should* be data that is derived *from* the request or represent data that belongs to the entirety of the request - no temporary data/rendering context. (And yes, I know, request is immutable and we at least do not mess with previous state/objects by using withAttribute, but I still feel like this is wrong…) The patch https://review.typo3.org/c/Packages/TYPO3.CMS/+/77252 that added this used following justification > However, ConfigurationManager is also abused to > "park" the current ContentObjectRenderer instance …but now it is actually "parked" in the request object, which isn't any better. This is really something that needs to be tied *only* to the rendering context of a plugin – which would be RenderingContext speaking of extbase. So far I wanted to drop this, maybe to make clear: If you see any chance for (maybe even for v12) to decouple them in more placed, then that'd be great in order to maybe get rid of currentContentObject again. Thanks.

    Bootstrap.php:95

    Why is the condition swapped? We've got a proper type declaration and checking for null is perfectly fine in that case. (!instanceof is rather overhead here)
  16. Christian Kuhn uploaded patch set 7 CR +1 V +1 08/02/23, 10:55

  17. Christian Kuhn commented on patch set 7 08/02/23, 10:58

    Reply

    yeah, we're abusing it here for now. the changes however also allow us further cleanups. i think we'll continue here, refactor further, then look at it again.

    Bootstrap.php:95 Reply

    Done
  18. Christian Kuhn uploaded patch set 8 08/02/23, 10:59

  19. core-ci voted on patch set 7 V +1 08/02/23, 11:08 Core CI is happy: https://git.typo3.org/typo3/CI/cms/-/pipelines/44873

  20. core-ci voted on patch set 8 V +1 08/02/23, 11:10 Core CI is happy: https://git.typo3.org/typo3/CI/cms/-/pipelines/44875

  21. Oliver Klee updated the commit message in patch set 9 V +1 08/02/23, 11:31

  22. core-ci voted on patch set 9 V +1 08/02/23, 11:42 Core CI is happy: https://git.typo3.org/typo3/CI/cms/-/pipelines/44878

  23. Christian Kuhn voted on patch set 9 V +1 CR +1 08/02/23, 14:31

  24. Benni Mack voted on patch set 9 V +2 CR +2 08/02/23, 14:31

  25. Benni Mack merged patch set 10 08/02/23, 14:31