core/lib/Drupal/Core/Render/Element/StatusMessages.php | 4 +--- core/lib/Drupal/Core/Render/Renderer.php | 11 +++++++++++ 2 files changed, 12 insertions(+), 3 deletions(-) diff --git a/core/lib/Drupal/Core/Render/Element/StatusMessages.php b/core/lib/Drupal/Core/Render/Element/StatusMessages.php index c2fa305..b845c91 100644 --- a/core/lib/Drupal/Core/Render/Element/StatusMessages.php +++ b/core/lib/Drupal/Core/Render/Element/StatusMessages.php @@ -46,8 +46,6 @@ public function getInfo() { * The updated renderable array containing the placeholder. */ public static function generatePlaceholder(array $element) { - $plugin_id = 'status_messages'; - $callback = get_class() . '::renderMessages'; $context = [ 'display' => $element['#display'], @@ -57,7 +55,7 @@ public static function generatePlaceholder(array $element) { $callback => $context, ], '#create_placeholder' => TRUE, - // Make it uncacheable. + // Messsages are not cacheable. '#cache' => [ 'max-age' => 0, ], diff --git a/core/lib/Drupal/Core/Render/Renderer.php b/core/lib/Drupal/Core/Render/Renderer.php index 184f06a..f2e19c9 100644 --- a/core/lib/Drupal/Core/Render/Renderer.php +++ b/core/lib/Drupal/Core/Render/Renderer.php @@ -126,6 +126,7 @@ public function renderPlaceholder($placeholder, array $elements) { // Replace the placeholder with its rendered markup, and merge its // bubbleable metadata with the main element's. + // @todo this cannot happen here, because BigPipe cannot do this. $elements['#markup'] = str_replace($placeholder, $markup, $elements['#markup']); $elements = $this->mergeBubbleableMetadata($elements, $placeholder_elements); @@ -555,6 +556,16 @@ protected function createPlaceholder(array $element) { '#cache' => TRUE, ]); + /* // @todo This at least makes development of this patch easier, but I'm not + // sure whether we can keep this; it'd too easily prevent us from doing + // "auto-placeholdering"? + // @todo Convert to an assertion once https://www.drupal.org/node/2408013 + // lands; having more properties is harmless but also useless. + $unsupported_keys = array_diff(array_keys($elements), ['#pre_render_cache', '#cache', '#create_placeholder']); + if (count($unsupported_keys)) { + throw new \Exception(implode($unsupported_keys)); + }*/ + // Generate placeholder markup. $attributes = new Attribute(); $i = 0;