[TASK] Cleanup EXT/requiredExt handling 32/27232/4
authorChristian Kuhn <lolli@schwarzbu.ch>
Sat, 1 Feb 2014 14:05:37 +0000 (15:05 +0100)
committerChristian Kuhn <lolli@schwarzbu.ch>
Sat, 1 Feb 2014 14:59:14 +0000 (15:59 +0100)
LocalConfiguration setting EXT/requiredExt was obsoleted with the
new package manger, the setting is removed by the PackageStates
migration code in install tool already.

* Remove further mentions of this setting
* Adapt method in ExtensionManagementUtility
* Streamline and remove some related units tests
* Move deletion of requiredExt setting to silent update
* Adapt an em view helper to new API

Change-Id: Ie9593c9791893bb4fb0714032efbfc06808b0a35
Resolves: #55555
Releases: 6.2
Reviewed-on: https://review.typo3.org/27232
Reviewed-by: Anja Leichsenring
Tested-by: Anja Leichsenring
Reviewed-by: Daniel Siepmann
Reviewed-by: Christian Kuhn
Tested-by: Christian Kuhn
typo3/sysext/core/Classes/Utility/ExtensionManagementUtility.php
typo3/sysext/core/Configuration/DefaultConfiguration.php
typo3/sysext/core/Tests/Unit/Utility/ExtensionManagementUtilityTest.php
typo3/sysext/extensionmanager/Classes/ViewHelpers/ToggleExtensionInstallationStateViewHelper.php
typo3/sysext/install/Classes/Controller/StepController.php
typo3/sysext/install/Classes/Service/SilentConfigurationUpgradeService.php

