From 950e8db735b474caad6234969c4978778620ba36 Mon Sep 17 00:00:00 2001
From: Helmut Hummel <helmut.hummel@typo3.org>
Date: Sat, 7 Nov 2015 01:19:03 +0100
Subject: [PATCH] [TASK] Simplify and unify flash message rendering
MIME-Version: 1.0
Content-Type: text/plain; charset=UTF-8
Content-Transfer-Encoding: 8bit

* Reverts the change that allowed HTML tags by default in flash messages
* Simplifies flash message markup to be bootstrap alert style
* Delegate flash message rendering completely to module template
* Deprecate render method in flash message
* Minor cleanups in flash message view helper and flash message class

Resolves: #71249
Releases: master
Change-Id: Idbb4bc31372fbc435519496168715e0bcc5cebf2
Reviewed-on: https://review.typo3.org/44592
Reviewed-by: Philipp Gampe <philipp.gampe@typo3.org>
Tested-by: Philipp Gampe <philipp.gampe@typo3.org>
Reviewed-by: Frank Nägler <frank.naegler@typo3.org>
Tested-by: Frank Nägler <frank.naegler@typo3.org>
Reviewed-by: Helmut Hummel <helmut.hummel@typo3.org>
Tested-by: Helmut Hummel <helmut.hummel@typo3.org>
---
 .../Less/TYPO3/_module_extensionmanager.less  |  7 ------
 .../Classes/Template/ModuleTemplate.php       | 12 +++++++--
 .../backend/Classes/View/PageLayoutView.php   |  2 +-
 .../Resources/Private/Templates/Module.html   | 19 ++++++++++++--
 .../BackendUserActionController.php           |  1 +
 .../Controller/PermissionController.php       |  5 ++--
 .../Resources/Private/Layouts/Default.html    |  9 -------
 .../Resources/Private/Layouts/Permission.html | 13 ----------
 .../core/Classes/Messaging/FlashMessage.php   | 18 +++++--------
 .../Classes/Messaging/FlashMessageQueue.php   |  8 ++++++
 ...precateRenderMethodOfFlashMessageClass.rst | 22 ++++++++++++++++
 .../Classes/Controller/DocumentController.php |  1 +
 .../Resources/Private/Layouts/Default.html    |  5 ----
 .../Controller/AbstractModuleController.php   |  1 +
 .../Resources/Private/Layouts/Main.html       |  5 ----
 .../Private/Templates/Distribution/Show.html  |  1 -
 .../List/UnresolvedDependencies.html          |  8 +-----
 .../Resources/Private/Layouts/Default.html    |  7 +-----
 .../ViewHelpers/FlashMessagesViewHelper.php   | 14 -----------
 .../Controller/AdministrationController.php   |  1 +
 .../Private/Layouts/Administration.html       |  1 -
 .../Administration/StatisticDetails.html      |  7 +-----
 .../Classes/Controller/LanguageController.php |  2 +-
 .../Templates/Language/ListLanguages.html     |  6 -----
 .../Templates/Language/ListTranslations.html  |  5 ----
 .../Controller/RecyclerModuleController.php   |  1 +
 .../Resources/Private/Layouts/Default.html    |  5 ----
 .../Controller/SchedulerModuleController.php  | 25 +------------------
 .../t3skin/Resources/Public/Css/backend.css   |  6 -----
 ...eObjectBrowserModuleFunctionController.php |  2 +-
 .../Classes/Controller/PreviewController.php  |  1 +
 .../Classes/Controller/ReviewController.php   |  1 +
 .../Resources/Private/Layouts/Module.html     |  7 +-----
 .../Resources/Private/Layouts/Nodoc.html      |  7 ------
 34 files changed, 81 insertions(+), 154 deletions(-)
 create mode 100644 typo3/sysext/core/Documentation/Changelog/master/Deprecation-71249-DeprecateRenderMethodOfFlashMessageClass.rst

diff --git a/Build/Resources/Public/Less/TYPO3/_module_extensionmanager.less b/Build/Resources/Public/Less/TYPO3/_module_extensionmanager.less
index 4f40939c3193..a7f1a659d8ed 100644
--- a/Build/Resources/Public/Less/TYPO3/_module_extensionmanager.less
+++ b/Build/Resources/Public/Less/TYPO3/_module_extensionmanager.less
@@ -121,13 +121,6 @@
 	}
 }
 
-// Distributions detail
-.distribution-detail-flashmessage {
-	margin-bottom: 2.5em;
-	p {
-		padding-bottom: 0;
-	}
-}
 .distribution-detail {
 	.clearfix();
 	min-width: 750px;
diff --git a/typo3/sysext/backend/Classes/Template/ModuleTemplate.php b/typo3/sysext/backend/Classes/Template/ModuleTemplate.php
index c50f11c5bb05..e12430740a51 100644
--- a/typo3/sysext/backend/Classes/Template/ModuleTemplate.php
+++ b/typo3/sysext/backend/Classes/Template/ModuleTemplate.php
@@ -355,7 +355,7 @@ class ModuleTemplate
         if ($this->moduleName) {
             $this->view->assign('moduleName', $this->moduleName);
         }
-
+        $this->view->assign('flashMessageQueueIdentifier', $this->getFlashMessageQueue()->getIdentifier());
         $renderedPage = $this->pageRenderer->render(PageRenderer::PART_HEADER);
         $renderedPage .= $this->bodyTag;
         $renderedPage .= $this->view->render();
@@ -866,6 +866,14 @@ class ModuleTemplate
         $this->getFlashMessageQueue()->enqueue($flashMessage);
     }
 
