From 8c24765d1e730bad2a0d1f193328af872367ab6c Mon Sep 17 00:00:00 2001
From: Nicole Cordes <typo3@cordes.co>
Date: Tue, 3 Mar 2015 15:10:12 +0100
Subject: [PATCH] [BUGFIX] Reload extension list after update

If an extension was updated the list should be reloaded to show
update information.

Releases: master, 6.2
Resolves: #64733
Change-Id: I27598995fd365745eab14a1e095fd342cd198093
Reviewed-on: http://review.typo3.org/37502
Reviewed-by: Andreas Fernandez <andreas.fernandez@aspedia.de>
Tested-by: Andreas Fernandez <andreas.fernandez@aspedia.de>
Reviewed-by: Wouter Wolters <typo3@wouterwolters.nl>
Tested-by: Wouter Wolters <typo3@wouterwolters.nl>
---
 .../Classes/Controller/DownloadController.php | 17 +++++-----
 .../Resources/Private/Language/locallang.xlf  |  5 ++-
 .../Templates/Download/UpdateExtension.json   |  5 ---
 .../Resources/Public/JavaScript/Main.js       | 32 ++-----------------
 4 files changed, 14 insertions(+), 45 deletions(-)
 delete mode 100644 typo3/sysext/extensionmanager/Resources/Private/Templates/Download/UpdateExtension.json

diff --git a/typo3/sysext/extensionmanager/Classes/Controller/DownloadController.php b/typo3/sysext/extensionmanager/Classes/Controller/DownloadController.php
index 4445435f7bb1..1d6d661d01ea 100644
--- a/typo3/sysext/extensionmanager/Classes/Controller/DownloadController.php
+++ b/typo3/sysext/extensionmanager/Classes/Controller/DownloadController.php
@@ -177,23 +177,22 @@ class DownloadController extends AbstractController {
 	 * already. This method should only be called if we are sure that there is
 	 * an update.
 	 *
-	 * @return void
+	 * @return string
 	 */
 	protected function updateExtensionAction() {
-		$hasErrors = FALSE;
-		$errorMessage = '';
-
 		$extensionKey = $this->request->getArgument('extension');
 		$highestTerVersionExtension = $this->extensionRepository->findHighestAvailableVersion($extensionKey);
 		try {
 			$this->managementService->downloadMainExtension($highestTerVersionExtension);
+			$this->addFlashMessage(
+				htmlspecialchars($this->translate('extensionList.updateFlashMessage.body', array($extensionKey))),
+				$this->translate('extensionList.updateFlashMessage.title')
+			);
 		} catch (\Exception $e) {
-			$hasErrors = TRUE;
-			$errorMessage = $e->getMessage();
+			$this->addFlashMessage(htmlspecialchars($e->getMessage()), '', \TYPO3\CMS\Core\Messaging\FlashMessage::ERROR);
 		}
-		$this->view->assign('extension', $highestTerVersionExtension)
-			->assign('hasErrors', $hasErrors)
-			->assign('errorMessage', $errorMessage);
+
+		return '';
 	}
 
 	/**
diff --git a/typo3/sysext/extensionmanager/Resources/Private/Language/locallang.xlf b/typo3/sysext/extensionmanager/Resources/Private/Language/locallang.xlf
index 42b5a007abf0..6bf4bd0f9e11 100644
--- a/typo3/sysext/extensionmanager/Resources/Private/Language/locallang.xlf
+++ b/typo3/sysext/extensionmanager/Resources/Private/Language/locallang.xlf
@@ -213,9 +213,12 @@
 			<trans-unit id="extensionList.updateFlashMessage.title" xml:space="preserve">
 				<source>Extension Update</source>
 			</trans-unit>
-			<trans-unit id="extensionList.updateFlashMessage.message" xml:space="preserve">
+			<trans-unit id="extensionList.updateFlashMessage.message" xml:space="preserve" deprecated="Unused since CMS 6.2">
 				<source>{0} updated!</source>
 			</trans-unit>
+			<trans-unit id="extensionList.updateFlashMessage.body" xml:space="preserve">
+				<source>%s was updated!</source>
+			</trans-unit>
 			<trans-unit id="extensionList.removalConfirmation.question" xml:space="preserve">
 				<source>Are you sure you want to remove the extension?</source>
 			</trans-unit>
diff --git a/typo3/sysext/extensionmanager/Resources/Private/Templates/Download/UpdateExtension.json b/typo3/sysext/extensionmanager/Resources/Private/Templates/Download/UpdateExtension.json
deleted file mode 100644
index 4195df6f07f4..000000000000
--- a/typo3/sysext/extensionmanager/Resources/Private/Templates/Download/UpdateExtension.json
+++ /dev/null
@@ -1,5 +0,0 @@
-{namespace em=TYPO3\CMS\Extensionmanager\ViewHelpers}
-<em:format.jsonEncode additionalAttributes="{extension:extension.extensionKey,
-errorMessage:errorMessage,
-hasErrors:hasErrors
-}" />
\ No newline at end of file
diff --git a/typo3/sysext/extensionmanager/Resources/Public/JavaScript/Main.js b/typo3/sysext/extensionmanager/Resources/Public/JavaScript/Main.js
index 399b1be71950..df90a015e68d 100644
--- a/typo3/sysext/extensionmanager/Resources/Public/JavaScript/Main.js
+++ b/typo3/sysext/extensionmanager/Resources/Public/JavaScript/Main.js
@@ -216,36 +216,8 @@ define(['jquery', 'datatables', 'jquery/jquery.clearable'], function($) {
 							beforeSend: function() {
 								$extManager.mask();
 							},
-							success: function(data) {
-								if (data.hasErrors) {
-									top.TYPO3.Flashmessage.display(
-										top.TYPO3.Severity.error,
-										TYPO3.lang['downloadExtension.updateExtension.error'],
-										data.errorMessage,
-										15
-									);
-									$extManager.unmask();
-								} else {
-									top.TYPO3.Flashmessage.display(
-										top.TYPO3.Severity.info,
-										TYPO3.lang['extensionList.updateFlashMessage.title'],
-										TYPO3.lang['extensionList.updateFlashMessage.message'].replace(/\{0\}/g, data.extension),
-										15
-									);
-									location.reload();
-								}
-							},
-							error: function(jqXHR, textStatus, errorThrown) {
-								// Create an error message with diagnosis info.
-								var errorMessage = textStatus + '(' + errorThrown + '): ' + jqXHR.responseText;
-
-								top.TYPO3.Flashmessage.display(
-									top.TYPO3.Severity.error,
-									TYPO3.lang['downloadExtension.updateExtension.error'],
-									errorMessage,
-									15
-								);
-								$extManager.unmask();
+							complete: function() {
+								location.reload();
 							}
 						});
 						top.TYPO3.Modal.dismiss();
-- 
GitLab