Commit 11c7e844 authored by Oliver Bartsch's avatar Oliver Bartsch
Browse files

[BUGFIX] Push PackageManager to ExtensionManagementUtility in Bootstrap

In order to allow conditional service registration based on
ExtensionManagementUtility::isLoaded() checks in Services.php,
the PackageManager is pushed to ExtensionManagementUtility
before container creation. This has been the case prior to #91500
in order to support runtime activated packages, but got removed
as isLoaded() checks in Services.php have never been an intended

They have been documented in example code nonetheless
and therefore usage is now fixed:

Documentation should be adapted to recommend conditional
services checks (ContainerBuilder::hasDefinition) instead.
Once that is done, isLoaded() in Services.php can be marked as
deprecated in future patches.

Resolves: #95327
Related: #91500
Releases: master
Signed-off-by: Benjamin Franzke's avatarBenjamin Franzke <>
Change-Id: Ifec470bd6364727ec0d9a5937106e6c94c0e18c2

Tested-by: core-ci's avatarcore-ci <>
Tested-by: Benni Mack's avatarBenni Mack <>
Tested-by: Oliver Bartsch's avatarOliver Bartsch <>
Reviewed-by: Benni Mack's avatarBenni Mack <>
Reviewed-by: Oliver Bartsch's avatarOliver Bartsch <>
parent b27044e6
......@@ -137,18 +137,32 @@ class Bootstrap
'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:
// 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.
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.
// Reset LogManager singleton instance in order for GeneralUtility::makeInstance()
// to proxy LogManager retrieval to ContainerInterface->get() from now on.
// Reset singleton instances in order for GeneralUtility::makeInstance() to use
// ContainerInterface->get() for early services from now on.
GeneralUtility::removeSingletonInstance(LogManager::class, $logManager);
// Push PackageManager instance to ExtensionManagementUtility
GeneralUtility::removeSingletonInstance(PackageManager::class, $packageManager);
if ($failsafe) {
$bootState->done = true;
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment