diff --git a/core/includes/bootstrap.inc b/core/includes/bootstrap.inc index ced9c4c..99160be 100644 --- a/core/includes/bootstrap.inc +++ b/core/includes/bootstrap.inc @@ -517,9 +517,9 @@ function watchdog_exception($type, Exception $exception, $message = NULL, $varia * @param string|array|\Drupal\Component\Utility\SafeStringInterface $message * (optional) The translated message to be displayed to the user. For * consistency with other messages, it should begin with a capital letter and - * end with a period. A render array may also be provided for markup, but - * #attached is not supported. Additionally, any cache tags and contexts are - * ignored, however this is okay because page caching is disabled. + * end with a period. A render array may also be provided for markup, and if + * so it will be rendered with RendererInterface::renderPlain() (meaning + * caching and attachment data will be stripped). * @param string $type * (optional) The message's type. Defaults to 'status'. These values are * supported: @@ -556,6 +556,7 @@ function watchdog_exception($type, Exception $exception, $message = NULL, $varia * * @see drupal_get_messages() * @see status-messages.html.twig + * @see \Drupal\Core\Render\RendererInterface::renderPlain() */ function drupal_set_message($message = NULL, $type = 'status', $repeat = FALSE) { if (isset($message)) { @@ -573,11 +574,7 @@ function drupal_set_message($message = NULL, $type = 'status', $repeat = FALSE) // may have unpredictable results and some render array functionality // (like assets) should not be supported. if (is_array($message)) { - $rendered_message = \Drupal::service('renderer')->renderPlain($message); - // The rendering will have all attachments bubbled to #attached in the top - // level of $message. Assert that there are none. - assert('empty($message[\'#attached\']);', 'Render arrays passed to drupal_set_message() cannot have attachments.'); - $message = $rendered_message; + $message = \Drupal::service('renderer')->renderPlain($message); } // Do not use strict type checking so that equivalent string and