Review main Merged

62575[TASK] Inject singletons used by EXT:install in service providers

Benjamin Franzke CR +2 V +2 Expert +873 −309 updated 04/17/20, 12:24

Commit message

This will allow both, dependency injection for these services (manually
wired in service providers), and usage in install/maintenance tool
(where we do not use the caching symfony container for basic tasks).

The move to DI is possible thanks to the failsafe container and the
service providers which can fed the failsafe container with service
factories. These factories are used to wire services manually.

Notes:

 * The definition in a service provider means we are required to use
   manual wiring and are forced to define the dependencies in the service
   provider when we add new depenencies to services that are being used
   by the install..
   With that approach we can assure that we do not accidentally add new
   dependencies to services which would become available in symfony DI due
   to autowiring, but would be unavailable in the install tool.

 * The install tool has operations that require a booted symfony
   container which is provided by the LateBootService. Services that
   are used in that mode do not need to be listed in service providers.
   Therefore we do only add core services to service providers if they
   are used in a context without a fully booted symfony DI container.

 * GLOBALS['LANG'] mocks in Core\Tests\Unit\DataHandling\DataHandlerTest
   have been removed as the code under test does no longer use
   $GLOBALS['LANG']->csConvObj->substr() but mb_substr. The test had been
   introduced with #68602 but the tested code was adapted in #78670.

 * We got a bit ugly constructs now, where a unit(!) test previously used

     $GLOBALS['LANG'] = new LanguageService();

   …we now have to encode the dependency structure:

     $GLOBALS['LANG'] = new LanguageService(new Locales,
         new LocalizationFactory(
             new LanguageStore,
             $cacheManagerProphecy->reveal()
         )
     );

   This isn't nice, but this change reveals that the affected unit tests
   should either be adapted, removed or be moved to a functional test.
   Such adaption are out of scope for this change.

 * loadExtLocalconfDatabaseAndExtTables() is removed from the
   EXT:install AbstractController, as it hides the implicit dependency
   to LateBootService

 * Nullable constructor arguments have been changed to be non-nullable
   whenever possible. That results in some more test adaptions, but
   reveals, where unit tests rely on implicit dependencies and offers
   better readability and less possible codepaths.

Review

  • Code review CR +2

    Imported before Forger kept the single votes, the next import adds them.

  • Verified V +2

    Imported before Forger kept the single votes, the next import adds them.

Issues 2

Files 45

Show 25 more files