From ccf51c54bdc70eaea8091902b0b6ceafb17b26a5 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Fabien=20Cl=C3=A9ment?= Date: Wed, 12 Jan 2022 18:23:24 +0100 Subject: [PATCH] Issue #3254328 by GOT intermedia: Update to Drupal 9.3.0 adding --2 suffix to (views-) block-ID's --- core/lib/Drupal/Core/Render/PlaceholderGenerator.php | 10 ++++++++++ .../src/Render/Placeholder/BigPipeStrategy.php | 10 ++++++++++ 2 files changed, 20 insertions(+) diff --git a/core/lib/Drupal/Core/Render/PlaceholderGenerator.php b/core/lib/Drupal/Core/Render/PlaceholderGenerator.php index 467a07e74a..87647a98bf 100644 --- a/core/lib/Drupal/Core/Render/PlaceholderGenerator.php +++ b/core/lib/Drupal/Core/Render/PlaceholderGenerator.php @@ -77,6 +77,16 @@ public function createPlaceholder(array $element) { '#cache' => TRUE, ]); + // Be sure cache contexts and tags are sorted before serializing them and + // making hash. Issue #3225328 remove sort from contexts and tags arrays for + // performances reasons. + if (isset($placeholder_render_array['#cache']['contexts'])) { + sort($placeholder_render_array['#cache']['contexts']); + } + if (isset($placeholder_render_array['#cache']['tags'])) { + sort($placeholder_render_array['#cache']['tags']); + } + // Generate placeholder markup. Note that the only requirement is that this // is unique markup that isn't easily guessable. The #lazy_builder callback // and its arguments are put in the placeholder markup solely to simplify<<< diff --git a/core/modules/big_pipe/src/Render/Placeholder/BigPipeStrategy.php b/core/modules/big_pipe/src/Render/Placeholder/BigPipeStrategy.php index 69945eca6a..f1363dd818 100644 --- a/core/modules/big_pipe/src/Render/Placeholder/BigPipeStrategy.php +++ b/core/modules/big_pipe/src/Render/Placeholder/BigPipeStrategy.php @@ -274,6 +274,16 @@ protected static function generateBigPipePlaceholderId($original_placeholder, ar // Generate a BigPipe placeholder ID (to be used by BigPipe's JavaScript). // @see \Drupal\Core\Render\PlaceholderGenerator::createPlaceholder() if (isset($placeholder_render_array['#lazy_builder'])) { + // Be sure cache contexts and tags are sorted before serializing them and + // making hash. Issue #3225328 remove sort from contexts and tags arrays for + // performances reasons. + if (isset($placeholder_render_array['#cache']['contexts'])) { + sort($placeholder_render_array['#cache']['contexts']); + } + if (isset($placeholder_render_array['#cache']['tags'])) { + sort($placeholder_render_array['#cache']['tags']); + } + $callback = $placeholder_render_array['#lazy_builder'][0]; $arguments = $placeholder_render_array['#lazy_builder'][1]; $token = Crypt::hashBase64(serialize($placeholder_render_array)); -- 2.25.1