[BUGFIX] Uninstall extension with dependency throws Exception 79/22579/2
authorWouter Wolters <typo3@wouterwolters.nl>
Tue, 9 Jul 2013 16:49:02 +0000 (18:49 +0200)
committerStefan Neufeind <typo3.neufeind@speedpartner.de>
Thu, 25 Jul 2013 22:21:56 +0000 (00:21 +0200)
Exception is thrown if uninstalling an extension with
dependecies on that extension. Catch the exception and
show a nice Flashmessage.

Change-Id: I434a4e1e1d83f43a6f5d4c99a82433e35ddd92f9
Resolves: #49722
Releases: 6.2, 6.1, 6.0
Reviewed-on: https://review.typo3.org/22579
Reviewed-by: Stefan Neufeind
Tested-by: Stefan Neufeind
typo3/sysext/extensionmanager/Classes/Controller/ActionController.php
typo3/sysext/extensionmanager/Classes/Utility/InstallUtility.php
typo3/sysext/extensionmanager/Resources/Private/Language/locallang.xlf
typo3/sysext/extensionmanager/Resources/Private/Templates/List/Index.html

index 9a8243a..335d61a 100644 (file)
@@ -79,7 +79,18 @@ class ActionController extends \TYPO3\CMS\Extensionmanager\Controller\AbstractCo
                $installedExtensions = \TYPO3\CMS\Core\Utility\ExtensionManagementUtility::getLoadedExtensionListArray();
                if (in_array($extension, $installedExtensions)) {
                        // uninstall
-                       $this->installUtility->uninstall($extension);
+                       try {
+                               $this->installUtility->uninstall($extension);
+                       } catch (\TYPO3\CMS\Extensionmanager\Exception\ExtensionManagerException $e) {
+                               $flashMessage = \TYPO3\CMS\Core\Utility\GeneralUtility::makeInstance(
+                                       'TYPO3\\CMS\\Core\\Messaging\\FlashMessage',
+                                       htmlspecialchars($e->getMessage()),
+                                       '',
+                                       \TYPO3\CMS\Core\Messaging\FlashMessage::ERROR,
+                                       TRUE
+                               );
+                               $this->getControllerContext()->getFlashMessageQueue()->enqueue($flashMessage);
+                       }
                } else {
                        // install
                        $this->managementService->resolveDependenciesAndInstall(
@@ -138,4 +149,4 @@ class ActionController extends \TYPO3\CMS\Extensionmanager\Controller\AbstractCo
                $this->fileHandlingUtility->sendSqlDumpFileToBrowserAndDelete($filePath, $fileName);
        }
 }
-?>
\ No newline at end of file
+?>
index 32df00d..119c6a0 100644 (file)
@@ -153,7 +153,14 @@ class InstallUtility implements \TYPO3\CMS\Core\SingletonInterface {
        public function uninstall($extensionKey) {
                $dependentExtensions = $this->dependencyUtility->findInstalledExtensionsThatDependOnMe($extensionKey);
                if (is_array($dependentExtensions) && count($dependentExtensions) > 0) {
-                       throw new \TYPO3\CMS\Extensionmanager\Exception\ExtensionManagerException('Cannot deactivate extension ' . $extensionKey . ' - The extension(s) ' . implode(',', $dependentExtensions) . ' depend on it', 1342554622);
+                       throw new \TYPO3\CMS\Extensionmanager\Exception\ExtensionManagerException(
+                               \TYPO3\CMS\Extbase\Utility\LocalizationUtility::translate(
+                                       'extensionList.uninstall.dependencyError',
+                                       'extensionmanager',
+                                       array($extensionKey, implode(',', $dependentExtensions))
+                               ),
+                               1342554622
+                       );
                } else {
                        $this->unloadExtension($extensionKey);
                }
@@ -411,4 +418,4 @@ class InstallUtility implements \TYPO3\CMS\Core\SingletonInterface {
 }
 
 
-?>
\ No newline at end of file
+?>
index c8bca28..3f66fe2 100644 (file)
                        <trans-unit id="extensionList.updateFromTer.never" xml:space="preserve">
                                <source>Never</source>
                        </trans-unit>
+                       <trans-unit id="extensionList.uninstall.dependencyError" xml:space="preserve">
+                               <source>Cannot deactivate extension '%s' - The extension(s) '%s' depend on it.</source>
+                       </trans-unit>
 
                        <trans-unit id="task.updateExtensionListTask.name" xml:space="preserve">
                                <source>Update extension list</source>
index 067a5d4..77d8638 100644 (file)
@@ -11,6 +11,8 @@
 </f:section>
 
 <f:section name="Content">
+       <f:flashMessages renderMode="div" />
+
        <div class="uploadForm" style="display: none;">
                <span class="spinner"></span>
                <f:translate key="extensionList.loading"/>