core/lib/Drupal/Core/Render/Renderer.php | 23 ++++++----------
core/modules/big_pipe/src/Render/BigPipe.php | 39 +++++++++++++++-------------
2 files changed, 29 insertions(+), 33 deletions(-)
diff --git a/core/lib/Drupal/Core/Render/Renderer.php b/core/lib/Drupal/Core/Render/Renderer.php
index a624c0f..14d9713 100644
--- a/core/lib/Drupal/Core/Render/Renderer.php
+++ b/core/lib/Drupal/Core/Render/Renderer.php
@@ -665,25 +665,18 @@ protected function replacePlaceholders(array &$elements) {
// to this one special case, with this hard-coded solution.
// @see \Drupal\Core\Render\Element\StatusMessages
// @see https://www.drupal.org/node/2712935#comment-11368923
- $possible_message_placeholders = [
- '',
- '',
- '',
- '',
- ];
-
- // We hardcoded the placeholders above to avoid doing this on every request,
- // but we ensure those hardcoded strings are accurate via assertions.
- assert('$possible_message_placeholders[0] === (string) $this->placeholderGenerator->createPlaceholder(["#lazy_builder" => ["Drupal\\Core\\Render\\Element\\StatusMessages::renderMessages", [NULL]], "#create_placeholder" => TRUE])["#markup"]');
- assert('$possible_message_placeholders[1] === (string) $this->placeholderGenerator->createPlaceholder(["#lazy_builder" => ["Drupal\\Core\\Render\\Element\\StatusMessages::renderMessages", ["status"]], "#create_placeholder" => TRUE])["#markup"]');
- assert('$possible_message_placeholders[2] === (string) $this->placeholderGenerator->createPlaceholder(["#lazy_builder" => ["Drupal\\Core\\Render\\Element\\StatusMessages::renderMessages", ["warning"]], "#create_placeholder" => TRUE])["#markup"]');
- assert('$possible_message_placeholders[3] === (string) $this->placeholderGenerator->createPlaceholder(["#lazy_builder" => ["Drupal\\Core\\Render\\Element\\StatusMessages::renderMessages", ["error"]], "#create_placeholder" => TRUE])["#markup"]');
+ $message_placeholders = [];
+ foreach ($elements['#attached']['placeholders'] as $placeholder => $placeholder_element) {
+ if (isset($placeholder_element['#lazy_builder']) && $placeholder_element['#lazy_builder'][0] === 'Drupal\Core\Render\Element\StatusMessages::renderMessages') {
+ $message_placeholders[] = $placeholder;
+ }
+ }
// Render placeholders in the appropriate order.
$placeholders = array_keys($elements['#attached']['placeholders']);
$ordered_placeholders = array_merge(
- array_diff($placeholders, $possible_message_placeholders),
- array_intersect($placeholders, $possible_message_placeholders)
+ array_diff($placeholders, $message_placeholders),
+ array_intersect($placeholders, $message_placeholders)
);
foreach ($ordered_placeholders as $placeholder) {
$elements = $this->renderPlaceholder($placeholder, $elements);
diff --git a/core/modules/big_pipe/src/Render/BigPipe.php b/core/modules/big_pipe/src/Render/BigPipe.php
index 00ec4a2..a965068 100644
--- a/core/modules/big_pipe/src/Render/BigPipe.php
+++ b/core/modules/big_pipe/src/Render/BigPipe.php
@@ -128,7 +128,7 @@ public function sendContent($content, array $attachments) {
list($pre_body, $post_body) = explode('