[BUGFIX] Streamline queue objects on dependency check 76/39276/2
authorNicole Cordes <typo3@cordes.co>
Tue, 5 May 2015 10:18:05 +0000 (12:18 +0200)
committerAndreas Fernandez <typo3@scripting-base.de>
Tue, 5 May 2015 11:47:07 +0000 (13:47 +0200)
The data stored in different download queues mixes arrays and objects.
Therefore you cannot loop over all queues and call functions of extension
objects. This patch streamlines all objects and make sure always objects
are returned.

Releases: master, 6.2
Resolves: #66798
Change-Id: I6eedefb614145b8645c7c52ff5daa7ad6c9c38e7
Reviewed-on: http://review.typo3.org/39276
Reviewed-by: Wouter Wolters <typo3@wouterwolters.nl>
Reviewed-by: Helmut Hummel <helmut.hummel@typo3.org>
Tested-by: Helmut Hummel <helmut.hummel@typo3.org>
Reviewed-by: Andreas Fernandez <typo3@scripting-base.de>
Tested-by: Andreas Fernandez <typo3@scripting-base.de>
typo3/sysext/extensionmanager/Classes/Domain/Model/DownloadQueue.php
typo3/sysext/extensionmanager/Classes/Service/ExtensionManagementService.php
typo3/sysext/extensionmanager/Tests/Unit/Service/ExtensionManagementServiceTest.php

index 8bee00f..5f25326 100644 (file)
@@ -108,11 +108,11 @@ class DownloadQueue implements \TYPO3\CMS\Core\SingletonInterface {
        /**
         * Adds an extension to the install queue for later installation
         *
-        * @param string $extensionKey
+        * @param Extension $extension
         * @return void
         */
-       public function addExtensionToInstallQueue($extensionKey) {
-               $this->extensionInstallStorage[$extensionKey] = $extensionKey;
+       public function addExtensionToInstallQueue($extension) {
+               $this->extensionInstallStorage[$extension->getExtensionKey()] = $extension;
        }
 
        /**
index dd61beb..fd4e030 100644 (file)
@@ -79,8 +79,9 @@ class ExtensionManagementService implements \TYPO3\CMS\Core\SingletonInterface {
        public function markExtensionForInstallation($extensionKey) {
                // We have to check for dependencies of the extension first, before marking it for installation
                // because this extension might have dependencies, which need to be installed first
-               $this->dependencyUtility->checkDependencies($this->getExtension($extensionKey));
-               $this->downloadQueue->addExtensionToInstallQueue($extensionKey);
+               $extension = $this->getExtension($extensionKey);
+               $this->dependencyUtility->checkDependencies($extension);
+               $this->downloadQueue->addExtensionToInstallQueue($extension);
        }
 
        /**
@@ -166,7 +167,7 @@ class ExtensionManagementService implements \TYPO3\CMS\Core\SingletonInterface {
                                $updatedDependencies = $this->uninstallDependenciesToBeUpdated($queue['update']);
                        }
                        // add extension at the end of the download queue
-                       $this->downloadQueue->addExtensionToInstallQueue($extension->getExtensionKey());
+                       $this->downloadQueue->addExtensionToInstallQueue($extension);
                        $installQueue = $this->downloadQueue->getExtensionInstallStorage();
                        if (count($installQueue) > 0) {
                                $installedDependencies = $this->installDependencies($installQueue);
@@ -286,13 +287,13 @@ class ExtensionManagementService implements \TYPO3\CMS\Core\SingletonInterface {
                        $this->emitWillInstallExtensionsSignal($installQueue);
                }
                $resolvedDependencies = array();
-               foreach ($installQueue as $extensionKey => $extensionDetails) {
-                       $this->installUtility->install($extensionDetails);
-                       $this->emitHasInstalledExtensionSignal($extensionDetails);
+               foreach ($installQueue as $extensionKey => $_) {
+                       $this->installUtility->install($extensionKey);
+                       $this->emitHasInstalledExtensionSignal($extensionKey);
                        if (!is_array($resolvedDependencies['installed'])) {
                                $resolvedDependencies['installed'] = array();
                        }
-                       $resolvedDependencies['installed'][$extensionKey] = $extensionDetails;
+                       $resolvedDependencies['installed'][$extensionKey] = $extensionKey;
                }
                return $resolvedDependencies;
        }
index 72334ce..caa15d2 100644 (file)
@@ -232,17 +232,14 @@ class ExtensionManagementServiceTest extends \TYPO3\CMS\Core\Tests\UnitTestCase
                        \TYPO3\CMS\Extensionmanager\Service\ExtensionManagementService::class,
                        array('emitWillInstallExtensionsSignal', 'emitHasInstalledExtensionSignal')
                );
+               /** @var \TYPO3\CMS\Extensionmanager\Domain\Model\Extension $extensionMock */
+               $extensionMock = $this->getMock(\TYPO3\CMS\Extensionmanager\Domain\Model\Extension::class, array('dummy'));
+               $extensionMock->setExtensionKey('foobar');
                $installQueue = array(
-                       'foobar' => array(
-                               'key' => 'foobar',
-                               'siteRelPath' => 'path'
-                       )
+                       'foobar' => $extensionMock,
                );
                $installUtility = $this->getAccessibleMock(\TYPO3\CMS\Extensionmanager\Utility\InstallUtility::class, array('install','emitWillInstallExtensionsSignal'), array(), '', FALSE);
-               $installUtility->expects($this->once())->method('install')->with(array(
-                       'key' => 'foobar',
-                       'siteRelPath' => 'path'
-               ));
+               $installUtility->expects($this->once())->method('install')->with('foobar');
                $managementMock->_set('installUtility', $installUtility);
                $managementMock->_call('installDependencies', $installQueue);
        }
@@ -256,8 +253,11 @@ class ExtensionManagementServiceTest extends \TYPO3\CMS\Core\Tests\UnitTestCase
                        'emitWillInstallExtensionsSignal',
                        'emitHasInstalledExtensionSignal'
                ));
+               /** @var \TYPO3\CMS\Extensionmanager\Domain\Model\Extension $extensionMock */
+               $extensionMock = $this->getMock(\TYPO3\CMS\Extensionmanager\Domain\Model\Extension::class, array('dummy'));
+               $extensionMock->setExtensionKey('foobar');
                $installQueue = array(
-                       'foobar' => 'foobar'
+                       'foobar' => $extensionMock,
                );
                $installUtility = $this->getAccessibleMock(\TYPO3\CMS\Extensionmanager\Utility\InstallUtility::class, array('install','emitWillInstallExtensionsSignal'), array(), '', FALSE);
                $installUtility->expects($this->once())->method('install')->with('foobar');