Commit 7473eaf4 authored by alexpott's avatar alexpott
Browse files

Issue #2371671 by podarok | Chi: Fixed drupal_set_message repeat parameter does not work.

parent 74eb2b9b
...@@ -703,11 +703,12 @@ function drupal_set_message($message = NULL, $type = 'status', $repeat = FALSE) ...@@ -703,11 +703,12 @@ function drupal_set_message($message = NULL, $type = 'status', $repeat = FALSE)
$_SESSION['messages'][$type] = array(); $_SESSION['messages'][$type] = array();
} }
if ($repeat || !in_array($message, $_SESSION['messages'][$type])) { $new = array(
$_SESSION['messages'][$type][] = array(
'safe' => SafeMarkup::isSafe($message), 'safe' => SafeMarkup::isSafe($message),
'message' => $message, 'message' => $message,
); );
if ($repeat || !in_array($new, $_SESSION['messages'][$type])) {
$_SESSION['messages'][$type][] = $new;
} }
// Mark this page as being uncacheable. // Mark this page as being uncacheable.
......
...@@ -34,4 +34,13 @@ function testSetRemoveMessages() { ...@@ -34,4 +34,13 @@ function testSetRemoveMessages() {
$this->assertText('Second message (not removed).'); $this->assertText('Second message (not removed).');
} }
/**
* Tests setting duplicated messages.
*/
function testDuplicatedMessages() {
$this->drupalGet('system-test/drupal-set-message');
$this->assertUniqueText('Non Duplicated message');
$this->assertNoUniqueText('Duplicated message');
}
} }
...@@ -65,6 +65,13 @@ public function drupalSetMessageTest() { ...@@ -65,6 +65,13 @@ public function drupalSetMessageTest() {
// Remove the first. // Remove the first.
unset($_SESSION['messages']['status'][0]); unset($_SESSION['messages']['status'][0]);
// Duplicate message check.
drupal_set_message('Non Duplicated message', 'status', FALSE);
drupal_set_message('Non Duplicated message', 'status', FALSE);
drupal_set_message('Duplicated message', 'status', TRUE);
drupal_set_message('Duplicated message', 'status', TRUE);
return []; return [];
} }
......
Supports Markdown
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment