Review main Abandoned Breaking

66995[!!!][TASK] Remove SingletonInterface from prototype classes

Benni Mack CR 0 V 0 Normal +107 −46 updated 12/09/20, 12:23

Commit message

Back in TYPO3 v4 / PHP5 age, the singleton interface
was added to a lot of classes to limit performance
issues, which is not needed anymore in PHP7
times.

This change removes unneeded singleton instances,
leaving Extbase Persistence, Factories and Manager
classes as is for the time being.

In addition, the mentioned classes do not carry relevant
state, and only need to be registered in DI if they
need auto-wiring (= dependencies in any kind of way)
in place. DI can also mark classes as "shared" which
is not needed in the changed classes.

Review

  • Code review CR 0
  • Verified V 0

Issues 1

Files 25

Show 5 more files

Review log 1523

  1. Benni Mack uploaded patch set 1 12/04/20, 10:21

  2. TYPO3com voted on patch set 1 V -1 12/04/20, 10:29 Completed build in 07m 55s on Fri, 4 Dec, 10:29 AM Test Summary: 3930 of 32550 failed Find logs and detail information at https://bamboo.typo3.com/browse/CORE-GTC-7776

  3. Benni Mack uploaded patch set 2 12/04/20, 12:29

  4. TYPO3com voted on patch set 2 V -1 12/04/20, 12:38 Completed build in 08m 34s on Fri, 4 Dec, 12:38 PM Test Summary: 970 of 32646 failed Find logs and detail information at https://bamboo.typo3.com/browse/CORE-GTC-7782

  5. Benni Mack uploaded patch set 3 12/04/20, 12:55

  6. TYPO3com voted on patch set 3 V +1 12/04/20, 13:04 Completed build in 08m 51s on Fri, 4 Dec, 01:04 PM Test Summary: 32405 passed Find logs and detail information at https://bamboo.typo3.com/browse/CORE-GTC-7783

  7. Benni Mack uploaded patch set 4 12/07/20, 07:50

  8. TYPO3com voted on patch set 4 V -1 12/07/20, 08:00 Completed build in 09m 48s on Mon, 7 Dec, 08:00 AM Test Summary: 31540 passed Find logs and detail information at https://bamboo.typo3.com/browse/CORE-GTC-7884

  9. TYPO3com voted on patch set 4 V +1 12/07/20, 08:09 Completed build in 28m 33s on Mon, 7 Dec, 08:09 AM Test Summary: 32413 passed Find logs and detail information at https://bamboo.typo3.com/browse/CORE-GTC-7884

  10. Benni Mack updated the commit message in patch set 5 12/07/20, 08:46

  11. TYPO3com voted on patch set 5 V +1 12/07/20, 08:55 Completed build in 09m 26s on Mon, 7 Dec, 08:55 AM Test Summary: 32413 passed Find logs and detail information at https://bamboo.typo3.com/browse/CORE-GTC-7889

  12. Alexander Schnitzler commented on patch set 5 12/08/20, 08:58

    I would rephrase to something like > ...if unnecessary or > Don't let prototypes implement SingletonInterface.
  13. Benni Mack uploaded patch set 6 12/08/20, 13:44

  14. TYPO3com voted on patch set 6 V -1 12/08/20, 13:56 Completed build in 12m 48s on Tue, 8 Dec, 01:56 PM Test Summary: 31698 passed Find logs and detail information at https://bamboo.typo3.com/browse/CORE-GTC-7964

  15. TYPO3com voted on patch set 6 V +1 12/08/20, 14:19 Completed build in 47m 54s on Tue, 8 Dec, 02:19 PM Test Summary: 32410 passed Find logs and detail information at https://bamboo.typo3.com/browse/CORE-GTC-7964

  16. Benni Mack commented on patch set 6 12/08/20, 15:51

    Reply

    Ack
  17. Christian Kuhn commented on patch set 6 CR -1 12/08/20, 17:16

    on it.
  18. Christian Kuhn commented on patch set 6 CR 0 12/08/20, 17:33

    looks good, asking benni on two details, though. may vote when this is sorted out.
  19. Alexander Schnitzler commented on patch set 6 CR -1 12/09/20, 09:39

    FlexFormService.php:23 Unresolved

    Why this? Class is stateless and can be shared.

    SessionManager.php:37 Unresolved

    Also don't agree here. This class is stateless. The only property is only a cache. The problem I have with this class is that it's a mixture of a factory and a service and I would extract the factory method.

    Services.yaml:71 Unresolved

    Why this? Class is stateful and yields different results in mthods depending on its state.

    HashService.php:29 Unresolved

    Don't agree here. Class can be shared.

    ExtensionManagementService.php:34 Unresolved

    I tend to disagree here. 95% of this class is pure service, reusable and sharable. The inner state can be resolved by passing the property values as parameters to the methods using them.

    DependencyUtility.php:33 Unresolved

    Pretty much the same as with the ExtensionManagementService. This class shouldn't be called Utility but Service and its inner state should be resolved.

    EmConfUtility.php:25 Unresolved

    Same as with DependencyUtility.

    FileHandlingUtility.php:33 Unresolved

    And again the same like before with the other utilities.

    InstallUtility.php:50 Unresolved

    And again the same like before with the other utilities.

    ListUtility.php:39 Unresolved

    Same like before. $availableExtensions is a property that caches a result. Could easily be static because it doesn't change during runtime. It's either null or with a per request defined state.

    T3editor.php:33 Unresolved

    Well, this is a non shared class because it is a configuration factory. I would say there is no harm in having it shared but neither is there any harm having it not shared.

    CollectionService.php:29 Unresolved

    I would keep this a service and get rid of the stateful properties which is easily doable. Since those properties are reset already, this class is stateless actually and I would keep it a shared service.
  20. Benni Mack commented on patch set 6 12/09/20, 10:52

    Hey Alex, I would rather define these things (shared & public) via DI than via "SingletonInstance", that was my main reason: Streamline behavior, also make testing simpler. I initially thought this was a good idea, but it seems we disagree on the definition of a why things should or should not be a shared service (or a service in DI at all). This is totally fine with me (no hard feelings), but at the same time I don't think it's worth the effort / discussion now, this was more a "drive-by" work, and no written-down master plan about Singleton / State / DI, which probably needs to be defined first. I suggest we drop this change (I'd be fine with it), and we can pick it up at a later stage then.
  21. Alexander Schnitzler commented on patch set 6 12/09/20, 11:08

    Reply

    > I would rather define these things (shared & public) via DI than via "SingletonInstance" I understand, same here. But this change also converts shared instances to non-shared ones. And I don't get the idea about that. imo shared instances are a good thing and a good goal is to have as much as possible. I am fine with talking about that later.
  22. Benni Mack commented on patch set 6 12/09/20, 11:09

    Reply

    yes. I think having as few shared instances as possible is good :) but this is a really good example on how to discuss the views of each other.
  23. Benni Mack abandoned the change 12/09/20, 12:23

    Not working on it yet