+    /**
+     * @param \TYPO3\CMS\Core\Messaging\FlashMessageQueue $flashMessageQueue
+     */
+    public function setFlashMessageQueue($flashMessageQueue)
+    {
+        $this->flashMessageQueue = $flashMessageQueue;
+    }
+
     /**
      * @return \TYPO3\CMS\Core\Messaging\FlashMessageQueue
      */
@@ -874,7 +882,7 @@ class ModuleTemplate
         if (!isset($this->flashMessageQueue)) {
             /** @var FlashMessageService $service */
             $service = GeneralUtility::makeInstance(FlashMessageService::class);
-            $this->flashMessageQueue = $service->getMessageQueueByIdentifier('module.template.flashmessages');
+            $this->flashMessageQueue = $service->getMessageQueueByIdentifier();
         }
         return $this->flashMessageQueue;
     }
diff --git a/typo3/sysext/backend/Classes/View/PageLayoutView.php b/typo3/sysext/backend/Classes/View/PageLayoutView.php
index de5b1e69fae3..4a5c8f6111e6 100644
--- a/typo3/sysext/backend/Classes/View/PageLayoutView.php
+++ b/typo3/sysext/backend/Classes/View/PageLayoutView.php
@@ -2168,7 +2168,7 @@ class PageLayoutView extends \TYPO3\CMS\Recordlist\RecordList\AbstractDatabaseRe
                     FlashMessage::WARNING
                 );
                 $service = GeneralUtility::makeInstance(FlashMessageService::class);
-                $queue = $service->getMessageQueueByIdentifier('module.template.flashmessages');
+                $queue = $service->getMessageQueueByIdentifier();
                 $queue->addMessage($message);
             }
         }
diff --git a/typo3/sysext/backend/Resources/Private/Templates/Module.html b/typo3/sysext/backend/Resources/Private/Templates/Module.html
index e18a281952e4..eaf142e7a083 100644
--- a/typo3/sysext/backend/Resources/Private/Templates/Module.html
+++ b/typo3/sysext/backend/Resources/Private/Templates/Module.html
@@ -8,9 +8,24 @@
 		<f:render partial="DocHeader" arguments="{docHeader:docHeader}" />
 	</f:if>
 	<div class="module-body t3js-module-body">
-		<f:flashMessages as="flashMessages" queueIdentifier="module.template.flashmessages">
+		<f:flashMessages as="flashMessages" queueIdentifier="{flashMessageQueueIdentifier}">
 			<f:for each="{flashMessages}" as="flashMessage">
-				{flashMessage}
+				<div class="alert {flashMessage.class}">
+					<div class="media">
+						<div class="media-left">
+							<span class="fa-stack fa-lg">
+								<i class="fa fa-circle fa-stack-2x"></i>
+								<i class="fa fa-{flashMessage.iconName} fa-stack-1x"></i>
+							</span>
+						</div>
+						<div class="media-body">
+							<f:if condition="{flashMessage.title}">
+								<h4 class="alert-title">{flashMessage.title}</h4>
+							</f:if>
+							<div class="alert-message">{flashMessage.message}</div>
+						</div>
+					</div>
+				</div>
 			</f:for>
 		</f:flashMessages>
 		<f:format.raw>{content}</f:format.raw>
diff --git a/typo3/sysext/beuser/Classes/Controller/BackendUserActionController.php b/typo3/sysext/beuser/Classes/Controller/BackendUserActionController.php
index b8801864486c..0aabb6ab295f 100644
--- a/typo3/sysext/beuser/Classes/Controller/BackendUserActionController.php
+++ b/typo3/sysext/beuser/Classes/Controller/BackendUserActionController.php
@@ -59,6 +59,7 @@ class BackendUserActionController extends ActionController
             || $this->actionMethodName == 'compareAction') {
             $this->generateMenu();
             $this->registerDocheaderButtons();
+            $this->view->getModuleTemplate()->setFlashMessageQueue($this->controllerContext->getFlashMessageQueue());
         }
     }
 
diff --git a/typo3/sysext/beuser/Classes/Controller/PermissionController.php b/typo3/sysext/beuser/Classes/Controller/PermissionController.php
index e01603f23ca8..65932d50031a 100644
--- a/typo3/sysext/beuser/Classes/Controller/PermissionController.php
+++ b/typo3/sysext/beuser/Classes/Controller/PermissionController.php
@@ -138,6 +138,7 @@ class PermissionController extends ActionController
                 '
             );
             $this->registerDocHeaderButtons();
