[TASK] Cleanup EM Code
authorHelmut Hummel <helmut.hummel@typo3.org>
Thu, 18 Oct 2012 16:01:44 +0000 (18:01 +0200)
committerHelmut Hummel <helmut.hummel@typo3.org>
Fri, 19 Oct 2012 14:52:27 +0000 (16:52 +0200)
* Use controller arguments for actions
* Add escaping in viewhelpers
* Remove compatibility files
* Fix some annotations
* Enable test after ConfigurationManager change
* Fix new property mapper configuration

Releases: 6.0
Resolves: #42163

Change-Id: Ida9010e2eb00013c3a3e855983b58bb7df38c30d
Reviewed-on: http://review.typo3.org/15803
Reviewed-by: Philipp Gampe
Tested-by: Philipp Gampe
Reviewed-by: Helmut Hummel
Tested-by: Helmut Hummel
17 files changed:
typo3/sysext/core/Tests/BaseTestCase.php
typo3/sysext/extensionmanager/Classes/Controller/ActionController.php
typo3/sysext/extensionmanager/Classes/Utility/Configuration.php [deleted file]
typo3/sysext/extensionmanager/Classes/Utility/Database.php [deleted file]
typo3/sysext/extensionmanager/Classes/Utility/Dependency.php [deleted file]
typo3/sysext/extensionmanager/Classes/Utility/Download.php [deleted file]
typo3/sysext/extensionmanager/Classes/Utility/EmConf.php [deleted file]
typo3/sysext/extensionmanager/Classes/Utility/FileHandling.php [deleted file]
typo3/sysext/extensionmanager/Classes/Utility/Importer/ExtensionList.php [deleted file]
typo3/sysext/extensionmanager/Classes/Utility/Importer/MirrorList.php [deleted file]
typo3/sysext/extensionmanager/Classes/Utility/Install.php [deleted file]
typo3/sysext/extensionmanager/Classes/Utility/List.php [deleted file]
typo3/sysext/extensionmanager/Classes/ViewHelpers/ConfigureExtensionViewHelper.php
typo3/sysext/extensionmanager/Classes/ViewHelpers/DownloadExtensionDataViewHelper.php
typo3/sysext/extensionmanager/Classes/ViewHelpers/DownloadExtensionViewHelper.php
typo3/sysext/extensionmanager/Tests/Unit/Domain/Repository/ConfigurationItemRepositoryTest.php
typo3/sysext/extensionmanager/ext_typoscript_setup.txt

