Review main Merged

90969[TASK] Make some FAL related services more harmless

Christian Kuhn CR +2 V +2 Hard +196 −182 updated 10/14/25, 10:00

Commit message

With patch #107611 some more FAL related services can be
easily made stateless and readonly: MetaDataRepository
and ProcessedFileRepository. While FAL is still under
construction in this regard, the patch applies the
casual cycle for these two services:

* Inline last properties that have been de-facto
  constants.
* Use more DI in the services, declare them readonly,
  avoid LoggerAwareTrait since it prevents services
  from being readonly.
* Avoid SingletonInterface since it is pointless with
  services being shared by default.
* Declare more types on service methods and clean up
  consumers.
* Adapt unit tests accordingly and clean up.
* Inject the now stateless services in consumers more
  often in favor of GU::makeInstance().

Review

  • Code review CR +2 Done
    • Benjamin Franzke +2
    • Anja Leichsenring +1
    • Stefan Bürk +1
  • Verified V +2 Done
    • Benjamin Franzke +2
    • Anja Leichsenring +1
    • Stefan Bürk +1
    • core-ci +1 CI

Issues 2

Files 9

Review log 2435

Show 510 earlier messages
  1. Christian Kuhn uploaded patch set 1 10/09/25, 11:18

  2. Christian Kuhn uploaded patch set 2 10/09/25, 11:26

  3. core-ci voted on patch set 1 V -1 10/09/25, 11:32 Core CI is not happy: https://git.typo3.org/typo3/CI/cms/-/pipelines/86291

  4. core-ci voted on patch set 2 V -1 10/09/25, 11:33 Core CI is not happy: https://git.typo3.org/typo3/CI/cms/-/pipelines/86292

  5. Christian Kuhn uploaded patch set 3 V -1 10/09/25, 11:50

  6. core-ci voted on patch set 3 V -1 10/09/25, 11:57 Core CI is not happy: https://git.typo3.org/typo3/CI/cms/-/pipelines/86293

  7. Christian Kuhn uploaded patch set 4 V -1 10/09/25, 11:58

  8. core-ci voted on patch set 4 V +1 10/09/25, 12:05 Core CI is happy: https://git.typo3.org/typo3/CI/cms/-/pipelines/86294

  9. Christian Kuhn uploaded patch set 5 V +1 10/09/25, 12:27

  10. core-ci voted on patch set 5 V +1 10/09/25, 12:34 Core CI is happy: https://git.typo3.org/typo3/CI/cms/-/pipelines/86296

  1. Christian Kuhn updated the commit message in patch set 6 V +1 10/09/25, 12:38

  2. Christian Kuhn updated the commit message in patch set 7 10/09/25, 12:38

  3. Christian Kuhn updated the commit message in patch set 8 10/09/25, 12:39

  4. Christian Kuhn updated the commit message in patch set 9 10/09/25, 12:42

  5. core-ci voted on patch set 6 V +1 10/09/25, 12:48 Core CI is happy: https://git.typo3.org/typo3/CI/cms/-/pipelines/86297

  6. core-ci voted on patch set 7 V +1 10/09/25, 12:50 Core CI is happy: https://git.typo3.org/typo3/CI/cms/-/pipelines/86298

  7. core-ci voted on patch set 8 V +1 10/09/25, 12:53 Core CI is happy: https://git.typo3.org/typo3/CI/cms/-/pipelines/86299

  8. Benjamin Franzke commented on patch set 9 10/09/25, 12:57

    > Avoid SingletonInterface since it is pointless with services being shared by default. I'm not against this change, but we need to look out for incompatibilities here when using this argumentation (in other patches). `SingletonInterface` implies shared (default) *AND* `public` (non default). That means removing the SingletonInterface usually(*) removes the `public` flag if not specified explicitly and prevents existing users from using `GeneralUtility::makeInstance(WhateverRepository::class)`, so we always need to think about adding `#[Autoconfigure(public: true)]` if we see the need to preserve service location via `GU::makeInstance()`. Now, all of this said you might say > well `GeneralUtility::makeInstance(MetaDataRepository::class)` still works, what's your problem? Right, this case is edgy. The services that are changed here are defined in service providers (which is basically a TYPO3 DI configuration flavor) which makes them public by default.. So yes, `SingeltonInterface` was redundant/no longer needed, but not because services are shared by default, but because these services are defines in service providers. I hope this doesn't feel like a lecture, but rather an explanation of the complicated entanglements of our mixture of `Services.yaml`/`Services.php`/`ServiceProvider.php` and `SingletonInterface`.
  9. core-ci voted on patch set 9 V +1 10/09/25, 12:58 Core CI is happy: https://git.typo3.org/typo3/CI/cms/-/pipelines/86301

  10. Benjamin Franzke updated the commit message in patch set 10 V +1 10/09/25, 12:59

  11. Benjamin Franzke commented on patch set 10 10/09/25, 12:59

    Reply

    Rephrased that bullet point.
  12. Christian Kuhn uploaded patch set 11 10/09/25, 13:01

  13. Benjamin Franzke commented on patch set 10 10/09/25, 13:02

    ServiceProvider.php:513

    BTW, my plan is to remove these FAL services from service providers at some point in order to be able to use full Symfony DI feature set here, because I figure it's annoying that we have to maintain so many services manually in here. But that requires some overhaul of the installtool to avoid implicit FAL usage in Fluid context. Work on that started in this relation chain: > 90794: [TASK] Remove main application services from failsafe container | https://review.typo3.org/c/Packages/TYPO3.CMS/+/90794
  14. Christian Kuhn commented on patch set 11 10/09/25, 13:04

    Reply

    true. thx. i just realized that as well when re-reading the change. i added public:true to the two services. reason: core still uses makeInstance() for each service once. in general, we should mid-term reduce public:true, imho we can do this when core always injects a service and does not use makeInstance() anymore, but that also depends on the impact of the service is question. in this specific case public:true is still needed anyway.
  15. core-ci voted on patch set 10 V +1 10/09/25, 13:09 Core CI is happy: https://git.typo3.org/typo3/CI/cms/-/pipelines/86303

  16. core-ci voted on patch set 11 V +1 10/09/25, 13:10 Core CI is happy: https://git.typo3.org/typo3/CI/cms/-/pipelines/86304

  17. Anja Leichsenring voted on patch set 11 CR +1 V +1 10/09/25, 13:32

  18. Stefan Bürk voted on patch set 11 CR +1 V +1 10/09/25, 14:54

  19. Christian Kuhn commented on patch set 11 10/09/25, 15:08

    Reply

    my changed worked because serviceProvider entries made them public. i wasn't aware of that. thx! so declaring public:true in the attribute is now redundant. i hope it is still good/ok to have that attribute explicitly attached for now.
  20. Benjamin Franzke commented on patch set 11 CR +2 V +2 10/10/25, 06:24

    Reply

    yup, I think that's good, given the plan to remove them from servie providers.
  21. Benjamin Franzke merged patch set 12 10/10/25, 06:24

  22. Simon Schaufelberger commented on patch set 12 10/10/25, 09:29

    MetaDataRepository.php:46

    Since this class isn't internal, i would expect all these to be protected in case someone needs to xclass the class and then can't use these classes. This would also mean a breaking change.

    ProcessedFileRepository.php:40

    same here
  23. Christian Kuhn commented on patch set 12 10/10/25, 19:03

    MetaDataRepository.php:46 Reply

    i don't get your point at all. how to xclass an interface? "breakng" xclasses is not breaking anyways. xclassing connection pool and context is pretty much impossible and/or not neccessary. would you like to show a specific issue, at best in a given project where this change really is an issue? your remarks sound rather theoreticaly without practictal impact?

    ProcessedFileRepository.php:40 Reply

    Done
  24. Simon Schaufelberger commented on patch set 12 10/10/25, 19:07

    MetaDataRepository.php:46 Reply

    no, you misunderstood me. When someone xclasses MetaDataRepository, then it's not possible anymore to use the event dispatcher because it's not protected. So when you are currently overwriting removeByFileUid, then your code crashes because $this->eventDispatcher is suddenly private.
  25. Christian Kuhn commented on patch set 12 10/14/25, 10:00

    MetaDataRepository.php:46 Reply

    Ok, here is a more verbose answer: xclasses are a last resort hack, devs may only use if there is absolutely no other solution. This is because they are the solution that is the furthest away from a contract, so they have the most disadvantages on all sides: both core never know when it "breaks" potential xclasses, and users often don't know when a core change broke one. An composer applied patch is more stable than an xclass since diff at least tells you when it can't be applied due to a change in the direct surroundings. If core would try to "support" xclassing with a b/w promise, 90% of the non-docs changes wouldn't be allowed since they could break an xclass. such a goal would halt nearly all development. This is why this change - that makes some things private - is *not* considered breaking: * To start with, there is *very little reason* to xclass this class: the class mainly implements straight forward queries *and* there is an event (!) in almost all of them already that allows doing things using a proper contract. * If an xclass really seeds one of the now private class property dependencies, it would inject*() it on its own. * Instead of xclassing one of the main methods of this repository, a dev could also look at the use case. Chances are a change in the consumers, an own class, event usage, or similar could be a solution as well. And that is why i asked for specific and existing example xclasses in living projects before we change a private visibility back to protected again: Chances are, there are none, and even if so, the problem most likely can and should be solved differently by the consumer. We will not cripple DI visibility based on theoretical thinking, but we could decide to be nice if true use cases pop up, so please deliver one so we can look at it. To be clear again: Making a DI property private in a "leaf" class is typically *not* considered breaking when the only reasoning is that it *may* break an xclass. We live some exceptions in cases we know that some specific classes are more often xclassed (eg i try to keep some stuff in datahandler protected over private), but those are usually due to other technical core debts, and we then bow to this in specific cases somehow. For classes like this one, this is not the case and we'd really need hard information on use cases to turn this back into protected. We shouldn't do that without reason.