[BUGFIX] Extensionmanager does not show error messages on update failure 38/28738/5
authorPhilipp Gampe <philipp.gampe@typo3.org>
Tue, 25 Mar 2014 02:13:49 +0000 (03:13 +0100)
committerMarkus Klein <klein.t3@mfc-linz.at>
Tue, 29 Apr 2014 22:15:05 +0000 (00:15 +0200)
The extension manager fails to show any error message if an extension
update fails.

Convert exceptions (e.g. dependency fails, TER download fails) into a
nice flashmessage.
Convert any server errors (uncatchable PHP errors) into a flashmessage.

Resolves: #56823
Releases: 6.2, 6.1
Change-Id: Ife3c6d3dcd23177ba22192dd6ae720352931b538
Reviewed-on: https://review.typo3.org/28738
Reviewed-by: Wouter Wolters
Tested-by: Wouter Wolters
Reviewed-by: Jost Baron
Reviewed-by: Markus Klein
Tested-by: Markus Klein
typo3/sysext/extensionmanager/Classes/Controller/DownloadController.php
typo3/sysext/extensionmanager/Resources/Private/Language/locallang.xlf
typo3/sysext/extensionmanager/Resources/Private/Templates/Download/UpdateExtension.json
typo3/sysext/extensionmanager/Resources/Public/JavaScript/main.js

index d4ee7ff..6af67bb 100644 (file)
@@ -161,11 +161,23 @@ class DownloadController extends \TYPO3\CMS\Extensionmanager\Controller\Abstract
         * @return void
         */
        protected function updateExtensionAction() {
+               $hasErrors = FALSE;
+               $errorMessage = '';
+               $result = array();
+
                $extensionKey = $this->request->getArgument('extension');
                /** @var $highestTerVersionExtension \TYPO3\CMS\Extensionmanager\Domain\Model\Extension */
                $highestTerVersionExtension = $this->extensionRepository->findHighestAvailableVersion($extensionKey);
-               $result = $this->managementService->resolveDependenciesAndInstall($highestTerVersionExtension);
-               $this->view->assign('result', $result)->assign('extension', $highestTerVersionExtension);
+               try {
+                       $result = $this->managementService->resolveDependenciesAndInstall($highestTerVersionExtension);
+               } catch (\Exception $e) {
+                       $hasErrors = TRUE;
+                       $errorMessage = $e->getMessage();
+               }
+               $this->view->assign('result', $result)
+                       ->assign('extension', $highestTerVersionExtension)
+                       ->assign('hasErrors', $hasErrors)
+                       ->assign('errorMessage', $errorMessage);
        }
 
        /**
index cdcd34d..3091049 100644 (file)
                        <trans-unit id="downloadExtension.dependencyType.install" xml:space="preserve">
                                <source>install</source>
                        </trans-unit>
+                       <trans-unit id="downloadExtension.updateExtension.error" xml:space="preserve">
+                               <source>Error while updating extension</source>
+                       </trans-unit>
                        <trans-unit id="extensionList.dependenciesResolveDownloadError.title" xml:space="preserve">
                                <source>Download Error</source>
                        </trans-unit>
index 35f50e8..4195df6 100644 (file)
@@ -1,2 +1,5 @@
 {namespace em=TYPO3\CMS\Extensionmanager\ViewHelpers}
-<em:format.jsonEncode additionalAttributes="{extension:extension.extensionKey}" />
\ No newline at end of file
+<em:format.jsonEncode additionalAttributes="{extension:extension.extensionKey,
+errorMessage:errorMessage,
+hasErrors:hasErrors
+}" />
\ No newline at end of file
index c85801e..d258638 100644 (file)
                                                url: dialog.url,
                                                dataType: 'json',
                                                success: function(data) {
+                                                       if (data.hasErrors) {
+                                                               TYPO3.Flashmessage.display(
+                                                                       TYPO3.Severity.error,
+                                                                       TYPO3.l10n.localize('downloadExtension.updateExtension.error'),
+                                                                       data.errorMessage,
+                                                                       15
+                                                               );
+                                                       } else {
+                                                               TYPO3.Flashmessage.display(
+                                                                       TYPO3.Severity.information,
+                                                                       TYPO3.l10n.localize('extensionList.updateFlashMessage.title'),
+                                                                       TYPO3.l10n.localize('extensionList.updateFlashMessage.message').replace(/\{0\}/g, data.extension),
+                                                                       15
+                                                               );
+                                                       }
+                                                       $('.typo3-extension-manager').unmask();
+                                               },
+                                               error: function(jqXHR, textStatus, errorThrown) {
+                                                       // Create an error message with diagnosis info.
+                                                       var errorMessage = textStatus + '(' + errorThrown + '): ' + jqXHR.responseText;
+
+                                                       TYPO3.Flashmessage.display(
+                                                               TYPO3.Severity.error,
+                                                               TYPO3.l10n.localize('downloadExtension.updateExtension.error'),
+                                                               errorMessage,
+                                                               15
+                                                       );
                                                        $('.typo3-extension-manager').unmask();
-                                                       TYPO3.Flashmessage.display(TYPO3.Severity.information, TYPO3.l10n.localize('extensionList.updateFlashMessage.title'),
-                                                                       TYPO3.l10n.localize('extensionList.updateFlashMessage.message').replace(/\{0\}/g, data.extension), 15);
                                                }
                                        });
                                } else {