+            $this->view->getModuleTemplate()->setFlashMessageQueue($this->controllerContext->getFlashMessageQueue());
         }
     }
 
@@ -192,8 +193,8 @@ class PermissionController extends ActionController
         if ($this->getBackendUser()->workspace != 0) {
             // Adding section with the permission setting matrix:
             $this->addFlashMessage(
-                'LLL:EXT:beuser/Resources/Private/Language/locallang_mod_permission.xlf:WorkspaceWarningText',
-                'LLL:EXT:beuser/Resources/Private/Language/locallang_mod_permission.xlf:WorkspaceWarning',
+                LocalizationUtility::translate('LLL:EXT:beuser/Resources/Private/Language/locallang_mod_permission.xlf:WorkspaceWarningText', 'beuser'),
+                LocalizationUtility::translate('LLL:EXT:beuser/Resources/Private/Language/locallang_mod_permission.xlf:WorkspaceWarning', 'beuser'),
                 FlashMessage::WARNING
             );
         }
diff --git a/typo3/sysext/beuser/Resources/Private/Layouts/Default.html b/typo3/sysext/beuser/Resources/Private/Layouts/Default.html
index f9e814a33c33..60723973cba0 100644
--- a/typo3/sysext/beuser/Resources/Private/Layouts/Default.html
+++ b/typo3/sysext/beuser/Resources/Private/Layouts/Default.html
@@ -1,11 +1,2 @@
-<f:be.pageRenderer />
-
 <f:render section="headline" />
-
-<f:flashMessages as="flashMessages">
-	<f:for each="{flashMessages}" as="flashMessage">
-		{flashMessage}
-	</f:for>
-</f:flashMessages>
-
 <f:render section="content" />
diff --git a/typo3/sysext/beuser/Resources/Private/Layouts/Permission.html b/typo3/sysext/beuser/Resources/Private/Layouts/Permission.html
index bc8b5eb88e1a..60723973cba0 100644
--- a/typo3/sysext/beuser/Resources/Private/Layouts/Permission.html
+++ b/typo3/sysext/beuser/Resources/Private/Layouts/Permission.html
@@ -1,15 +1,2 @@
-<f:be.pageRenderer />
 <f:render section="headline" />
-
-<f:flashMessages as="flashMessages">
-	<ul class="typo3-flashMessages">
-		<f:for each="{flashMessages}" as="flashMessage">
-			<li class="alert {flashMessage.class}">
-				<h4><f:translate id="{flashMessage.title}" extensionName="beuser" /></h4>
-				<f:translate id="{flashMessage.message}" extensionName="beuser" />
-			</li>
-		</f:for>
-	</ul>
-</f:flashMessages>
-
 <f:render section="content" />
diff --git a/typo3/sysext/core/Classes/Messaging/FlashMessage.php b/typo3/sysext/core/Classes/Messaging/FlashMessage.php
index 719b49abc6fb..5dcaf20409e3 100644
--- a/typo3/sysext/core/Classes/Messaging/FlashMessage.php
+++ b/typo3/sysext/core/Classes/Messaging/FlashMessage.php
@@ -14,13 +14,15 @@ namespace TYPO3\CMS\Core\Messaging;
  * The TYPO3 project - inspiring people to share!
  */
 
