[BUGFIX] Streamline queue objects on dependency check 77/39277/3
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 13:00:17 +0000 (15:00 +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/39277
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 936ec7e..3c1887a 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 c27849a..0e3726b 100644 (file)
@@ -70,8 +70,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);
        }
 
        /**
@@ -150,7 +151,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);
@@ -269,13 +270,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 6233a62..73b02df 100644 (file)
@@ -230,17 +230,14 @@ class ExtensionManagementServiceTest extends \TYPO3\CMS\Core\Tests\UnitTestCase
                        'TYPO3\\CMS\\Extensionmanager\\Service\\ExtensionManagementService',
                        array('emitWillInstallExtensionsSignal', 'emitHasInstalledExtensionSignal')
                );
+               /** @var \TYPO3\CMS\Extensionmanager\Domain\Model\Extension $extensionMock */
+               $extensionMock = $this->getMock('TYPO3\\CMS\\Extensionmanager\\Domain\\Model\\Extension', array('dummy'));
+               $extensionMock->setExtensionKey('foobar');
                $installQueue = array(
-                       'foobar' => array(
-                               'key' => 'foobar',
-                               'siteRelPath' => 'path'
-                       )
+                       'foobar' => $extensionMock,
                );
                $installUtility = $this->getAccessibleMock('TYPO3\\CMS\\Extensionmanager\\Utility\\InstallUtility', 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);
        }
@@ -254,8 +251,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', array('dummy'));
+               $extensionMock->setExtensionKey('foobar');
                $installQueue = array(
-                       'foobar' => 'foobar'
+                       'foobar' => $extensionMock,
                );
                $installUtility = $this->getAccessibleMock('TYPO3\\CMS\\Extensionmanager\\Utility\\InstallUtility', array('install','emitWillInstallExtensionsSignal'), array(), '', FALSE);
                $installUtility->expects($this->once())->method('install')->with('foobar');