Review main Merged

87784[BUGFIX] Allow extbase persistence layer without ServerRequest

Alexander Schnitzler CR +2 V +2 Normal +143 −52 updated 01/29/25, 16:35

Commit message

Extbase in general has a rather hard dependency to PSR-7 Request,
in particular through the ConfigurationManager. This is usually
initialized in extbase bootstrap when extbase runs as a standard
content element in FE, and similar when run as BE module.

This has been hardened in v12 and v13, making clear that key code
like controller action handling and views can not run without
a Request being set.

Some other parts - namely the persistence layer - however reduced
its dependency to Request (and TypoScript) at the same time: The
dependency to TypoScript has been removed in the model mapping
configuration and is PHP based since TYPO3 v10.

The default persistence currently only fetches the toggle whether
reference index should be updated from TypoScript configuration.
This setting however should be removed since the reference index
becomes more and more important with recent core versions and
extbase should usually *always* keep the refindex updated. The
other configuration setting used from TypoScript is "storagePid".
We probably won't get rid of this anytime soon, but we can at
least make it fallback to pid 0 for now.

The patch aims to optionally run the extbase persistence layer
without a request being set to ConfigurationManager. To be able
to use this part of Extbase in contexts without a fully bootstrapped
configuration manager, try..catch blocks have been introduced which
catch a newly introduced `NoServerRequestGivenException`.

Sane fallback values are then used:
* Reference index will always be updated
* Storage page id will be 0

The reference index behavior is not configurable otherwise but
the storage page can be overridden during writes by setting the
`$pid` property of the respective entity.

During reads, users can explicitly override the query settings
and define custom storage page ids to read from or choose to
not take any storage page into consideration.

The patch implements the changes and cleans up surrounding code
slightly. The ConfigurationManager now throws a specific exception
that can be caught, this was a \RuntimeException before. Catching
global exceptions is bad practice, `NoServerRequestGivenException`
extends basic `Extbase\Exception` in v14, not `\RuntimeException`,
which is not considered breaking. The v13 version of the patch
will extend `\RuntimeException` though, to not break any existing
v13 instance that may currently catch `\RuntimeException`.

Review

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

Issues 1

Files 7

Review log 2934

Show 79 earlier messages
  1. Alexander Schnitzler uploaded patch set 1 01/16/25, 18:47

  2. Alexander Schnitzler wrote 01/16/25, 18:49

    Topic set to extbase
  3. Alexander Schnitzler commented on patch set 1 01/16/25, 18:51

    @lolli@schwarzbu.ch I think that's really it. Didn't find any other places which should fail gracefully. If you found anything else, please let me know.
  4. core-ci voted on patch set 1 V -1 01/16/25, 18:53 Core CI is not happy: https://git.typo3.org/typo3/CI/cms/-/pipelines/72574

  5. Oliver Klee commented on patch set 1 01/16/25, 20:17

    NoServerRequestGivenException.php:20

    Maybe make it final and readonly?
  6. Alexander Schnitzler uploaded patch set 2 V -1 01/17/25, 06:48

  7. Alexander Schnitzler commented on patch set 2 01/17/25, 06:49

    NoServerRequestGivenException.php:20 Reply

    readonly isn't possible due to its parent class. But it's final now.
  8. core-ci voted on patch set 2 V -1 01/17/25, 06:54 Core CI is not happy: https://git.typo3.org/typo3/CI/cms/-/pipelines/72595

  9. Andreas Kienast commented on patch set 2 01/17/25, 07:03

    ConfigurationManager.php:81

    `Exception\` is superfluous as the exception class is imported anyway. That's also why the CGL check fails.
  1. Alexander Schnitzler uploaded patch set 3 V -1 01/17/25, 07:06

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

  3. Oliver Klee voted on patch set 3 CR +1 01/17/25, 09:08

  4. Oliver Klee updated the commit message in patch set 4 CR +1 V +1 01/17/25, 09:34

  5. Oliver Klee voted on patch set 4 CR +1 01/17/25, 09:34

  6. core-ci voted on patch set 4 V +1 01/17/25, 09:42 Core CI is happy: https://git.typo3.org/typo3/CI/cms/-/pipelines/72608

  7. Alexander Schnitzler commented on patch set 4 01/17/25, 10:17

    ConfigurationManager.php:81 Reply

    Done
  8. Garvin Hicking commented on patch set 4 01/17/25, 15:26

    Backend.php:873

    Should we maybe create a central method like 'setupDefaultFrameworkConfiguration' that returns a stub config here? That would make changes to the default maybe more streamlined in the future. And we could set both indices (storagePid+updateReferenceIndex) at one central place? (I wonder if those defaults should maybe even be retrieved via a system.php config default array....?)
  9. Alexander Schnitzler commented on patch set 4 01/17/25, 17:25

    Backend.php:873 Reply

    Christian and me actually did have other plans here, namely to remove both configuration values alltogether in the future. The reference index should always be updated and the storage pid should be actively maintained by the users.
  10. Garvin Hicking commented on patch set 4 01/17/25, 20:10

    Backend.php:873 Reply

    Ack. I'd say having a central method for that and deprecating it later would make it easier to find them again, but I fully trust in your decission, so resolving this comment. Thanks for working on it, every work on extbase makes me happy :-)
  11. Alexander Schnitzler commented on patch set 4 01/23/25, 09:41

    Just found another place where the new behaviour is problematic. I run a very big site with an API, which is independent from 99% of the core, so it's placed very early in the middleware stack. This is not longer possible with an Extbase persistence depending on a fully bootstrapped frontend with TypoScript and all. It's just another example where people run into issues upgrading to 13.4, when things ran smoothly up until 12.4. I know a lot of projects that run an API that early. It seems like an edge case for all those who use TYPO3 purely as CMS, but those that use it as a framework might experience this issue.
  12. Christian Kuhn commented on patch set 4 01/28/25, 16:45

    Reply

    i disagree with this assessment.
  13. Christian Kuhn commented on patch set 4 01/28/25, 16:55

    Reply

    I added a note to the issue on why I disagree with this.
  14. Christian Kuhn commented on patch set 4 01/29/25, 13:31

    i think we should go with the patch, but i'd like to rephrase the commit message a bit. i hope its ok to push an adapted version.
  15. Garvin Hicking voted on patch set 4 CR +1 01/29/25, 14:58

  16. Christian Kuhn uploaded patch set 5 CR +1 V +1 01/29/25, 15:44

  17. Christian Kuhn commented on patch set 5 01/29/25, 15:50

    note the v13 backport should be slightly different, i'll take care if the main version is upvoted.
  18. core-ci voted on patch set 5 V +1 01/29/25, 15:50 Core CI is happy: https://git.typo3.org/typo3/CI/cms/-/pipelines/73145

  19. Christian Kuhn commented on patch set 5 CR +1 V +1 01/29/25, 15:58

    please keep merge & backport with me.
  20. Benni Mack commented on patch set 5 CR +1 V +1 01/29/25, 16:01

    please go ahead @lolli@schwarzbu.ch
  21. Garvin Hicking commented on patch set 5 CR +1 V +1 01/29/25, 16:08

    Thank you!
  22. Oliver Klee voted on patch set 5 CR +1 01/29/25, 16:09

  23. Christian Kuhn voted on patch set 5 CR +2 V +2 01/29/25, 16:34

  24. Christian Kuhn merged patch set 6 01/29/25, 16:34

  25. Christian Kuhn commented on patch set 6 01/29/25, 16:35

    Reply

    Done