Skip to content

Commit

Permalink
[TASK] Revert "[BUGFIX] Push PackageManager to ExtensionManagementUti…
Browse files Browse the repository at this point in the history
…lity in Bootstrap"

This reverts commit 11c7e84.

The BUGFIX accounted for ExtensionManagementUtility usage in Services.php
which has never been officially supported, but has been a documentation
bug and actually worked only by accident and only in TYPO3 core,
not with tools like typo3-console. Therefore extensions that use this
could always cause breakage in some situations.

The alternative to use optional service dependencies via
ContainerBuilder::hasDefinition() is available since v10
and the documentation is adapted accordingly in #95359.
Therefore the BUGFIX is reverted.

Resolves: #95358
Related: #95359
Reverts: #95327
Releases: master
Change-Id: I387fa2905b554ca12bf60d6bff452c9964c36a69
Reviewed-on: https://review.typo3.org/c/Packages/TYPO3.CMS/+/71252
Tested-by: core-ci <typo3@b13.com>
Tested-by: Helmut Hummel <typo3@helhum.io>
Tested-by: Oliver Bartsch <bo@cedev.de>
Reviewed-by: Helmut Hummel <typo3@helhum.io>
Reviewed-by: Oliver Bartsch <bo@cedev.de>
  • Loading branch information
bnf authored and o-ba committed Sep 25, 2021
1 parent 6ff84cd commit 6dbe94b
Showing 1 changed file with 5 additions and 19 deletions.
24 changes: 5 additions & 19 deletions typo3/sysext/core/Classes/Core/Bootstrap.php
Expand Up @@ -137,32 +137,18 @@ public static function init(
'boot.state' => $bootState,
]);

// Push PackageManager instance to ExtensionManagementUtility to support ::isLoaded() checks in Services.php
//
// Note that ExtensionManagementUtility() usage in Services.php has never been an intended usage,
// but it was technically possible in TYPO3 v10 as a side effect of runtime activated packages,
// and therefore got documented in example code:
// https://docs.typo3.org/c/typo3/cms-dashboard/10.4/en-us/Configuration/WidgetRegistration.html#services-php-file
//
// Container builds should generally be stateless and should only take explicit service configuration and ContainerBuilder
// build-state into account. Therefore ExtensionManagementUtility usage in Services.php should generally be avoided,
// and be replaced by service checks, e.g. ContainerBuilder->hasDefinition(ClassNameOfOptionalDependency::class)
// (combined with package suggest definition in composer.json/ext_emconf.php to ensure extension ordering is correct)
//
// @todo: Adapt documentation and maybe log a deprecation notice if ::isLoaded() is used during container builds.
ExtensionManagementUtility::setPackageManager($packageManager);
GeneralUtility::setSingletonInstance(PackageManager::class, $packageManager);

$container = $builder->createDependencyInjectionContainer($packageManager, $dependencyInjectionContainerCache, $failsafe);

// Push the container to GeneralUtility as we want to make sure its
// makeInstance() method creates classes using the container from now on.
GeneralUtility::setContainer($container);

// Reset singleton instances in order for GeneralUtility::makeInstance() to use
// ContainerInterface->get() for early services from now on.
// Reset LogManager singleton instance in order for GeneralUtility::makeInstance()
// to proxy LogManager retrieval to ContainerInterface->get() from now on.
GeneralUtility::removeSingletonInstance(LogManager::class, $logManager);
GeneralUtility::removeSingletonInstance(PackageManager::class, $packageManager);

// Push PackageManager instance to ExtensionManagementUtility
ExtensionManagementUtility::setPackageManager($packageManager);

if ($failsafe) {
$bootState->done = true;
Expand Down

0 comments on commit 6dbe94b

Please sign in to comment.