Review main Merged

94222[TASK] Make PageRepository readonly

Christian Kuhn CR +2 V +2 Normal +73 −71 updated 06/01/26, 11:12

Commit message

This follows #109716: The class can be declared readonly.

Still, we can't resolve the constructor towards proper DI:
PageRepository uses Context a lot, which is why various
consumers makeInstance(PageRepository::class, $myContext).

The issue is that some of these consumers actively hand
over a manipulated context rather than the global one.

This is the key issue with context: It was designed to
be created early and not change anymore and can thus be
injected, but in practice it *is* manipulated. The true
solution is thus to hand over context to all methods of
PageRepository that need it (essentially all of them), and
to take care no other sub-service injects global context
again. This leads to a massive refactoring. And even after
that, removing the constructor context argument and making
the other constructor arguments mandatory would be quite
breaking, forcing extensions to have switches based on
core version.

For now, we'll keep the broken DI of PageRepository:
Consumers that do not hand over context, or hand over
the global (not manipulated) context, are changed to get
PageRepository injected, those that don't, keep handing
over $context via makeInstance() to __construct() and
PageRepository will manually continue creating missing
dependencies in __construct body.

It might be easier to create a new class as substitution
of PageRepository mid-term. This would allow us to migrate
methods in a clean way with better signatures, having
potentially better performance and getting rid of the
"magic" keys PageRepository adds to database row arrays.
PageRepository could then ultimately be deprecated and
dissolved, without core having massive b/w compat trouble.

Review

  • Code review CR +2 Done
    • Christian Kuhn +2
    • Oliver Klee +1
    • Stefan Bürk +1
    • Josua Vogel +1
  • Verified V +2 Done
    • Christian Kuhn +2
    • Oliver Klee +1
    • Stefan Bürk +1
    • Josua Vogel +1
    • core-ci +1 CI

Issues 2

Files 16

Review log 1419

  1. Christian Kuhn uploaded patch set 1 05/30/26, 17:17

  2. core-ci voted on patch set 1 V +1 05/30/26, 17:25 Core CI is happy: https://git.typo3.org/typo3/CI/cms/-/pipelines/102690

  3. Christian Kuhn uploaded patch set 2 V +1 05/30/26, 21:13

  4. Christian Kuhn uploaded patch set 3 05/30/26, 21:21

  5. core-ci voted on patch set 2 V -1 05/30/26, 21:27 Core CI is not happy: https://git.typo3.org/typo3/CI/cms/-/pipelines/102696

  6. core-ci voted on patch set 3 V -1 05/30/26, 21:33 Core CI is not happy: https://git.typo3.org/typo3/CI/cms/-/pipelines/102697

  7. Christian Kuhn uploaded patch set 4 V -1 05/30/26, 21:59

  8. core-ci voted on patch set 4 V +1 05/30/26, 22:07 Core CI is happy: https://git.typo3.org/typo3/CI/cms/-/pipelines/102699

  9. Oliver Klee commented on patch set 4 CR +1 V +1 05/31/26, 09:05

    Added some comments, none of them blocking.

    Typo3DbQueryParserTest.php:607

    Hit this snag on reading: Shouldn't this also be `$context` instead of a new instance? (Not that it would have any effect on the test.)

    DatabaseRecordLinkBuilderTest.php:157

    Note: This (and many other things) probably should be a stub, not a mock. But that's a topic for another change.

    SearchControllerTest.php:93

    Should we directly make this a stub (for following best practices) or keep it a mock for now (for consistency)?

    RedirectServiceTest.php:100

    Ditto (mock vs. stub)
  10. Stefan Bürk voted on patch set 4 CR +1 V +1 05/31/26, 10:53

  11. Josua Vogel voted on patch set 4 CR +1 V +1 05/31/26, 15:00

  12. Christian Kuhn commented on patch set 4 06/01/26, 10:57

    Typo3DbQueryParserTest.php:607 Reply

    Done

    DatabaseRecordLinkBuilderTest.php:157 Reply

    yes. i took care of that in fluid standalone already. i think the way to go with this is to have a series of dedicated changes when php version and thus phpunit version for v15 are sorted out. i'll not start working on this as drive-by changes right now.

    SearchControllerTest.php:93 Reply

    keep for now. switching to stubs should be done in a dedicated effort when we're ready to do this.

    RedirectServiceTest.php:100 Reply

    Done
  13. Christian Kuhn uploaded patch set 5 CR +1 V +1 06/01/26, 10:58

  14. core-ci voted on patch set 5 V +1 06/01/26, 11:05 Core CI is happy: https://git.typo3.org/typo3/CI/cms/-/pipelines/102755

  15. Stefan Bürk voted on patch set 5 CR +1 V +1 06/01/26, 11:06

  16. Oliver Klee voted on patch set 5 CR +1 V +1 06/01/26, 11:06

  17. Josua Vogel voted on patch set 5 CR +1 V +1 06/01/26, 11:10

  18. Christian Kuhn voted on patch set 5 CR +2 V +2 06/01/26, 11:12

  19. Christian Kuhn merged patch set 6 06/01/26, 11:12