+use TYPO3\CMS\Core\Utility\GeneralUtility;
+
 /**
  * A class representing flash messages.
  */
 class FlashMessage extends AbstractMessage
 {
     /**
-     * defines whether the message should be stored in the session (to survive redirects) or only for one request (default)
+     * Defines whether the message should be stored in the session (to survive redirects) or only for one request (default)
      *
      * @var bool
      */
@@ -55,7 +57,6 @@ class FlashMessage extends AbstractMessage
      * @param string $title Optional message title.
      * @param int $severity Optional severity, must be either of one of \TYPO3\CMS\Core\Messaging\FlashMessage constants
      * @param bool $storeInSession Optional, defines whether the message should be stored in the session or only for one request (default)
-     * @return void
      */
     public function __construct($message, $title = '', $severity = self::OK, $storeInSession = false)
     {
@@ -101,7 +102,7 @@ class FlashMessage extends AbstractMessage
      *
      * @return string The message severity icon name
      */
-    protected function getIconName()
+    public function getIconName()
     {
         return $this->icons[$this->severity];
     }
@@ -110,9 +111,11 @@ class FlashMessage extends AbstractMessage
      * Renders the flash message.
      *
      * @return string The flash message as HTML.
+     * @deprecated since TYPO3 CMS 7, will be removed in TYPO3 CMS 8
      */
     public function render()
     {
+        GeneralUtility::logDeprecatedFunction();
         $title = '';
         if (!empty($this->title)) {
             $title = '<h4 class="alert-title">' . $this->title . '</h4>';
@@ -134,13 +137,4 @@ class FlashMessage extends AbstractMessage
 			</div>';
         return $message;
     }
-
-    /**
-     * Renders the flash message, makes it possible to render a flashMessage in a fluid view.
-     *
-     * @return string
-     */
-    public function __toString() {
-        return $this->render();
-    }
 }
diff --git a/typo3/sysext/core/Classes/Messaging/FlashMessageQueue.php b/typo3/sysext/core/Classes/Messaging/FlashMessageQueue.php
index 45c1c7652369..65cc5c8ba1c4 100644
--- a/typo3/sysext/core/Classes/Messaging/FlashMessageQueue.php
+++ b/typo3/sysext/core/Classes/Messaging/FlashMessageQueue.php
@@ -36,6 +36,14 @@ class FlashMessageQueue extends \SplQueue
         $this->identifier = $identifier;
     }
 
+    /**
+     * @return string
+     */
+    public function getIdentifier()
+    {
+        return $this->identifier;
+    }
+
     /**
      * Adds a message either to the BE_USER session (if the $message has the storeInSession flag set)
      * or it enqueues the message.
diff --git a/typo3/sysext/core/Documentation/Changelog/master/Deprecation-71249-DeprecateRenderMethodOfFlashMessageClass.rst b/typo3/sysext/core/Documentation/Changelog/master/Deprecation-71249-DeprecateRenderMethodOfFlashMessageClass.rst
new file mode 100644
index 000000000000..48bf73ba8f82
--- /dev/null
+++ b/typo3/sysext/core/Documentation/Changelog/master/Deprecation-71249-DeprecateRenderMethodOfFlashMessageClass.rst
@@ -0,0 +1,22 @@
+===================================================================
+Deprecation: #71249 - Deprecate render method of FlashMessage class
+===================================================================
+
+Description
+===========
+
+Method ``TYPO3\CMS\Core\Messaging\FlashMessage::render()`` has been deprecated.
+
+
+Affected Installations
+======================
+
+Instances with custom backend modules that use this method.
+
+
+Migration
+=========
+
+Use custom render code, the ``<f:flashMessage />`` ViewHelper or the ``ModuleTemplate`` for backend modules to render Flash Messages.
+It is suggested not to include HTML in flash messages. Flash messages should be short notifications on usr interactions.
+If you need more elaborate or persistent messages, use ``<f:be.infobox />`` view helper or HTML similar to that.
\ No newline at end of file
diff --git a/typo3/sysext/documentation/Classes/Controller/DocumentController.php b/typo3/sysext/documentation/Classes/Controller/DocumentController.php
index 6488114d7336..d59835d20e36 100644
--- a/typo3/sysext/documentation/Classes/Controller/DocumentController.php
+++ b/typo3/sysext/documentation/Classes/Controller/DocumentController.php
@@ -107,6 +107,7 @@ class DocumentController extends ActionController
             }
 
             $this->view->getModuleTemplate()->getDocHeaderComponent()->getMenuRegistry()->addMenu($menu);
+            $this->view->getModuleTemplate()->setFlashMessageQueue($this->controllerContext->getFlashMessageQueue());
         }
     }
 
diff --git a/typo3/sysext/documentation/Resources/Private/Layouts/Default.html b/typo3/sysext/documentation/Resources/Private/Layouts/Default.html
index f3c0e8fc5554..a5c707aa3996 100644
--- a/typo3/sysext/documentation/Resources/Private/Layouts/Default.html
+++ b/typo3/sysext/documentation/Resources/Private/Layouts/Default.html
@@ -1,9 +1,4 @@
 <div class="typo3-documentation">
 	<f:render section="module-headline" />
-	<f:flashMessages as="flashMessages">
-		<f:for each="{flashMessages}" as="flashMessage">
-			{flashMessage}
-		</f:for>
-	</f:flashMessages>
 	<f:render section="Content" />
 </div>
diff --git a/typo3/sysext/extensionmanager/Classes/Controller/AbstractModuleController.php b/typo3/sysext/extensionmanager/Classes/Controller/AbstractModuleController.php
index e470aa18e87b..50a0194aecd6 100644
--- a/typo3/sysext/extensionmanager/Classes/Controller/AbstractModuleController.php
+++ b/typo3/sysext/extensionmanager/Classes/Controller/AbstractModuleController.php
@@ -108,6 +108,7 @@ class AbstractModuleController extends AbstractController {
         }
 
         $this->view->getModuleTemplate()->getDocHeaderComponent()->getMenuRegistry()->addMenu($menu);
+        $this->view->getModuleTemplate()->setFlashMessageQueue($this->controllerContext->getFlashMessageQueue());
     }
 
     /**
diff --git a/typo3/sysext/extensionmanager/Resources/Private/Layouts/Main.html b/typo3/sysext/extensionmanager/Resources/Private/Layouts/Main.html
index 2dca2733c34d..6ec7227f8b8d 100644
--- a/typo3/sysext/extensionmanager/Resources/Private/Layouts/Main.html
+++ b/typo3/sysext/extensionmanager/Resources/Private/Layouts/Main.html
@@ -15,10 +15,5 @@
 	}"
 	/>
 <f:render section="headline" />
-<f:flashMessages as="flashMessages">
-	<f:for each="{flashMessages}" as="flashMessage">
-		{flashMessage}
-	</f:for>
-</f:flashMessages>
 
 <f:render section="content" />
diff --git a/typo3/sysext/extensionmanager/Resources/Private/Templates/Distribution/Show.html b/typo3/sysext/extensionmanager/Resources/Private/Templates/Distribution/Show.html
index 3be78664f95d..00e0524117f5 100644
--- a/typo3/sysext/extensionmanager/Resources/Private/Templates/Distribution/Show.html
+++ b/typo3/sysext/extensionmanager/Resources/Private/Templates/Distribution/Show.html
@@ -7,7 +7,6 @@
 </f:section>
 
 <f:section name="content">
-	<f:flashMessages class="distribution-detail-flashmessage" />
 	<div class="distribution-detail">
 		<div class="distribution-detail-previewpane">
 			<em:image
diff --git a/typo3/sysext/extensionmanager/Resources/Private/Templates/List/UnresolvedDependencies.html b/typo3/sysext/extensionmanager/Resources/Private/Templates/List/UnresolvedDependencies.html
index 3ed2957e747a..93bbbcf458b7 100644
--- a/typo3/sysext/extensionmanager/Resources/Private/Templates/List/UnresolvedDependencies.html
+++ b/typo3/sysext/extensionmanager/Resources/Private/Templates/List/UnresolvedDependencies.html
@@ -7,12 +7,6 @@
 </f:section>
 
 <f:section name="content">
-	<f:flashMessages as="flashMessages">
-		<f:for each="{flashMessages}" as="flashMessage">
-			{flashMessage}
-		</f:for>
-	</f:flashMessages>
-
 	<f:render partial="List/UnresolvedDependencies" arguments="{_all}" />
 	<f:be.infobox title="{f:translate(key: 'dependencyCheck.unresolvedDependencies.title')}" state="1">
 		<f:render partial="List/UnresolvedDependenciesMessage" />
@@ -23,4 +17,4 @@
 	<f:link.action action="installExtensionWithoutSystemDependencyCheck" controller="Action" arguments="{extensionKey: extension.extensionKey}" class="btn btn-default t3js-dependencies disabled onClickMaskExtensionManager">
 		<span class="t3-icon t3-icon-actions t3-icon-dialog-error">&nbsp;</span> <f:translate key="dependencyCheck.unresolvedDependencies.proceed" />
 	</f:link.action>
-</f:section>
+</f:section>
\ No newline at end of file
diff --git a/typo3/sysext/filelist/Resources/Private/Layouts/Default.html b/typo3/sysext/filelist/Resources/Private/Layouts/Default.html
index 3cf7a5f552f1..d0c3279270d4 100644
--- a/typo3/sysext/filelist/Resources/Private/Layouts/Default.html
+++ b/typo3/sysext/filelist/Resources/Private/Layouts/Default.html
@@ -1,12 +1,7 @@
 <f:render section="headline" />
-<f:flashMessages as="flashMessages" queueIdentifier="core.template.flashMessages">
-	<f:for each="{flashMessages}" as="flashMessage">
-		{flashMessage}
-	</f:for>
-</f:flashMessages>
 <f:render section="content" />
 
 <div class="t3js-drag-uploader" data-target-folder="{folderIdentifier}" data-progress-container="#typo3-filelist"
 	 data-dropzone-trigger=".t3js-drag-uploader-trigger" data-dropzone-target=".t3js-module-body h1:first"
 	 data-file-deny-pattern="{fileDenyPattern}" data-max-file-size="{maxFileSize}"
-	></div>
+	></div>
\ No newline at end of file
diff --git a/typo3/sysext/fluid/Classes/ViewHelpers/FlashMessagesViewHelper.php b/typo3/sysext/fluid/Classes/ViewHelpers/FlashMessagesViewHelper.php
index 83a899b02cf3..406347a050dc 100644
--- a/typo3/sysext/fluid/Classes/ViewHelpers/FlashMessagesViewHelper.php
+++ b/typo3/sysext/fluid/Classes/ViewHelpers/FlashMessagesViewHelper.php
@@ -93,20 +93,6 @@ class FlashMessagesViewHelper extends \TYPO3\CMS\Fluid\Core\ViewHelper\AbstractT
      */
     protected $tagName = 'ul';
 
-    /**
-     * @var \TYPO3\CMS\Extbase\Configuration\ConfigurationManagerInterface
-     */
-    protected $configurationManager;
-
-    /**
-     * @param \TYPO3\CMS\Extbase\Configuration\ConfigurationManagerInterface $configurationManager
-     * @return void
-     */
-    public function injectConfigurationManager(\TYPO3\CMS\Extbase\Configuration\ConfigurationManagerInterface $configurationManager)
-    {
-        $this->configurationManager = $configurationManager;
-    }
-
     /**
      * Initialize arguments
      *
diff --git a/typo3/sysext/indexed_search/Classes/Controller/AdministrationController.php b/typo3/sysext/indexed_search/Classes/Controller/AdministrationController.php
index 80a694155111..d5da4ba31bb0 100644
--- a/typo3/sysext/indexed_search/Classes/Controller/AdministrationController.php
+++ b/typo3/sysext/indexed_search/Classes/Controller/AdministrationController.php
@@ -92,6 +92,7 @@ class AdministrationController extends ActionController
         $pageRecord = BackendUtility::readPageAccess($this->pageUid, $permissionClause);
         $view->getModuleTemplate()->getDocHeaderComponent()->setMetaInformation($pageRecord);
         $this->generateMenu();
+        $this->view->getModuleTemplate()->setFlashMessageQueue($this->controllerContext->getFlashMessageQueue());
     }
 
     /**
diff --git a/typo3/sysext/indexed_search/Resources/Private/Layouts/Administration.html b/typo3/sysext/indexed_search/Resources/Private/Layouts/Administration.html
index 80ab262df182..970e6a5c99fb 100644
--- a/typo3/sysext/indexed_search/Resources/Private/Layouts/Administration.html
+++ b/typo3/sysext/indexed_search/Resources/Private/Layouts/Administration.html
@@ -1,3 +1,2 @@
-<f:be.pageRenderer />
 <h1>Indexing Engine Statistics</h1>
 <f:render section="Content" />
diff --git a/typo3/sysext/indexed_search/Resources/Private/Templates/Administration/StatisticDetails.html b/typo3/sysext/indexed_search/Resources/Private/Templates/Administration/StatisticDetails.html
index 3b255f558f65..7bdee920d906 100644
--- a/typo3/sysext/indexed_search/Resources/Private/Templates/Administration/StatisticDetails.html
+++ b/typo3/sysext/indexed_search/Resources/Private/Templates/Administration/StatisticDetails.html
@@ -5,11 +5,6 @@
 
 <f:section name="Content">
 	<p class="lead"><f:translate key="administration.document.description"/></p>
-	<f:flashMessages as="flashMessages">
-		<f:for each="{flashMessages}" as="flashMessage">
-			{flashMessage}
-		</f:for>
-	</f:flashMessages>
 	<f:if condition="{phashRow}">
 		<f:then>
 			<table class="table table-striped table-hover">
@@ -196,4 +191,4 @@
 
 		</f:form>
 	</f:if>
-</f:section>
+</f:section>
\ No newline at end of file
diff --git a/typo3/sysext/lang/Classes/Controller/LanguageController.php b/typo3/sysext/lang/Classes/Controller/LanguageController.php
index 7d588bbef404..de88559edb91 100644
--- a/typo3/sysext/lang/Classes/Controller/LanguageController.php
+++ b/typo3/sysext/lang/Classes/Controller/LanguageController.php
@@ -285,7 +285,7 @@ class LanguageController extends ActionController
         $menu->addMenuItem($languageListMenuItem);
         $menu->addMenuItem($translationMenuItem);
         $this->view->getModuleTemplate()->getDocHeaderComponent()->getMenuRegistry()->addMenu($menu);
-
+        $this->view->getModuleTemplate()->setFlashMessageQueue($this->controllerContext->getFlashMessageQueue());
     }
 
     /**
diff --git a/typo3/sysext/lang/Resources/Private/Templates/Language/ListLanguages.html b/typo3/sysext/lang/Resources/Private/Templates/Language/ListLanguages.html
index 96e0a1393e54..5bf413237630 100644
--- a/typo3/sysext/lang/Resources/Private/Templates/Language/ListLanguages.html
+++ b/typo3/sysext/lang/Resources/Private/Templates/Language/ListLanguages.html
@@ -1,6 +1,5 @@
 {namespace core=TYPO3\CMS\Core\ViewHelpers}
 <?xml version="1.0" encoding="UTF-8" ?>
-<!DOCTYPE html>
 <html xmlns="http://www.w3.org/1999/xhtml" lang="en"
       xmlns:f="http://xsd.helmut-hummel.de/ns/TYPO3/CMS/Fluid/ViewHelpers">
 <f:layout name="Default"/>
@@ -9,11 +8,6 @@
 	<h1>
 		<f:translate key="header.languages"/>
 	</h1>
-	<f:flashMessages as="flashMessages">
-		<f:for each="{flashMessages}" as="flashMessage">
-			{flashMessage}
-		</f:for>
-	</f:flashMessages>
 	<form class="form-inline">
 		<div class="form-group">
 			<f:form.textfield name="typo3-language-searchfield" placeholder="{f:translate(key:'table.search')}"
diff --git a/typo3/sysext/lang/Resources/Private/Templates/Language/ListTranslations.html b/typo3/sysext/lang/Resources/Private/Templates/Language/ListTranslations.html
index a79c0f7d668d..cf19d4e356ae 100644
--- a/typo3/sysext/lang/Resources/Private/Templates/Language/ListTranslations.html
+++ b/typo3/sysext/lang/Resources/Private/Templates/Language/ListTranslations.html
@@ -2,11 +2,6 @@
 
 <f:section name="content">
 	<h1><f:translate key="header.translations" /></h1>
-	<f:flashMessages as="flashMessages">
-		<f:for each="{flashMessages}" as="flashMessage">
-			{flashMessage}
-		</f:for>
-	</f:flashMessages>
 	<form class="form-inline">
 		<div class="form-group">
 			<f:form.textfield name="typo3-language-searchfield" placeholder="{f:translate(key:'table.search')}" id="typo3-language-searchfield" value="{search}" class="form-control t3js-language-searchfield" />
diff --git a/typo3/sysext/recycler/Classes/Controller/RecyclerModuleController.php b/typo3/sysext/recycler/Classes/Controller/RecyclerModuleController.php
index 3cf6611ee94e..7a757db4bac3 100644
--- a/typo3/sysext/recycler/Classes/Controller/RecyclerModuleController.php
+++ b/typo3/sysext/recycler/Classes/Controller/RecyclerModuleController.php
@@ -115,6 +115,7 @@ class RecyclerModuleController extends ActionController
         /** @var BackendTemplateView $view */
         parent::initializeView($view);
         $this->registerDocheaderButtons();
+        $this->view->getModuleTemplate()->setFlashMessageQueue($this->controllerContext->getFlashMessageQueue());
     }
 
     /**
diff --git a/typo3/sysext/recycler/Resources/Private/Layouts/Default.html b/typo3/sysext/recycler/Resources/Private/Layouts/Default.html
index 2732da54ccdc..d3519f056836 100644
--- a/typo3/sysext/recycler/Resources/Private/Layouts/Default.html
+++ b/typo3/sysext/recycler/Resources/Private/Layouts/Default.html
@@ -1,8 +1,3 @@
 <f:be.pageRenderer includeRequireJsModules="{0:'TYPO3/CMS/Recycler/Recycler'}" />
 <h1><f:translate key="title" /></h1>
-<f:flashMessages as="flashMessages">
-	<f:for each="{flashMessages}" as="flashMessage">
-		{flashMessage}
-	</f:for>
-</f:flashMessages>
 <f:render section="content" />
diff --git a/typo3/sysext/scheduler/Classes/Controller/SchedulerModuleController.php b/typo3/sysext/scheduler/Classes/Controller/SchedulerModuleController.php
index e23a61528067..f4eee942c087 100644
--- a/typo3/sysext/scheduler/Classes/Controller/SchedulerModuleController.php
+++ b/typo3/sysext/scheduler/Classes/Controller/SchedulerModuleController.php
@@ -22,8 +22,6 @@ use TYPO3\CMS\Backend\Utility\BackendUtility;
 use TYPO3\CMS\Core\Database\DatabaseConnection;
 use TYPO3\CMS\Core\Imaging\Icon;
 use TYPO3\CMS\Core\Messaging\FlashMessage;
-use TYPO3\CMS\Core\Messaging\FlashMessageQueue;
-use TYPO3\CMS\Core\Messaging\FlashMessageService;
 use TYPO3\CMS\Core\Page\PageRenderer;
 use TYPO3\CMS\Core\Utility\GeneralUtility;
 use TYPO3\CMS\Core\Utility\ExtensionManagementUtility;
@@ -167,21 +165,6 @@ class SchedulerModuleController extends \TYPO3\CMS\Backend\Module\BaseScriptClas
         }
         $this->getButtons();
         $this->getModuleMenu();
-        $this->content = $this->getFlashMessages() . $this->content;
-    }
-
-    /**
-     * Get the default rendered FlashMessages from queue
-     *
-     * @return string
-     */
-    public function getFlashMessages()
-    {
-        /** @var $flashMessageService \TYPO3\CMS\Core\Messaging\FlashMessageService */
-        $flashMessageService = GeneralUtility::makeInstance(\TYPO3\CMS\Core\Messaging\FlashMessageService::class);
-        /** @var $defaultFlashMessageQueue \TYPO3\CMS\Core\Messaging\FlashMessageQueue */
-        $defaultFlashMessageQueue = $flashMessageService->getMessageQueueByIdentifier();
-        return $defaultFlashMessageQueue->renderFlashMessages();
     }
 
     /**
@@ -1499,13 +1482,7 @@ class SchedulerModuleController extends \TYPO3\CMS\Backend\Module\BaseScriptClas
      */
     public function addMessage($message, $severity = FlashMessage::OK)
     {
-        /** @var $flashMessage FlashMessage */
-        $flashMessage = GeneralUtility::makeInstance(\TYPO3\CMS\Core\Messaging\FlashMessage::class, $message, '', $severity);
-        /** @var $flashMessageService FlashMessageService */
-        $flashMessageService = GeneralUtility::makeInstance(\TYPO3\CMS\Core\Messaging\FlashMessageService::class);
-        /** @var $defaultFlashMessageQueue FlashMessageQueue */
-        $defaultFlashMessageQueue = $flashMessageService->getMessageQueueByIdentifier();
-        $defaultFlashMessageQueue->enqueue($flashMessage);
+        $this->moduleTemplate->addFlashMessage($message, '', $severity);
     }
 
     /**
diff --git a/typo3/sysext/t3skin/Resources/Public/Css/backend.css b/typo3/sysext/t3skin/Resources/Public/Css/backend.css
index 9ccd1cea873d..1212a92520eb 100644
--- a/typo3/sysext/t3skin/Resources/Public/Css/backend.css
+++ b/typo3/sysext/t3skin/Resources/Public/Css/backend.css
@@ -13460,12 +13460,6 @@ iframe {
 .distribution-meta .distribution-install {
   margin-top: 0.5em;
 }
-.distribution-detail-flashmessage {
-  margin-bottom: 2.5em;
-}
-.distribution-detail-flashmessage p {
-  padding-bottom: 0;
-}
 .distribution-detail {
   min-width: 750px;
 }
diff --git a/typo3/sysext/tstemplate/Classes/Controller/TypoScriptTemplateObjectBrowserModuleFunctionController.php b/typo3/sysext/tstemplate/Classes/Controller/TypoScriptTemplateObjectBrowserModuleFunctionController.php
index aeefd51fe7ca..960eb0ec91e4 100644
--- a/typo3/sysext/tstemplate/Classes/Controller/TypoScriptTemplateObjectBrowserModuleFunctionController.php
+++ b/typo3/sysext/tstemplate/Classes/Controller/TypoScriptTemplateObjectBrowserModuleFunctionController.php
@@ -552,7 +552,7 @@ class TypoScriptTemplateObjectBrowserModuleFunctionController extends AbstractFu
         /** @var $flashMessageService FlashMessageService */
         $flashMessageService = GeneralUtility::makeInstance(FlashMessageService::class);
         /** @var $defaultFlashMessageQueue \TYPO3\CMS\Core\Messaging\FlashMessageQueue */