index 94faa77..ca410a6 100644 (file)
@@ -65,10 +65,10 @@ abstract class BaseTestCase extends \PHPUnit_Framework_TestCase {
         * @param boolean $callOriginalClone whether to call the __clone method
         * @param boolean $callAutoload whether to call any autoload function
         *
-        * @return PHPUnit_Framework_MockObject_MockObject|AccessibleObjectInterface
+        * @return \PHPUnit_Framework_MockObject_MockObject|AccessibleObjectInterface
         *         a mock of $originalClassName with access methods added
         *
-        * @see Tx_Extbase_Tests_Unit_BaseTestCase::getAccessibleMock
+        * @see \TYPO3\CMS\Extbase\Tests\Unit\BaseTestCase::getAccessibleMock
         */
        protected function getAccessibleMock(
                $originalClassName, array $methods = array(), array $arguments = array(), $mockClassName = '',
index 04a7f0c..a168941 100644 (file)
@@ -42,44 +42,31 @@ class ActionController extends \TYPO3\CMS\Extensionmanager\Controller\AbstractCo
        protected $installUtility;
 
        /**
+        * @var \TYPO3\CMS\Extensionmanager\Utility\FileHandlingUtility
+        */
+       protected $fileHandlingUtility;
+
+       /**
         * @param \TYPO3\CMS\Extensionmanager\Utility\InstallUtility $installUtility
-        * @return void
         */
        public function injectInstallUtility(\TYPO3\CMS\Extensionmanager\Utility\InstallUtility $installUtility) {
                $this->installUtility = $installUtility;
        }
 
        /**
-        * @var \TYPO3\CMS\Extensionmanager\Utility\FileHandlingUtility
-        */
-       protected $fileHandlingUtility;
-
-       /**
         * @param \TYPO3\CMS\Extensionmanager\Utility\FileHandlingUtility $fileHandlingUtility
-        * @return void
         */
        public function injectFileHandlingUtility(\TYPO3\CMS\Extensionmanager\Utility\FileHandlingUtility $fileHandlingUtility) {
                $this->fileHandlingUtility = $fileHandlingUtility;
        }
 
        /**
-        * @throws \TYPO3\CMS\Extensionmanager\Exception\ExtensionManagerException
-        * @return void
-        */
-       public function initializeAction() {
-               if (!$this->request->hasArgument('extension')) {
-                       throw new \TYPO3\CMS\Extensionmanager\Exception\ExtensionManagerException('Required argument extension not set!', 1342874433);
-               }
-       }
-
-       /**
         * Toggle extension installation state action
         *
-        * @return void
+        * @param string $extension
         */
-       protected function toggleExtensionInstallationStateAction() {
+       protected function toggleExtensionInstallationStateAction($extension) {
                $installedExtensions = \TYPO3\CMS\Core\Extension\ExtensionManager::getLoadedExtensionListArray();
-               $extension = $this->request->getArgument('extension');
                if (in_array($extension, $installedExtensions)) {
                        // uninstall
                        $this->installUtility->uninstall($extension);
@@ -93,12 +80,11 @@ class ActionController extends \TYPO3\CMS\Extensionmanager\Controller\AbstractCo
        /**
         * Remove an extension (if it is still installed, uninstall it first)
         *
-        * @return void
+        * @param string $extension
         */
-       protected function removeExtensionAction() {
+       protected function removeExtensionAction($extension) {
                $success = TRUE;
                $message = '';
-               $extension = $this->request->getArgument('extension');
                try {
                        if (\TYPO3\CMS\Core\Extension\ExtensionManager::isLoaded($extension)) {
                                $this->installUtility->uninstall($extension);
@@ -114,10 +100,9 @@ class ActionController extends \TYPO3\CMS\Extensionmanager\Controller\AbstractCo
        /**
         * Download an extension as a zip file
         *
-        * @return void
+        * @param string $extension
         */
-       protected function downloadExtensionZipAction() {
-               $extension = $this->request->getArgument('extension');
+       protected function downloadExtensionZipAction($extension) {
                $fileName = $this->fileHandlingUtility->createZipFileFromExtension($extension);
                $this->fileHandlingUtility->sendZipFileToBrowserAndDelete($fileName);
        }
@@ -125,12 +110,11 @@ class ActionController extends \TYPO3\CMS\Extensionmanager\Controller\AbstractCo
        /**
         * Download data of an extension as sql statements
         *
+        * @param string $extension
         * @throws \TYPO3\CMS\Extensionmanager\Exception\ExtensionManagerException
-        * @return void
         */
-       protected function downloadExtensionDataAction() {
+       protected function downloadExtensionDataAction($extension) {
                $error = NULL;
-               $extension = $this->request->getArgument('extension');
                $sqlData = $this->installUtility->getExtensionSqlDataDump($extension);
                $dump = $sqlData['extTables'] . $sqlData['staticSql'];
                $fileName = $extension . '_sqlDump.sql';
@@ -141,8 +125,5 @@ class ActionController extends \TYPO3\CMS\Extensionmanager\Controller\AbstractCo
                }
                $this->fileHandlingUtility->sendSqlDumpFileToBrowserAndDelete($filePath, $fileName);
        }
-
 }
-
-
 ?>
\ No newline at end of file
diff --git a/typo3/sysext/extensionmanager/Classes/Utility/Configuration.php b/typo3/sysext/extensionmanager/Classes/Utility/Configuration.php
deleted file mode 100644 (file)
index 2e150a3..0000000
+++ /dev/null
@@ -1,8 +0,0 @@
-<?php
-/*
- * @deprecated since 6.0, the classname Tx_Extensionmanager_Utility_Configuration and this file is obsolete
- * and will be removed by 7.0. The class was renamed and is now located at:
- * typo3/sysext/extensionmanager/Classes/Utility/ConfigurationUtility.php
- */
-require_once \TYPO3\CMS\Core\Extension\ExtensionManager::extPath('extensionmanager') . 'Classes/Utility/ConfigurationUtility.php';
-?>
\ No newline at end of file
diff --git a/typo3/sysext/extensionmanager/Classes/Utility/Database.php b/typo3/sysext/extensionmanager/Classes/Utility/Database.php
deleted file mode 100644 (file)
index 0eb924d..0000000
+++ /dev/null
@@ -1,8 +0,0 @@
-<?php
-/*
- * @deprecated since 6.0, the classname Tx_Extensionmanager_Utility_Database and this file is obsolete
- * and will be removed by 7.0. The class was renamed and is now located at:
- * typo3/sysext/extensionmanager/Classes/Utility/DatabaseUtility.php
- */
-require_once \TYPO3\CMS\Core\Extension\ExtensionManager::extPath('extensionmanager') . 'Classes/Utility/DatabaseUtility.php';
-?>
\ No newline at end of file
diff --git a/typo3/sysext/extensionmanager/Classes/Utility/Dependency.php b/typo3/sysext/extensionmanager/Classes/Utility/Dependency.php
deleted file mode 100644 (file)
index cde1bc9..0000000
+++ /dev/null
@@ -1,8 +0,0 @@
-<?php
-/*
- * @deprecated since 6.0, the classname Tx_Extensionmanager_Utility_Dependency and this file is obsolete
- * and will be removed by 7.0. The class was renamed and is now located at:
- * typo3/sysext/extensionmanager/Classes/Utility/DependencyUtility.php
- */
-require_once \TYPO3\CMS\Core\Extension\ExtensionManager::extPath('extensionmanager') . 'Classes/Utility/DependencyUtility.php';
-?>
\ No newline at end of file
diff --git a/typo3/sysext/extensionmanager/Classes/Utility/Download.php b/typo3/sysext/extensionmanager/Classes/Utility/Download.php
deleted file mode 100644 (file)
index c28cfd8..0000000
+++ /dev/null
@@ -1,8 +0,0 @@
-<?php
-/*
- * @deprecated since 6.0, the classname Tx_Extensionmanager_Utility_Download and this file is obsolete
- * and will be removed by 7.0. The class was renamed and is now located at:
- * typo3/sysext/extensionmanager/Classes/Utility/DownloadUtility.php
- */
-require_once \TYPO3\CMS\Core\Extension\ExtensionManager::extPath('extensionmanager') . 'Classes/Utility/DownloadUtility.php';
-?>
\ No newline at end of file
diff --git a/typo3/sysext/extensionmanager/Classes/Utility/EmConf.php b/typo3/sysext/extensionmanager/Classes/Utility/EmConf.php
deleted file mode 100644 (file)
index 8ed9c05..0000000
+++ /dev/null
@@ -1,8 +0,0 @@
-<?php
-/*
- * @deprecated since 6.0, the classname Tx_Extensionmanager_Utility_EmConf and this file is obsolete
- * and will be removed by 7.0. The class was renamed and is now located at:
- * typo3/sysext/extensionmanager/Classes/Utility/EmConfUtility.php
- */
-require_once \TYPO3\CMS\Core\Extension\ExtensionManager::extPath('extensionmanager') . 'Classes/Utility/EmConfUtility.php';
-?>
\ No newline at end of file
diff --git a/typo3/sysext/extensionmanager/Classes/Utility/FileHandling.php b/typo3/sysext/extensionmanager/Classes/Utility/FileHandling.php
deleted file mode 100644 (file)
index ba7a649..0000000
+++ /dev/null
@@ -1,8 +0,0 @@
-<?php
-/*
- * @deprecated since 6.0, the classname Tx_Extensionmanager_Utility_FileHandling and this file is obsolete
- * and will be removed by 7.0. The class was renamed and is now located at:
- * typo3/sysext/extensionmanager/Classes/Utility/FileHandlingUtility.php
- */
-require_once \TYPO3\CMS\Core\Extension\ExtensionManager::extPath('extensionmanager') . 'Classes/Utility/FileHandlingUtility.php';
-?>
\ No newline at end of file
diff --git a/typo3/sysext/extensionmanager/Classes/Utility/Importer/ExtensionList.php b/typo3/sysext/extensionmanager/Classes/Utility/Importer/ExtensionList.php
deleted file mode 100644 (file)
index 8b3a49f..0000000
+++ /dev/null
@@ -1,8 +0,0 @@
-<?php
-/*
- * @deprecated since 6.0, the classname Tx_Extensionmanager_Utility_Importer_ExtensionList and this file is obsolete
- * and will be removed by 7.0. The class was renamed and is now located at:
- * typo3/sysext/extensionmanager/Classes/Utility/Importer/ExtensionListUtility.php
- */
-require_once \TYPO3\CMS\Core\Extension\ExtensionManager::extPath('extensionmanager') . 'Classes/Utility/Importer/ExtensionListUtility.php';
-?>
\ No newline at end of file
diff --git a/typo3/sysext/extensionmanager/Classes/Utility/Importer/MirrorList.php b/typo3/sysext/extensionmanager/Classes/Utility/Importer/MirrorList.php
deleted file mode 100644 (file)
index f73b0c5..0000000
+++ /dev/null
@@ -1,8 +0,0 @@
-<?php
-/*
- * @deprecated since 6.0, the classname Tx_Extensionmanager_Utility_Importer_MirrorList and this file is obsolete
- * and will be removed by 7.0. The class was renamed and is now located at:
- * typo3/sysext/extensionmanager/Classes/Utility/Importer/MirrorListUtility.php
- */
-require_once \TYPO3\CMS\Core\Extension\ExtensionManager::extPath('extensionmanager') . 'Classes/Utility/Importer/MirrorListUtility.php';
-?>
\ No newline at end of file
diff --git a/typo3/sysext/extensionmanager/Classes/Utility/Install.php b/typo3/sysext/extensionmanager/Classes/Utility/Install.php
deleted file mode 100644 (file)
index 22bb244..0000000
+++ /dev/null
@@ -1,8 +0,0 @@
-<?php
-/*
- * @deprecated since 6.0, the classname Tx_Extensionmanager_Utility_Install and this file is obsolete
- * and will be removed by 7.0. The class was renamed and is now located at:
- * typo3/sysext/extensionmanager/Classes/Utility/InstallUtility.php
- */
-require_once \TYPO3\CMS\Core\Extension\ExtensionManager::extPath('extensionmanager') . 'Classes/Utility/InstallUtility.php';
-?>
\ No newline at end of file
diff --git a/typo3/sysext/extensionmanager/Classes/Utility/List.php b/typo3/sysext/extensionmanager/Classes/Utility/List.php
deleted file mode 100644 (file)
index 2bbcca6..0000000
+++ /dev/null
@@ -1,8 +0,0 @@
-<?php
-/*
- * @deprecated since 6.0, the classname Tx_Extensionmanager_Utility_List and this file is obsolete
- * and will be removed by 7.0. The class was renamed and is now located at:
- * typo3/sysext/extensionmanager/Classes/Utility/ListUtility.php
- */
-require_once \TYPO3\CMS\Core\Extension\ExtensionManager::extPath('extensionmanager') . 'Classes/Utility/ListUtility.php';
-?>
\ No newline at end of file
index 03f2c0e..2cd0b4a 100644 (file)
@@ -43,7 +43,7 @@ class ConfigureExtensionViewHelper extends \TYPO3\CMS\Fluid\ViewHelpers\Link\Act
        /**
         * Renders a configure extension link if the extension has configuration options
         *
-        * @param string $extension
+        * @param array $extension
         * @return string the rendered a tag
         */
        public function render($extension) {
index 4742530..e9ca088 100644 (file)
@@ -43,7 +43,7 @@ class DownloadExtensionDataViewHelper extends \TYPO3\CMS\Fluid\ViewHelpers\Link\
        /**
         * Renders an install link
         *
-        * @param string $extension
+        * @param array $extension
         * @return string the rendered a tag
         */
        public function render($extension) {
index 78c8e30..be35b82 100644 (file)
@@ -51,8 +51,8 @@ class DownloadExtensionViewHelper extends \TYPO3\CMS\Fluid\ViewHelpers\FormViewH
                $pathSelector = '<ul>';
                foreach ($installPaths as $installPathType => $installPath) {
                        $pathSelector .= '<li>
-                               <input type="radio" id="' . $extension->getExtensionKey() . '-downloadPath-' . $installPathType . '" name="' . $this->getFieldNamePrefix('downloadPath') . '[downloadPath]" class="downloadPath" value="' . $installPathType . '"' . ($installPathType == 'Local' ? 'checked="checked"' : '') . '/>
-                               <label for="' . $extension->getExtensionKey() . '-downloadPath-' . $installPathType . '">' . $installPathType . '</label>
+                               <input type="radio" id="' . htmlspecialchars($extension->getExtensionKey()) . '-downloadPath-' . htmlspecialchars($installPathType) . '" name="' . htmlspecialchars($this->getFieldNamePrefix('downloadPath')) . '[downloadPath]" class="downloadPath" value="' . htmlspecialchars($installPathType) . '"' . ($installPathType == 'Local' ? 'checked="checked"' : '') . '/>
+                               <label for="' . htmlspecialchars($extension->getExtensionKey()) . '-downloadPath-' . htmlspecialchars($installPathType) . '">' . htmlspecialchars($installPathType) . '</label>
                        </li>';
                }
                $pathSelector .= '</ul>';
@@ -61,13 +61,13 @@ class DownloadExtensionViewHelper extends \TYPO3\CMS\Fluid\ViewHelpers\FormViewH
                $uriBuilder->reset();
                $uriBuilder->setFormat('json');
                $uri = $uriBuilder->uriFor($action, array(
-                       'extension' => $extension->getUid()
+                       'extension' => (int)$extension->getUid()
                ), 'Download');
                $this->tag->addAttribute('href', $uri);
                $label = '<input type="submit" value="' . \TYPO3\CMS\Extbase\Utility\LocalizationUtility::translate('extensionList.downloadViewHelper.submit', 'extensionmanager') . '" />';
                $this->tag->setContent($label . $pathSelector);
                $this->tag->addAttribute('class', 'download');
-               return '<div id="' . $extension->getExtensionKey() . '-downloadFromTer" class="downloadFromTer">' . $this->tag->render() . '</div>';
+               return '<div id="' . htmlspecialchars($extension->getExtensionKey()) . '-downloadFromTer" class="downloadFromTer">' . $this->tag->render() . '</div>';
        }
 
 }
index f44337e..e7bb3e1 100644 (file)
@@ -38,7 +38,7 @@ class ConfigurationItemRepositoryTest extends \TYPO3\CMS\Extbase\Tests\Unit\Base
        protected $backupGlobals = TRUE;
 
        /**
-        * @var \TYPO3\CMS\Extensionmanager\Domain\Repository\ConfigurationItemRepository
+        * @var \TYPO3\CMS\Extensionmanager\Domain\Repository\ConfigurationItemRepository|\TYPO3\CMS\Core\Tests\AccessibleObjectInterface
         */
        public $configurationItemRepository;
 
@@ -55,7 +55,7 @@ class ConfigurationItemRepositoryTest extends \TYPO3\CMS\Extbase\Tests\Unit\Base
                        'TYPO3\\CMS\\Core\\Configuration\\ConfigurationManager',
                        array('dummy')
                );
-               $this->configurationItemRepository->_set('configurationManager', $configurationManagerMock);
+               $this->configurationItemRepository->injectConfigurationManager($configurationManagerMock);
        }
 
        /**
@@ -221,18 +221,25 @@ class ConfigurationItemRepositoryTest extends \TYPO3\CMS\Extbase\Tests\Unit\Base
         * @return void
         */
        public function mergeWithExistingConfigurationOverwritesDefaultKeysWithCurrent() {
-               $this->markTestSkipped('Skipped this test until ConfigurationManager is made non static.');
+               $configurationManagerMock = $this->getAccessibleMock(
+                       'TYPO3\\CMS\\Core\\Configuration\\ConfigurationManager');
+               $configurationManagerMock
+                               ->expects($this->once())
+                               ->method('getConfigurationValueByPath')
+                               ->with('EXT/extConf/testextensionkey')
+                               ->will($this->returnValue(
+                                       serialize(array(
+                                               'FE.' => array(
+                                                       'enabled' => '1',
+                                                       'saltedPWHashingMethod' => 'TYPO3\\CMS\\Saltedpasswords\\Salt\\SaltInterface_sha1'
+                                               ),
+                                               'CLI.' => array(
+                                                       'enabled' => '0'
+                                               )
+                                       ))
+                               ));
+               $this->configurationItemRepository->injectConfigurationManager($configurationManagerMock);
 
-               $backupExtConf = $GLOBALS['TYPO3_CONF_VARS']['EXT']['extConf'];
-               $GLOBALS['TYPO3_CONF_VARS']['EXT']['extConf']['testextensionkey'] = serialize(array(
-                       'FE.' => array(
-                               'enabled' => '1',
-                               'saltedPWHashingMethod' => 'TYPO3\\CMS\\Saltedpasswords\\Salt\\SaltInterface_sha1'
-                       ),
-                       'CLI.' => array(
-                               'enabled' => '0'
-                       )
-               ));
                $defaultConfiguration = array(
                        'FE.enabled' => array(
                                'value' => '0'
@@ -264,9 +271,8 @@ class ConfigurationItemRepositoryTest extends \TYPO3\CMS\Extbase\Tests\Unit\Base
                                'value' => '0'
                        )
                );
-               $result = $this->configurationItemRepository->mergeWithExistingConfiguration($defaultConfiguration, array('key' => 'testextensionkey'));
+               $result = $this->configurationItemRepository->_call('mergeWithExistingConfiguration', $defaultConfiguration, array('key' => 'testextensionkey'));
                $this->assertEquals($expectedResult, $result);
-               $GLOBALS['TYPO3_CONF_VARS']['EXT']['extConf'] = $backupExtConf;
        }
 
        /**
index e9f4d63..5208223 100644 (file)
@@ -1,12 +1,11 @@
-config.tx_extbase {
+module.tx_extensionmanager {
+       settings {
+               repositoryUid = 1
+       }
        features {
                 # this enables/disables the reworked property mapper (see http://forge.typo3.org/projects/typo3v4-mvc/wiki/PropertyMapper_rework)
                rewrittenPropertyMapper = 1
                 # if enabled, default controller and/or action is skipped when creating URIs through the URI Builder (see http://forge.typo3.org/projects/typo3v4-mvc/wiki/Skip_default_arguments_in_URIs)
                skipDefaultArguments = 0
        }
-}
-
-module.tx_extensionmanager.settings {
-       repositoryUid = 1
-}
+}
\ No newline at end of file