[BUGFIX] PackageStates is not updated in EM 14/24714/3
authorThomas Maroschik <tmaroschik@dfau.de>
Sun, 13 Oct 2013 20:11:32 +0000 (22:11 +0200)
committerStefan Neufeind <typo3.neufeind@speedpartner.de>
Mon, 14 Oct 2013 14:00:04 +0000 (16:00 +0200)
Introduces a signal in the EM that emits right before extensions
will be installed. The package manager reacts on this signal and
scans the extension folders for new extensions.

Fixes: #52766
Releases: 6.2
Change-Id: Ida1146d98b2c7f280a079c7ce6737111186c95ac
Reviewed-on: https://review.typo3.org/24714
Reviewed-by: Sascha Egerer
Tested-by: Nicole Cordes
Reviewed-by: Markus Klein
Reviewed-by: Stefan Neufeind
Tested-by: Stefan Neufeind
typo3/sysext/core/Classes/Core/Bootstrap.php
typo3/sysext/core/Classes/Package/PackageManager.php
typo3/sysext/extbase/Classes/Object/Container/Container.php
typo3/sysext/extensionmanager/Classes/Service/ExtensionManagementService.php
typo3/sysext/extensionmanager/ext_localconf.php

index 2fd81f8..b93e540 100644 (file)
@@ -309,10 +309,11 @@ class Bootstrap {
        protected function initializePackageManagement($packageManagerClassName) {
                $packageManager = new $packageManagerClassName();
                $this->setEarlyInstance('TYPO3\\Flow\\Package\\PackageManager', $packageManager);
-               \TYPO3\CMS\Core\Utility\ExtensionManagementUtility::setPackageManager($packageManager);
+               Utility\ExtensionManagementUtility::setPackageManager($packageManager);
                $packageManager->injectClassLoader($this->getEarlyInstance('TYPO3\\CMS\\Core\\Core\\ClassLoader'));
                $packageManager->injectCoreCache($this->getEarlyInstance('TYPO3\\CMS\\Core\\Cache\\CacheManager')->getCache('cache_core'));
                $packageManager->initialize($this, PATH_site);
+               Utility\GeneralUtility::setSingletonInstance($packageManagerClassName, $packageManager);
                $GLOBALS['TYPO3_LOADED_EXT'] = new \TYPO3\CMS\Core\Compatibility\LoadedExtensionsArray($packageManager);
                return $this;
        }
index ed86966..a79ef15 100644 (file)
@@ -170,7 +170,7 @@ class PackageManager extends \TYPO3\Flow\Package\PackageManager implements \TYPO
        protected function saveToPackageCache() {
                $cacheEntryIdentifier = $this->getCacheEntryIdentifier();
                if ($cacheEntryIdentifier !== NULL && !$this->coreCache->has($cacheEntryIdentifier)) {
-                       $cacheEntryPath = $this->coreCache->getBackend()->getCacheDirectory();
+                       $cacheEntryPath = rtrim($this->coreCache->getBackend()->getCacheDirectory(), '/\\');
                        // Package objects get their own cache entry, so PHP does not have to parse the serialized string
                        $packageObjectsCacheEntryIdentifier = uniqid('PackageObjects_');
                        // Build cache file
@@ -237,7 +237,7 @@ class PackageManager extends \TYPO3\Flow\Package\PackageManager implements \TYPO
         * @return void
         * @throws \TYPO3\Flow\Package\Exception\DuplicatePackageException
         */
-       protected function scanAvailablePackages() {
+       public function scanAvailablePackages() {
                $previousPackageStatesConfiguration = $this->packageStatesConfiguration;
 
                if (isset($this->packageStatesConfiguration['packages'])) {
@@ -290,7 +290,7 @@ class PackageManager extends \TYPO3\Flow\Package\PackageManager implements \TYPO
                        $this->packageStatesConfiguration['packages'][$packageKey]['classesPath'] = \TYPO3\Flow\Package\Package::DIRECTORY_CLASSES;
                }
 
-               $this->registerPackagesFromConfiguration();
+               $this->registerPackagesFromConfiguration(!empty($this->packages));
                if ($this->packageStatesConfiguration != $previousPackageStatesConfiguration) {
                        $this->sortAndsavePackageStates();
                }
@@ -339,12 +339,17 @@ class PackageManager extends \TYPO3\Flow\Package\PackageManager implements \TYPO
        /**
         * Requires and registers all packages which were defined in packageStatesConfiguration
         *
+        * @param boolean $registerOnlyNewPackages
         * @return void
         * @throws \TYPO3\Flow\Package\Exception\CorruptPackageException
         */
-       protected function registerPackagesFromConfiguration() {
+       protected function registerPackagesFromConfiguration($registerOnlyNewPackages = FALSE) {
                foreach ($this->packageStatesConfiguration['packages'] as $packageKey => $stateConfiguration) {
 
+                       if ($registerOnlyNewPackages && $this->isPackageAvailable($packageKey)) {
+                               continue;
+                       }
+
                        $packagePath = isset($stateConfiguration['packagePath']) ? $stateConfiguration['packagePath'] : NULL;
                        $classesPath = isset($stateConfiguration['classesPath']) ? $stateConfiguration['classesPath'] : NULL;
                        $manifestPath = isset($stateConfiguration['manifestPath']) ? $stateConfiguration['manifestPath'] : NULL;
index c1225fe..8f1d256 100644 (file)
@@ -154,6 +154,9 @@ class Container implements \TYPO3\CMS\Core\SingletonInterface {
                if ($className === 'TYPO3\\CMS\\Core\\Cache\\CacheManager') {
                        return $GLOBALS['typo3CacheManager'];
                }
+               if ($className === 'TYPO3\\CMS\\Core\\Package\\PackageManager') {
+                       return \TYPO3\CMS\Core\Utility\GeneralUtility::makeInstance('TYPO3\\CMS\\Core\\Package\\PackageManager');
+               }
                $className = \TYPO3\CMS\Core\Core\ClassLoader::getClassNameForAlias($className);
                if (isset($this->singletonInstances[$className])) {
                        if (count($givenConstructorArguments) > 0) {
index 147f28b..ca9bff0 100644 (file)
@@ -194,6 +194,9 @@ class ExtensionManagementService implements \TYPO3\CMS\Core\SingletonInterface {
         * @return array
         */
        protected function installDependencies(array $installQueue) {
+               if (!empty($installQueue)) {
+                       $this->emitWillInstallExtensions($installQueue);
+               }
                $resolvedDependencies = array();
                foreach ($installQueue as $extensionKey => $extensionDetails) {
                        $this->installUtility->install($extensionDetails);
@@ -256,4 +259,24 @@ class ExtensionManagementService implements \TYPO3\CMS\Core\SingletonInterface {
                return $downloadedDependencies;
        }
 
+       /**
+        * @param array $installQueue
+        */
+       protected function emitWillInstallExtensions(array $installQueue) {
+               $this->getSignalSlotDispatcher()->dispatch(__CLASS__, 'willInstallExtensions', array($installQueue));
+       }
+
+       /**
+        * Get the SignalSlot dispatcher
+        *
+        * @return \TYPO3\CMS\Extbase\SignalSlot\Dispatcher
+        */
+       protected function getSignalSlotDispatcher() {
+               if (!isset($this->signalSlotDispatcher)) {
+                       $this->signalSlotDispatcher = \TYPO3\CMS\Core\Utility\GeneralUtility::makeInstance('TYPO3\\CMS\\Extbase\\Object\\ObjectManager')
+                               ->get('TYPO3\\CMS\\Extbase\\SignalSlot\\Dispatcher');
+               }
+               return $this->signalSlotDispatcher;
+       }
+
 }
index 94da9a9..f339e04 100644 (file)
@@ -13,4 +13,13 @@ $GLOBALS['TYPO3_CONF_VARS']['SC_OPTIONS']['scheduler']['tasks']['TYPO3\\CMS\\Ext
 
 if (TYPO3_MODE === 'BE') {
        $GLOBALS['TYPO3_CONF_VARS']['SC_OPTIONS']['extbase']['commandControllers'][] = 'TYPO3\\CMS\\Extensionmanager\\Command\\ExtensionCommandController';
+       if (!(TYPO3_REQUESTTYPE & TYPO3_REQUESTTYPE_INSTALL)) {
+               $signalSlotDispatcher = \TYPO3\CMS\Core\Utility\GeneralUtility::makeInstance('TYPO3\\CMS\\Extbase\\SignalSlot\\Dispatcher');
+               $signalSlotDispatcher->connect(
+                       'TYPO3\\CMS\\Extensionmanager\\Service\\ExtensionManagementService',
+                       'willInstallExtensions',
+                       'TYPO3\\CMS\\Core\\Package\\PackageManager',
+                       'scanAvailablePackages'
+               );
+       }
 }