-        $defaultFlashMessageQueue = $flashMessageService->getMessageQueueByIdentifier('module.template.flashmessages');
+        $defaultFlashMessageQueue = $flashMessageService->getMessageQueueByIdentifier();
         $defaultFlashMessageQueue->enqueue($flashMessage);
     }
 
diff --git a/typo3/sysext/workspaces/Classes/Controller/PreviewController.php b/typo3/sysext/workspaces/Classes/Controller/PreviewController.php
index 508148529e79..e93c67be73e1 100644
--- a/typo3/sysext/workspaces/Classes/Controller/PreviewController.php
+++ b/typo3/sysext/workspaces/Classes/Controller/PreviewController.php
@@ -43,6 +43,7 @@ class PreviewController extends AbstractController
     {
         parent::initializeView($view);
         $view->getModuleTemplate()->getDocHeaderComponent()->disable();
+        $this->view->getModuleTemplate()->setFlashMessageQueue($this->controllerContext->getFlashMessageQueue());
     }
 
     /**
diff --git a/typo3/sysext/workspaces/Classes/Controller/ReviewController.php b/typo3/sysext/workspaces/Classes/Controller/ReviewController.php
index 1dd5e6fd4cbd..fefac8d307c0 100644
--- a/typo3/sysext/workspaces/Classes/Controller/ReviewController.php
+++ b/typo3/sysext/workspaces/Classes/Controller/ReviewController.php
@@ -34,6 +34,7 @@ class ReviewController extends AbstractController
     {
         parent::initializeView($view);
         $this->registerButtons();
+        $this->view->getModuleTemplate()->setFlashMessageQueue($this->controllerContext->getFlashMessageQueue());
     }
 
     /**
diff --git a/typo3/sysext/workspaces/Resources/Private/Layouts/Module.html b/typo3/sysext/workspaces/Resources/Private/Layouts/Module.html
index b5a215ae98ff..d480d8d62d01 100644
--- a/typo3/sysext/workspaces/Resources/Private/Layouts/Module.html
+++ b/typo3/sysext/workspaces/Resources/Private/Layouts/Module.html
@@ -1,9 +1,4 @@
 <f:if condition="{pageTitle}"><h1>{pageTitle}</h1></f:if>
-<f:flashMessages as="flashMessages">
-	<f:for each="{flashMessages}" as="flashMessage">
-		{flashMessage}
-	</f:for>
-</f:flashMessages>
 <div id="workspacetabs"></div>
 <div class="well well-sm"><f:render section="main" /></div>
-<f:if condition="{showLegend}"><f:render partial="legend" /></f:if>
+<f:if condition="{showLegend}"><f:render partial="legend" /></f:if>
\ No newline at end of file
diff --git a/typo3/sysext/workspaces/Resources/Private/Layouts/Nodoc.html b/typo3/sysext/workspaces/Resources/Private/Layouts/Nodoc.html
index 3bc0693a361a..18efefcd0bb6 100644
--- a/typo3/sysext/workspaces/Resources/Private/Layouts/Nodoc.html
+++ b/typo3/sysext/workspaces/Resources/Private/Layouts/Nodoc.html
@@ -2,13 +2,6 @@
 	<!-- Content of module, for instance listing, info or editing -->
 	<div id="typo3-docbody">
 		<div id="typo3-inner-docbody">
-
-			<f:flashMessages as="flashMessages">
-				<f:for each="{flashMessages}" as="flashMessage">
-					{flashMessage}
-				</f:for>
-			</f:flashMessages>
-
 			<f:render section="main"/>
 		</div>
 	</div>
-- 
GitLab