[BUGFIX] Return all packages with PackageManager::getAvailablePackages 26/51026/3
authorNicole Cordes <typo3@cordes.co>
Thu, 22 Dec 2016 15:29:43 +0000 (16:29 +0100)
committerBenni Mack <benni@typo3.org>
Sun, 15 Jan 2017 12:05:32 +0000 (13:05 +0100)
Currently the PackageManager loads installed package information by
default only. This patch adds a new flag to ensure all packages are
fetched before all available package information should be returned.

Resolves: #79078
Releases: master
Change-Id: I729c02f7b5c8303ee8d277aa88782274dff23591
Reviewed-on: https://review.typo3.org/51026
Tested-by: TYPO3com <no-reply@typo3.com>
Reviewed-by: Georg Ringer <georg.ringer@gmail.com>
Tested-by: Georg Ringer <georg.ringer@gmail.com>
Reviewed-by: Benni Mack <benni@typo3.org>
Tested-by: Benni Mack <benni@typo3.org>
typo3/sysext/core/Classes/Package/PackageManager.php

index 2520a18..b6e7dad 100644 (file)
@@ -74,6 +74,11 @@ class PackageManager implements \TYPO3\CMS\Core\SingletonInterface
     protected $packages = [];
 
     /**
+     * @var bool
+     */
+    protected $availablePackagesScanned = false;
+
+    /**
      * A map between ComposerName and PackageKey, only available when scanAvailablePackages is run
      * @var array
      */
@@ -322,6 +327,7 @@ class PackageManager implements \TYPO3\CMS\Core\SingletonInterface
             }
         }
 
+        $this->availablePackagesScanned = true;
         $registerOnlyNewPackages = !empty($this->packages);
         $this->registerPackagesFromConfiguration($packages, $registerOnlyNewPackages);
     }
@@ -796,6 +802,10 @@ class PackageManager implements \TYPO3\CMS\Core\SingletonInterface
      */
     public function getAvailablePackages()
     {
+        if ($this->availablePackagesScanned === false) {
+            $this->scanAvailablePackages();
+        }
+
         return $this->packages;
     }