[BUGFIX] IRRE actions should render error messages from DataHandler 09/54809/2
authorBenni Mack <benni@typo3.org>
Thu, 16 Nov 2017 11:05:03 +0000 (12:05 +0100)
committerWouter Wolters <typo3@wouterwolters.nl>
Mon, 27 Nov 2017 22:39:48 +0000 (23:39 +0100)
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/54809
Tested-by: TYPO3com <no-reply@typo3.com>
Reviewed-by: Wouter Wolters <typo3@wouterwolters.nl>
Tested-by: Wouter Wolters <typo3@wouterwolters.nl>
typo3/sysext/backend/Classes/Controller/FormInlineAjaxController.php
typo3/sysext/backend/Resources/Public/JavaScript/jsfunc.inline.js

index 072b706..d2d2eba 100644 (file)
@@ -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;
@@ -363,6 +365,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) {
index 3e2f232..66f6ef4 100644 (file)
@@ -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) {