From 65f634e9fa76aca772f628845f3af078a9fad1f7 Mon Sep 17 00:00:00 2001 From: Benni Mack <benni@typo3.org> Date: Thu, 16 Nov 2017 12:05:03 +0100 Subject: [PATCH] [BUGFIX] IRRE actions should render error messages from DataHandler When IRRE actions (localize/synchronize) are triggered that result in a DataHandler error (e.g. "Localization failed, "languageField" and "transOrigPointerField" must be defined for the table") because of a missing configuration, the current implementation does not evaluate DataHandler results in the JSON response. The change adds the same functionality as for other DataHandler calls to evaluate the JSON response. Resolves: #83011 Releases: master, 8.7 Change-Id: I7a2069b78cd9c3fa031b7ac194ae5b18596b6a3e Reviewed-on: https://review.typo3.org/54659 Tested-by: TYPO3com <no-reply@typo3.com> Reviewed-by: Jan Helke <typo3@helke.de> Tested-by: Jan Helke <typo3@helke.de> Reviewed-by: Tymoteusz Motylewski <t.motylewski@gmail.com> Tested-by: Tymoteusz Motylewski <t.motylewski@gmail.com> --- .../Controller/FormInlineAjaxController.php | 19 +++++++++++++++++++ .../Public/JavaScript/jsfunc.inline.js | 5 +++++ 2 files changed, 24 insertions(+) diff --git a/typo3/sysext/backend/Classes/Controller/FormInlineAjaxController.php b/typo3/sysext/backend/Classes/Controller/FormInlineAjaxController.php index 25c75136b973..be1064f80c89 100644 --- a/typo3/sysext/backend/Classes/Controller/FormInlineAjaxController.php +++ b/typo3/sysext/backend/Classes/Controller/FormInlineAjaxController.php @@ -23,6 +23,8 @@ use TYPO3\CMS\Backend\Form\InlineStackProcessor; use TYPO3\CMS\Backend\Form\NodeFactory; use TYPO3\CMS\Core\Authentication\BackendUserAuthentication; use TYPO3\CMS\Core\DataHandling\DataHandler; +use TYPO3\CMS\Core\Messaging\AbstractMessage; +use TYPO3\CMS\Core\Messaging\FlashMessageService; use TYPO3\CMS\Core\Utility\ArrayUtility; use TYPO3\CMS\Core\Utility\GeneralUtility; use TYPO3\CMS\Core\Utility\MathUtility; @@ -348,6 +350,23 @@ class FormInlineAjaxController extends AbstractFormEngineAjaxController $oldItems = $this->getInlineRelatedRecordsUidArray($oldItemList); $newItems = $this->getInlineRelatedRecordsUidArray($newItemList); + // Render error messages from DataHandler + $tce->printLogErrorMessages(); + $flashMessageService = GeneralUtility::makeInstance(FlashMessageService::class); + $messages = $flashMessageService->getMessageQueueByIdentifier()->getAllMessagesAndFlush(); + if (!empty($messages)) { + foreach ($messages as $message) { + $jsonArray['messages'][] = [ + 'title' => $message->getTitle(), + 'message' => $message->getMessage(), + 'severity' => $message->getSeverity() + ]; + if ($message->getSeverity() === AbstractMessage::ERROR) { + $jsonArray['hasErrors'] = true; + } + } + } + // Set the items that should be removed in the forms view: $removedItems = array_diff($oldItems, $newItems); foreach ($removedItems as $childUid) { diff --git a/typo3/sysext/backend/Resources/Public/JavaScript/jsfunc.inline.js b/typo3/sysext/backend/Resources/Public/JavaScript/jsfunc.inline.js index 51ae6298b43a..cbf9c07eb443 100644 --- a/typo3/sysext/backend/Resources/Public/JavaScript/jsfunc.inline.js +++ b/typo3/sysext/backend/Resources/Public/JavaScript/jsfunc.inline.js @@ -233,6 +233,11 @@ var inline = { if (!json && xhr) { json = xhr.responseJSON; } + if (json.hasErrors) { + $.each(json.messages, function(position, message) { + top.TYPO3.Notification.error(message.title, message.message); + }); + } // If there are elements the should be added to the <HEAD> tag (e.g. for RTEhtmlarea): if (json.stylesheetFiles) { $.each(json.stylesheetFiles, function (index, stylesheetFile) { -- GitLab