64386[BUGFIX] Consistently fetch SiteConfiguration from DI
Commit message
Review
-
Code review CR +2 Done
- Helmut Hummel +2
- Benjamin Franzke +1
- Daniel Goerz +1
-
Verified V +2 Done
- Helmut Hummel +2
- Benjamin Franzke +1
- TYPO3com +1 CI
Issues 1
Files 9
- typo3/sysext/backend/Classes/Controller/SiteConfigurationController.php3+2 −3
- typo3/sysext/backend/Classes/Form/FormDataProvider/SiteDatabaseEditRow.php+2 −9
- typo3/sysext/backend/Configuration/Services.yaml3+2 −0
- typo3/sysext/core/Classes/Hooks/CreateSiteConfiguration.php+1 −4
- typo3/sysext/core/Classes/Site/SiteFinder.php+1 −5
- typo3/sysext/core/Classes/ServiceProvider.php+1 −1
- typo3/sysext/extensionmanager/Classes/Utility/InstallUtility.php+1 −4
- typo3/sysext/extensionmanager/Tests/Unit/Utility/InstallUtilityTest.php+5 −0
- typo3/sysext/frontend/Tests/Unit/ContentObject/ContentObjectRendererTest.php+4 −0
Review log 1417
-
Helmut Hummel uploaded patch set 1 05/01/20, 17:55
-
TYPO3com voted on patch set 1 V -1 05/01/20, 17:55 Completed build in 21s on Fri, 1 May, 05:55 PM Test Summary: No tests found Find logs and detail information at https://bamboo.typo3.com/browse/CORE-GTC-3151
-
Georg Ringer commented on patch set 1 05/01/20, 19:33
I guess you are meaning 10.4? we didn't branch yet, so master is fine -
Benjamin Franzke wrote 05/02/20, 04:56
Topic set to di -
Benjamin Franzke commented on patch set 1 05/02/20, 06:58
Very good catch, I was so sure I already replaced all those invocations, way before #89892… Why? SiteConfiguration was also configured in Services.yaml (including the constructor argument and as public service) and I faced the same problem with this before (the SiteConfiguration Services.yaml config was already included in the initial symfony DI patch). Anyway, maybe that patch was only in my stash, this change will definitely be needed. -
Benjamin Franzke uploaded patch set 2 05/02/20, 07:06
-
Benjamin Franzke commented on patch set 2 05/02/20, 07:07
Reply
Done -
TYPO3com voted on patch set 2 V +1 05/02/20, 07:17 Completed build in 10m 53s on Sat, 2 May, 07:17 AM Test Summary: 73663 passed Find logs and detail information at https://bamboo.typo3.com/browse/CORE-GTC-3159
-
Benjamin Franzke uploaded patch set 3 05/02/20, 08:56
-
TYPO3com voted on patch set 3 V +1 05/02/20, 09:09 Completed build in 13m 18s on Sat, 2 May, 09:09 AM Test Summary: 73663 passed Find logs and detail information at https://bamboo.typo3.com/browse/CORE-GTC-3162
-
Helmut Hummel commented on patch set 3 05/02/20, 11:46
> Patch Set 1: > > Why? SiteConfiguration was also configured in Services.yaml (including the constructor argument and as public service) Ah, right. When I was debugging this, I was looking for that, but somehow did not see it. And thanks for the cleanup! -
Alexander Schnitzler commented on patch set 3 05/02/20, 11:47
SiteConfigurationController.php:331Question regarding our general approach: makeInstance internally uses the container for Singletons. I always understood that we have that as a safety net for those who are not familiar with DI yet. Shouldn't the core use `GeneralUtility::getContainer()->get()` instead here to be a good example for users to show the difference between singletons and prototypes?Services.yaml:51Can you please shed some light on this change please? -
Benjamin Franzke commented on patch set 3 05/04/20, 07:09
SiteConfigurationController.php:331ReplyNo, GeneralUtility::getContainer() is marked @internal as it is explicitly not suggested to retrieve the container via GeneralUtility. The suggestion is always to use injection of services. If lazy loading is needed (e.g. for dispatchers), then injection of ContainerInterface is fine – GeneralUtility::getContainer() was really meant as internal helper for some codepaths (in core) that are currently not fixable otherwise (without breaking BC) – I'm thinking about some __wakeup Methods here. For my personal taste we already got too many GeneralUtility::getContainer() calls in core. I don't want people to migrate to GeneralUtility::getContainer()->get() while injection would be the right thing. Its better to stick with makeInstance then and migrate to proper injection (once possible) directly. Therefore, we do also rather use makeInstance in the core (if injection is not possible). So, why using GeneralUtility::makeInstance here? I think in Core, especially in bugfixes, we're not always able to simply refactor to dependency injection, as one needs to be *very* clear about the consequences, especially early instatiation of services, vs late (ondemand) instantiation. Regarding the safety net: Yes, makeInstance uses the container – for all clases/services that are marked as available in the container. Therefore it doesn't decide whether a service is a singleton or not, but rather looks at given constructor arguments being zero. If there are more than zero parameters be therefore have to bypass the container Actually, this case (SiteConfiguration) was (IIRC) the only one where non-optional constructor arguments where passed to singleton class before we introduced dependency injection.Services.yaml:51ReplySiteDatabaseEditRow didn't really use dependency injection yet. It had an optional constructor argument but retrieved the dependency via makeInstance if it wasn't passed. Now, as it wasn't public in the container, it was not registered in the container. This provider is instanciates lazily and therefore needs to be available in the container. This meant the dependency was never passed. I've therefore marked it public to be able to simplify the constructor of SiteDatabaseEditRow. In contrast to the SiteConfigurationController I considered it save to switch to dependency injection instead of makeInstance here. -
Alexander Schnitzler commented on patch set 3 05/04/20, 07:15
SiteConfigurationController.php:331Reply> The suggestion is always to use injection of services. Sure. I think I have to differentiate here. My understanding was not to use the container in general but in those case where we don't have a DI-ready environment. Then, and only then, I was under the impression that we rather use getContainer rather then makeInstance. Anyways, thanks for clearing that up! :)Services.yaml:51ReplyAck -
Daniel Goerz voted on patch set 3 CR +1 05/07/20, 07:36
-
Helmut Hummel voted on patch set 3 V +2 CR +2 05/11/20, 18:37
-
Helmut Hummel merged patch set 4 05/11/20, 18:37