[BUGFIX] Correctly check stack in DownloadQueue 69/31369/2
authorMarkus Klein <klein.t3@mfc-linz.at>
Sun, 29 Jun 2014 09:43:34 +0000 (11:43 +0200)
committerWouter Wolters <typo3@wouterwolters.nl>
Sat, 5 Jul 2014 19:12:36 +0000 (21:12 +0200)
The extension manager's DownloadQueue does now properly check
the stack when adding extensions to the queue.

Resolves: #59975
Releases: 6.3, 6.2, 6.1
Change-Id: I90e9699608c6d0f3ebd44dd54eb0f471a4e082d9
Reviewed-on: https://review.typo3.org/31369
Reviewed-by: Wouter Wolters
Tested-by: Wouter Wolters
typo3/sysext/extensionmanager/Classes/Domain/Model/DownloadQueue.php
typo3/sysext/extensionmanager/Tests/Unit/Domain/Model/DownloadQueueTest.php

index 9532f8a..8cc4e19 100644 (file)
@@ -23,7 +23,7 @@ class DownloadQueue implements \TYPO3\CMS\Core\SingletonInterface {
        /**
         * Storage for extensions to be downloaded
         *
-        * @var array<Tx_Extensionmanager_Domain_Model_Extension>
+        * @var Extension[string][string]
         */
        protected $extensionStorage = array();
 
@@ -61,8 +61,11 @@ class DownloadQueue implements \TYPO3\CMS\Core\SingletonInterface {
                if (!is_string($stack) || !in_array($stack, array('download', 'update'))) {
                        throw new \TYPO3\CMS\Extensionmanager\Exception\ExtensionManagerException('Stack has to be either "download" or "update"', 1342432103);
                }
-               if (array_key_exists($extension->getExtensionKey(), $this->extensionStorage)) {
-                       if (!($this->extensionStorage[$extension->getExtensionKey()] === $extension)) {
+               if (!isset($this->extensionStorage[$stack])) {
+                       $this->extensionStorage[$stack] = array();
+               }
+               if (array_key_exists($extension->getExtensionKey(), $this->extensionStorage[$stack])) {
+                       if ($this->extensionStorage[$stack][$extension->getExtensionKey()] !== $extension) {
                                throw new \TYPO3\CMS\Extensionmanager\Exception\ExtensionManagerException(
                                        $extension->getExtensionKey() . ' was requested to be downloaded in different versions.',
                                        1342432101
index adf93e7..53d45c7 100644 (file)
@@ -65,25 +65,26 @@ class DownloadQueueTest extends \TYPO3\CMS\Core\Tests\UnitTestCase {
 
        /**
         * @test
-        * @return void
+        * @expectedException \TYPO3\CMS\Extensionmanager\Exception\ExtensionManagerException
+        * @expectedExceptionCode 1342432103
         */
        public function addExtensionToQueueThrowsExceptionIfUnknownStackIsGiven() {
-               $this->setExpectedException('TYPO3\\CMS\\Extensionmanager\\Exception\\ExtensionManagerException', $this->any(), 1342432103);
                $this->downloadQueueMock->addExtensionToQueue($this->extensionMock, 'unknownStack');
        }
 
        /**
         * @test
         * @return void
+        * @expectedException \TYPO3\CMS\Extensionmanager\Exception\ExtensionManagerException
+        * @expectedExceptionCode 1342432101
         */
        public function addExtensionToQueueThrowsExceptionIfExtensionWithSameKeyAndDifferentValuesAlreadyExists() {
                /** @var \TYPO3\CMS\Extensionmanager\Domain\Model\Extension $extensionMock2 */
                $extensionMock2 = $this->getMock('TYPO3\\CMS\\Extensionmanager\\Domain\\Model\\Extension', array('dummy'));
                $extensionMock2->setExtensionKey('foobar');
                $extensionMock2->setVersion('1.0.3');
-               $this->downloadQueueMock->_set('extensionStorage', array('foobar' => $extensionMock2));
 
-               $this->setExpectedException('TYPO3\\CMS\\Extensionmanager\\Exception\\ExtensionManagerException', $this->any(), 1342432101);
+               $this->downloadQueueMock->addExtensionToQueue($extensionMock2);
                $this->downloadQueueMock->addExtensionToQueue($this->extensionMock);
        }