index 2d2e3db..0c5a940 100644 (file)
@@ -60,9 +60,10 @@ class ExtensionManagementUtility {
 
        /**
         * Sets the package manager for all that backwards compatibility stuff,
-        * so it doesn't have to be fetched through the bootstap
+        * so it doesn't have to be fetched through the bootstap.
         *
         * @param \TYPO3\CMS\Core\Package\PackageManager $packageManager
+        * @internal
         */
        static public function setPackageManager(\TYPO3\CMS\Core\Package\PackageManager $packageManager) {
                static::$packageManager = $packageManager;
@@ -90,9 +91,7 @@ class ExtensionManagementUtility {
        }
 
        /**
-        * Returns the absolute path to the extension with extension key $key
-        * If the extension is not loaded the function will die with an error message
-        * Useful for internal fileoperations
+        * Returns the absolute path to the extension with extension key $key.
         *
         * @param $key string Extension key
         * @param $script string $script is appended to the output if set.
@@ -1783,21 +1782,14 @@ tt_content.' . $key . $prefix . ' {
        }
 
        /**
-        * Gets list of required extensions.
-        * This is the list of extensions from constant REQUIRED_EXTENSIONS defined
-        * in bootstrap, together with a possible additional list of extensions from
-        * local configuration
+        * Returns REQUIRED_EXTENSIONS constant set by package manager as array.
         *
         * @return array List of required extensions
+        * @deprecated since 6,2, will be removed two versions later.
         */
        static public function getRequiredExtensionListArray() {
-               if (is_array($GLOBALS['TYPO3_CONF_VARS']['EXT']['requiredExt'])) {
-                       $requiredExtensions = $GLOBALS['TYPO3_CONF_VARS']['EXT']['requiredExt'];
-               } else {
-                       $requiredExtensions = GeneralUtility::trimExplode(',', $GLOBALS['TYPO3_CONF_VARS']['EXT']['requiredExt']);
-               }
-               $requiredExtensions = array_merge(GeneralUtility::trimExplode(',', REQUIRED_EXTENSIONS), $requiredExtensions);
-               return array_unique($requiredExtensions);
+               GeneralUtility::logDeprecatedFunction();
+               return GeneralUtility::trimExplode(',', REQUIRED_EXTENSIONS);
        }
 
        /**
index 3f46906..c9d29f9 100644 (file)
@@ -254,7 +254,6 @@ return array(
                'allowGlobalInstall' => FALSE,          // Boolean: If set, global extensions in typo3/ext/ are allowed to be installed, updated and deleted etc.
                'allowLocalInstall' => TRUE,            // Boolean: If set, local extensions in typo3conf/ext/ are allowed to be installed, updated and deleted etc.
                'allowSystemInstall' => FALSE,          // Boolean: If set, you can install extensions in the sysext/ dir. Use this to upgrade the 'cms' and 'lang' extensions.
-               'requiredExt' => array(),               // String. List of additional extensions which are REQUIRED and cannot be unloaded by the Extension Manager!
                'excludeForPackaging' => '(CVS|\\..*|.*~|.*\\.bak)',            // String: List of directories and files which will not be packaged into extensions nor taken into account otherwise by the Extension Manager. Perl regular expression syntax!
                'extListArray' => array(
                        'filelist',
index 46a2f13..2b3976b 100644 (file)
@@ -203,13 +203,14 @@ class ExtensionManagementUtilityTest extends \TYPO3\CMS\Core\Tests\UnitTestCase
         * @expectedException \BadFunctionCallException
         */
        public function extPathThrowsExceptionIfExtensionIsNotLoaded() {
+               $packageName = uniqid('foo');
                $packageManager = $this->getMock('TYPO3\\CMS\\Core\\Package\\PackageManager', array('isPackageActive'));
                $packageManager->expects($this->once())
                                ->method('isPackageActive')
-                               ->with($this->equalTo('bar'))
+                               ->with($this->equalTo($packageName))
                                ->will($this->returnValue(FALSE));
                ExtensionManagementUtility::setPackageManager($packageManager);
-               ExtensionManagementUtility::extPath('bar');
+               ExtensionManagementUtility::extPath($packageName);
        }
 
        /**
@@ -236,36 +237,6 @@ class ExtensionManagementUtilityTest extends \TYPO3\CMS\Core\Tests\UnitTestCase
                $this->assertSame(PATH_site . 'foo/bar.txt', ExtensionManagementUtility::extPath('foo', 'bar.txt'));
        }
 
-       /**
-        * @test
-        * @expectedException \BadFunctionCallException
-        */
-       public function extPathThrowsExceptionIfExtensionIsNotLoadedAndTypo3LoadedExtensionsIsEmpty() {
-               unset($GLOBALS['TYPO3_LOADED_EXT']);
-               $GLOBALS['TYPO3_CONF_VARS']['EXT']['requiredExt'] = '';
-               ExtensionManagementUtility::extPath('bar');
-       }
-
-       /**
-        * @test
-        */
-       public function extPathSearchesForPathOfExtensionInRequiredExtensionList() {
-               $this->setExpectedException('BadFunctionCallException', '', 1365429656);
-               unset($GLOBALS['TYPO3_LOADED_EXT']);
-               $GLOBALS['TYPO3_CONF_VARS']['EXT']['requiredExt'] = 'foo';
-               ExtensionManagementUtility::extPath('foo');
-       }
-
-       /**
-        * @test
-        */
-       public function extPathSearchesForPathOfExtensionInExtList() {
-               $this->setExpectedException('BadFunctionCallException', '', 1365429656);
-               unset($GLOBALS['TYPO3_LOADED_EXT']);
-               $GLOBALS['TYPO3_CONF_VARS']['EXT']['requiredExt'] = '';
-               ExtensionManagementUtility::extPath('foo');
-       }
-
        //////////////////////
        // Utility functions
        //////////////////////
@@ -1259,66 +1230,33 @@ class ExtensionManagementUtilityTest extends \TYPO3\CMS\Core\Tests\UnitTestCase
         * @expectedException \RuntimeException
         */
        public function unloadExtensionThrowsExceptionIfExtensionIsNotLoaded() {
-               $className = uniqid('ExtensionManagementUtility');
-               eval(
-                       'namespace ' . __NAMESPACE__ . ';' .
-                       'class ' . $className . ' extends \\TYPO3\\CMS\\Core\\Utility\\ExtensionManagementUtility {' .
-                       '  public static function isLoaded() {' .
-                       '    return FALSE;' .
-                       '  }' .
-                       '}'
-               );
-               $className = __NAMESPACE__ . '\\' . $className;
-               $className::unloadExtension('test');
-       }
-
-       /**
-        * @test
-        * @expectedException \RuntimeException
-        */
-       public function unloadExtensionThrowsExceptionIfExtensionIsRequired() {
-               $extensionKey = uniqid('test');
-               $className = uniqid('ExtensionManagementUtility');
-               eval(
-                       'namespace ' . __NAMESPACE__ . ';' .
-                       'class ' . $className . ' extends \\TYPO3\\CMS\\Core\\Utility\\ExtensionManagementUtility {' .
-                       '  public static function isLoaded() {' .
-                       '    return TRUE;' .
-                       '  }' .
-                       '  public static function getRequiredExtensionListArray() {' .
-                       '    return array(\'' . $extensionKey . '\');' .
-                       '  }' .
-                       '}'
-               );
-               $className = __NAMESPACE__ . '\\' . $className;
-               $className::unloadExtension($extensionKey);
+               $packageName = uniqid('foo');
+               $packageManager = $this->getMock('TYPO3\\CMS\\Core\\Package\\PackageManager', array('isPackageActive'));
+               $packageManager->expects($this->once())
+                       ->method('isPackageActive')
+                       ->with($this->equalTo($packageName))
+                       ->will($this->returnValue(FALSE));
+               ExtensionManagementUtility::setPackageManager($packageManager);
+               ExtensionManagementUtility::unloadExtension($packageName);
        }
 
        /**
         * @test
-        * @expectedException \RuntimeException
         */
-       public function unloadExtensionRemovesExtensionFromExtList() {
-               if (!file_exists((PATH_typo3conf . 'LocalConfiguration.php'))) {
-                       $this->markTestSkipped('Test is not available until update wizard to transform localconf.php was run.');
-               }
-               $extensionKeyToUnload = uniqid('unloadMe');
-               $className = uniqid('ExtensionManagementUtility');
-               eval(
-                       'namespace ' . __NAMESPACE__ . ';' .
-                       'class ' . $className . ' extends \\TYPO3\\CMS\\Core\\Utility\\ExtensionManagementUtility {' .
-                       '  public static function isLoaded() {' .
-                       '    return TRUE;' .
-                       '  }' .
-                       '  public static function writeNewExtensionList($extList) {' .
-                       '    if (!in_array(' . $extensionKeyToUnload . ', $extList)) {' .
-                       '      throw new \\RuntimeException(\'test\');' .
-                       '    }' .
-                       '  }' .
-                       '}'
+       public function unloadExtensionCallsPackageManagerToDeactivatePackage() {
+               $packageName = uniqid('foo');
+               $packageManager = $this->getMock(
+                       'TYPO3\\CMS\\Core\\Package\\PackageManager',
+                       array('isPackageActive', 'deactivatePackage')
                );
-               $className = __NAMESPACE__ . '\\' . $className;
-               $className::unloadExtension($extensionKeyToUnload);
+               $packageManager->expects($this->any())
+                       ->method('isPackageActive')
+                       ->will($this->returnValue(TRUE));
+               $packageManager->expects($this->once())
+                       ->method('deactivatePackage')
+                       ->with($packageName);
+               ExtensionManagementUtility::setPackageManager($packageManager);
+               ExtensionManagementUtility::unloadExtension($packageName);
        }
 
        /////////////////////////////////////////
index 51db261..749c51a 100644 (file)
@@ -45,10 +45,11 @@ class ToggleExtensionInstallationStateViewHelper extends \TYPO3\CMS\Fluid\ViewHe
         * @return string the rendered a tag
         */
        public function render($extension) {
-               $requiredExtensions = \TYPO3\CMS\Core\Utility\ExtensionManagementUtility::getRequiredExtensionListArray();
-
-               // Required extensions can't be deactivated, these are always activated
-               if (in_array($extension['key'], $requiredExtensions)) {
+               // Early return if package is protected and can not be unloaded
+               /** @var $packageManager \TYPO3\CMS\Core\Package\PackageManager */
+               $packageManager = $this->objectManager->get('TYPO3\\CMS\\Core\\Package\\PackageManager');
+               $package = $packageManager->getPackage($extension['key']);
+               if ($package->isProtected()) {
                        return '';
                }
 
index 0bd53f1..7f8f9b3 100644 (file)
@@ -306,7 +306,6 @@ class StepController extends AbstractController {
                                'EXT' => array(
                                        'extListArray' => '__UNSET',
                                        'extList' => '__UNSET',
-                                       'requiredExt' => '__UNSET',
                                ),
                        ));
 
index a9e2ba3..e976f68 100644 (file)
@@ -75,6 +75,8 @@ class SilentConfigurationUpgradeService {
                'EXT/extList_FE',
                // #41813
                'EXT/noEdit',
+               // #47018
+               'EXT/requiredExt',
                // #26090
                'FE/defaultTypoScript_editorcfg',
                'FE/defaultTypoScript_editorcfg.',