diff --git a/core/includes/bootstrap.inc b/core/includes/bootstrap.inc index d0ab3ae..4be3e9e 100644 --- a/core/includes/bootstrap.inc +++ b/core/includes/bootstrap.inc @@ -562,8 +562,8 @@ function drupal_set_message($message = NULL, $type = 'status', $repeat = FALSE) } $new = array( - 'safe' => SafeMarkup::isSafe($message), - 'message' => (string) $message, + 'safe' => (!is_array($message) && SafeMarkup::isSafe($message)), + 'message' => $message, ); if ($repeat || !in_array($new, $_SESSION['messages'][$type])) { $_SESSION['messages'][$type][] = $new; @@ -610,7 +610,7 @@ function drupal_get_messages($type = NULL, $clear_queue = TRUE) { // the messages also needs to be stored in the session. We retrieve the // safe status here and determine whether to mark the string as safe or // let autoescape do its thing. See drupal_set_message(). - if ($message['safe']) { + if ($message['safe']) { // Only set when the message is not an array. $message['message'] = SafeMarkup::set($message['message']); } $messages[$message_type][$key] = $message['message']; diff --git a/core/modules/system/src/Tests/Bootstrap/DrupalSetMessageTest.php b/core/modules/system/src/Tests/Bootstrap/DrupalSetMessageTest.php index bf130b5..79c824e 100644 --- a/core/modules/system/src/Tests/Bootstrap/DrupalSetMessageTest.php +++ b/core/modules/system/src/Tests/Bootstrap/DrupalSetMessageTest.php @@ -31,7 +31,7 @@ function testSetRemoveMessages() { // removes the first before it is displayed. $this->drupalGet('system-test/drupal-set-message'); $this->assertNoText('First message (removed).'); - $this->assertText('Second message (not removed).'); + $this->assertRaw(t('Second message with markup! (not removed).')); } /** @@ -48,7 +48,7 @@ function testDuplicatedMessages() { */ function testRenderArrayMessages() { $this->drupalGet('system-test/drupal-set-message'); - $this->assertText('Render array'); + $this->assertRaw('Render array with markup!'); } } diff --git a/core/modules/system/tests/modules/system_test/src/Controller/SystemTestController.php b/core/modules/system/tests/modules/system_test/src/Controller/SystemTestController.php index 3b69300..3e5fe18 100644 --- a/core/modules/system/tests/modules/system_test/src/Controller/SystemTestController.php +++ b/core/modules/system/tests/modules/system_test/src/Controller/SystemTestController.php @@ -101,10 +101,10 @@ public function mainContentFallback() { public function drupalSetMessageTest() { // Set two messages. drupal_set_message('First message (removed).'); - drupal_set_message('Second message (not removed).'); + drupal_set_message(t('Second message with markup! (not removed).')); // Add a render array message. - drupal_set_message(['#markup' => 'Render array']); + drupal_set_message(['#markup' => 'Render array with markup!']); // Remove the first. unset($_SESSION['messages']['status'][0]);