[BUGFIX] Use correct packageManager initializing 92/57692/3
authorNicole Cordes <typo3@cordes.co>
Thu, 26 Jul 2018 15:49:38 +0000 (17:49 +0200)
committerBenni Mack <benni@typo3.org>
Thu, 26 Jul 2018 20:05:21 +0000 (22:05 +0200)
As the PackageManager is a singleton class, you should call
GeneralUtility::makeInstance to retrieve the instance. The bootstrap
correctly initializes the first instance and registers it as singleton
already.

Resolves: #85659
Releases: master
Change-Id: I414a3fe4004044b0cdf6d2d8978f7e3463886018
Reviewed-on: https://review.typo3.org/57692
Reviewed-by: Christian Kuhn <lolli@schwarzbu.ch>
Tested-by: Christian Kuhn <lolli@schwarzbu.ch>
Tested-by: TYPO3com <no-reply@typo3.com>
Reviewed-by: Benni Mack <benni@typo3.org>
Tested-by: Benni Mack <benni@typo3.org>
typo3/sysext/install/Classes/Http/RequestHandler.php

index 9fd5919..8c7c10c 100644 (file)
@@ -18,7 +18,6 @@ namespace TYPO3\CMS\Install\Http;
 use Psr\Http\Message\ResponseInterface;
 use Psr\Http\Message\ServerRequestInterface;
 use TYPO3\CMS\Core\Configuration\ConfigurationManager;
-use TYPO3\CMS\Core\Core\Bootstrap;
 use TYPO3\CMS\Core\Core\Environment;
 use TYPO3\CMS\Core\FormProtection\FormProtectionFactory;
 use TYPO3\CMS\Core\FormProtection\InstallToolFormProtection;
@@ -29,6 +28,7 @@ use TYPO3\CMS\Core\Messaging\FlashMessage;
 use TYPO3\CMS\Core\Messaging\FlashMessageQueue;
 use TYPO3\CMS\Core\Package\PackageInterface;
 use TYPO3\CMS\Core\Package\PackageManager;
+use TYPO3\CMS\Core\Utility\GeneralUtility;
 use TYPO3\CMS\Install\Authentication\AuthenticationService;
 use TYPO3\CMS\Install\Controller\AbstractController;
 use TYPO3\CMS\Install\Controller\EnvironmentController;
@@ -323,8 +323,11 @@ class RequestHandler implements RequestHandlerInterface
     protected function recreatePackageStatesFileIfMissing(): void
     {
         if (!file_exists(Environment::getLegacyConfigPath() . '/PackageStates.php')) {
+            // We need a FailsafePackageManager at this moment, however this is given
+            // As Bootstrap is registering the FailsafePackageManager object as a singleton instance
+            // of the main PackageManager class. See \TYPO3\CMS\Core\Core\Bootstrap::init()
             /** @var \TYPO3\CMS\Core\Package\FailsafePackageManager $packageManager */
-            $packageManager = Bootstrap::getInstance()->getEarlyInstance(PackageManager::class);
+            $packageManager = GeneralUtility::makeInstance(PackageManager::class);
             $packages = $packageManager->getAvailablePackages();
             foreach ($packages as $package) {
                 if ($package instanceof PackageInterface && $package->isPartOfMinimalUsableSystem()) {