Review main Merged

95296[FEATURE] Inject PageRepository instead of creating it via makeInstance

Benni Mack CR +2 V +2 Normal +133 −46 updated 09/02/26, 07:56

Commit message

PageRepository is bound to a Context at construction time, which is why
all calls created it by hand. None of them ever went through
the container: makeInstance() only consults it when no constructor
arguments are passed, and PageRepository is a private, non-singleton
and untagged service, so has() is false for it either way. Every call
site therefore ended up in "new PageRepository()", relying on the four
"?? GeneralUtility::makeInstance(...)" fallbacks in the constructor to
locate Context, TcaSchemaFactory, PageTypeLinkResolver and the logger.

The class itself is readonly and holds no state of its own, and its
runtime cache identifiers already embed the language and workspace ids
read from the Context, so instance identity carries no meaning.
Only the Context varies per call site - in most cases just its
language aspect.

We add withContext() and withLanguageAspect() to derive an instance for
a different Context, and use them to inject PageRepository into the
consumers that are container-managed.

This removes eleven makeInstance() calls and both copies of the
"clone the global Context, set the language aspect" boilerplate.

Review

  • Code review CR +2 Done
    • Benni Mack +2
    • Georg Ringer +1
    • Simon Schaufelberger +1
  • Verified V +2 Done
    • Benni Mack +2
    • Georg Ringer +1
    • Simon Schaufelberger +1
    • core-ci +1 CI

Issues 1

Files 12

Review log 913

  1. Benni Mack uploaded patch set 1 08/12/26, 15:51

  2. Benni Mack updated the commit message in patch set 2 08/12/26, 15:52

  3. core-ci voted on patch set 1 V -1 08/12/26, 16:04 Core CI is not happy: https://git.typo3.org/typo3/CI/cms/-/pipelines/106558

  4. core-ci voted on patch set 2 V -1 08/12/26, 16:06 Core CI is not happy: https://git.typo3.org/typo3/CI/cms/-/pipelines/106559

  5. Benni Mack rebased onto patch set 3 V -1 09/01/26, 14:25

  6. core-ci voted on patch set 3 V -1 09/01/26, 14:35 Core CI is not happy: https://git.typo3.org/typo3/CI/cms/-/pipelines/107496

  7. Benni Mack uploaded patch set 4 V -1 09/01/26, 14:42

  8. Benni Mack marked it ready for review 09/01/26, 14:42

  9. core-ci voted on patch set 4 V +1 09/01/26, 14:49 Core CI is happy: https://git.typo3.org/typo3/CI/cms/-/pipelines/107500

  10. Simon Schaufelberger voted on patch set 4 CR +1 V +1 09/02/26, 06:08

  11. Georg Ringer voted on patch set 4 CR +1 V +1 09/02/26, 06:55

  12. Benni Mack voted on patch set 4 CR +2 V +2 09/02/26, 07:56

  13. Benni Mack merged patch set 5 09/02/26, 07:56