[BUGFIX] EM does not update extension list
authorHelmut Hummel <helmut.hummel@typo3.org>
Thu, 29 Nov 2012 18:01:36 +0000 (19:01 +0100)
committerChristian Kuhn <lolli@schwarzbu.ch>
Thu, 29 Nov 2012 18:48:59 +0000 (19:48 +0100)
Currently the Extension Manager looks up the field
in the extension repository repository on how many
extensions are in the system.

Since the result of this getter might be a string
or the number in there might not be up to date,
the EM does not update the extension list.

Change that to a count on the extension table,
which is the wanted behavior here.

Fixes: #43460
Releases: 6.0, 6.1

Change-Id: I3917148852995d0853fbca60848881d6aeacc989
Reviewed-on: http://review.typo3.org/16857
Reviewed-by: Philipp Gampe
Tested-by: Philipp Gampe
Reviewed-by: Christian Kuhn
Tested-by: Christian Kuhn
typo3/sysext/extensionmanager/Classes/Controller/UpdateFromTerController.php
typo3/sysext/extensionmanager/Classes/Domain/Model/Repository.php
typo3/sysext/extensionmanager/Tests/Unit/Controller/UpdateFromTerControllerTest.php

index 00b755b..cfdceca 100644 (file)
@@ -102,7 +102,7 @@ class UpdateFromTerController extends \TYPO3\CMS\Extensionmanager\Controller\Abs
                $errorMessage = '';
                /** @var $repository \TYPO3\CMS\Extensionmanager\Domain\Model\Repository */
                $repository = $this->repositoryRepository->findOneByUid((int)$this->settings['repositoryUid']);
-               if ($repository->getExtensionCount() === 0 || $forceUpdateCheck) {
+               if ($this->extensionRepository->countAll() === 0 || $forceUpdateCheck) {
                        try {
                                $updated = $this->repositoryHelper->updateExtList();
                        } catch (\TYPO3\CMS\Extensionmanager\Exception\ExtensionManagerException $e) {
index 32f892a..719c81d 100644 (file)
@@ -207,7 +207,7 @@ class Repository extends \TYPO3\CMS\Extbase\DomainObject\AbstractEntity {
         * Method returns extension count
         *
         * @access public
-        * @return int count of read extensions
+        * @return integer count of read extensions
         */
        public function getExtensionCount() {
                return $this->extensionCount;
index 07db202..a8f84a0 100644 (file)
@@ -44,14 +44,16 @@ class UpdateFromTerControllerTest extends \TYPO3\CMS\Extbase\Tests\Unit\BaseTest
        public function updateExtensionListFromTerCallsUpdateExtListIfExtensionListIsEmpty() {
                $controllerMock = $this->getAccessibleMock('TYPO3\\CMS\\Extensionmanager\\Controller\\UpdateFromTerController', array('dummy'));
                $repositoryRepositoryMock = $this->getAccessibleMock('TYPO3\\CMS\\Extensionmanager\\Domain\\Repository\\RepositoryRepository', array('findOneByUid'));
-               $repositoryModelMock = $this->getAccessibleMock('TYPO3\\CMS\\Extensionmanager\\Domain\\Model\\Repository', array('getLastUpdate','getExtensionCount'));
+               $repositoryModelMock = $this->getAccessibleMock('TYPO3\\CMS\\Extensionmanager\\Domain\\Model\\Repository', array('getLastUpdate'));
                $repositoryHelperMock = $this->getAccessibleMock('TYPO3\\CMS\\Extensionmanager\\Utility\\Repository\\Helper', array('updateExtList'));
                $viewMock = $this->getAccessibleMock('TYPO3\\CMS\\Fluid\\View\\TemplateView', array('assign'));
                $requestMock = $this->getAccessibleMock('TYPO3\\CMS\\Extbase\\Mvc\\Request', array('hasArgument', 'getArgument'));
                $viewMock->expects($this->any())->method('assign')->will($this->returnValue($viewMock));
-               $repositoryModelMock->expects($this->once())->method('getExtensionCount')->will($this->returnValue(0));
                $repositoryRepositoryMock->expects($this->once())->method('findOneByUid')->with(1)->will($this->returnValue($repositoryModelMock));
                $repositoryHelperMock->expects($this->once())->method('updateExtList');
+               $extensionRepositoryMock = $this->getAccessibleMock('TYPO3\\CMS\\Extensionmanager\\Domain\\Repository\\ExtensionRepository');
+               $extensionRepositoryMock->expects($this->once())->method('countAll')->will($this->returnValue(0));
+               $controllerMock->injectExtensionRepository($extensionRepositoryMock);
 
                $controllerMock->_set('repositoryRepository', $repositoryRepositoryMock);
                $controllerMock->_set('repositoryHelper', $repositoryHelperMock);
@@ -65,17 +67,19 @@ class UpdateFromTerControllerTest extends \TYPO3\CMS\Extbase\Tests\Unit\BaseTest
         * @test
         * @return void
         */
-       public function updateExtensionListFromTerCallsUpdateExtListIfExtensionListIsNotEmpty() {
+       public function updateExtensionListFromTerDoesNotCallsUpdateExtListIfExtensionListIsNotEmpty() {
                $controllerMock = $this->getAccessibleMock('TYPO3\\CMS\\Extensionmanager\\Controller\\UpdateFromTerController', array('dummy'));
                $repositoryRepositoryMock = $this->getAccessibleMock('TYPO3\\CMS\\Extensionmanager\\Domain\\Repository\\RepositoryRepository', array('findOneByUid'));
-               $repositoryModelMock = $this->getAccessibleMock('TYPO3\\CMS\\Extensionmanager\\Domain\\Model\\Repository', array('getLastUpdate','getExtensionCount'));
+               $repositoryModelMock = $this->getAccessibleMock('TYPO3\\CMS\\Extensionmanager\\Domain\\Model\\Repository', array('getLastUpdate'));
                $repositoryHelperMock = $this->getAccessibleMock('TYPO3\\CMS\\Extensionmanager\\Utility\\Repository\\Helper', array('updateExtList'));
                $viewMock = $this->getAccessibleMock('TYPO3\\CMS\\Fluid\\View\\TemplateView', array('assign'));
                $requestMock = $this->getAccessibleMock('TYPO3\\CMS\\Extbase\\Mvc\\Request', array('hasArgument', 'getArgument'));
                $viewMock->expects($this->any())->method('assign')->will($this->returnValue($viewMock));
-               $repositoryModelMock->expects($this->once())->method('getExtensionCount')->will($this->returnValue(1));
                $repositoryRepositoryMock->expects($this->once())->method('findOneByUid')->with(1)->will($this->returnValue($repositoryModelMock));
                $repositoryHelperMock->expects($this->never())->method('updateExtList');
+               $extensionRepositoryMock = $this->getAccessibleMock('TYPO3\\CMS\\Extensionmanager\\Domain\\Repository\\ExtensionRepository');
+               $extensionRepositoryMock->expects($this->once())->method('countAll')->will($this->returnValue(100));
+               $controllerMock->injectExtensionRepository($extensionRepositoryMock);
 
                $controllerMock->_set('repositoryRepository', $repositoryRepositoryMock);
                $controllerMock->_set('repositoryHelper', $repositoryHelperMock);
@@ -92,14 +96,16 @@ class UpdateFromTerControllerTest extends \TYPO3\CMS\Extbase\Tests\Unit\BaseTest
        public function updateExtensionListFromTerCallsUpdateExtListIfForceUpdateCheckIsSet() {
                $controllerMock = $this->getAccessibleMock('TYPO3\\CMS\\Extensionmanager\\Controller\\UpdateFromTerController', array('dummy'));
                $repositoryRepositoryMock = $this->getAccessibleMock('TYPO3\\CMS\\Extensionmanager\\Domain\\Repository\\RepositoryRepository', array('findOneByUid'));
-               $repositoryModelMock = $this->getAccessibleMock('TYPO3\\CMS\\Extensionmanager\\Domain\\Model\\Repository', array('getLastUpdate','getExtensionCount'));
+               $repositoryModelMock = $this->getAccessibleMock('TYPO3\\CMS\\Extensionmanager\\Domain\\Model\\Repository', array('getLastUpdate'));
                $repositoryHelperMock = $this->getAccessibleMock('TYPO3\\CMS\\Extensionmanager\\Utility\\Repository\\Helper', array('updateExtList'));
                $viewMock = $this->getAccessibleMock('TYPO3\\CMS\\Fluid\\View\\TemplateView', array('assign'));
                $requestMock = $this->getAccessibleMock('TYPO3\\CMS\\Extbase\\Mvc\\Request', array('hasArgument', 'getArgument'));
                $viewMock->expects($this->any())->method('assign')->will($this->returnValue($viewMock));
-               $repositoryModelMock->expects($this->once())->method('getExtensionCount')->will($this->returnValue(1));
                $repositoryRepositoryMock->expects($this->once())->method('findOneByUid')->with(1)->will($this->returnValue($repositoryModelMock));
                $repositoryHelperMock->expects($this->once())->method('updateExtList');
+               $extensionRepositoryMock = $this->getAccessibleMock('TYPO3\\CMS\\Extensionmanager\\Domain\\Repository\\ExtensionRepository');
+               $extensionRepositoryMock->expects($this->once())->method('countAll')->will($this->returnValue(100));
+               $controllerMock->injectExtensionRepository($extensionRepositoryMock);
 
                $controllerMock->_set('repositoryRepository', $repositoryRepositoryMock);
                $controllerMock->_set('repositoryHelper', $repositoryHelperMock);