--- 2979184-20.patch 2019-11-25 14:24:35.295861349 +0400 +++ 2979184-23.patch 2019-11-25 14:39:25.779849494 +0400 @@ -1,5 +1,5 @@ diff --git a/core/modules/layout_builder/src/Entity/LayoutBuilderEntityViewDisplay.php b/core/modules/layout_builder/src/Entity/LayoutBuilderEntityViewDisplay.php -index 6619c580ce..9ac07566ab 100644 +index dc07388..31d0bd1 100644 --- a/core/modules/layout_builder/src/Entity/LayoutBuilderEntityViewDisplay.php +++ b/core/modules/layout_builder/src/Entity/LayoutBuilderEntityViewDisplay.php @@ -9,6 +9,7 @@ @@ -10,11 +10,10 @@ use Drupal\Core\Plugin\Context\Context; use Drupal\Core\Plugin\Context\ContextDefinition; use Drupal\Core\Plugin\Context\EntityContext; -@@ -31,6 +32,25 @@ class LayoutBuilderEntityViewDisplay extends BaseEntityViewDisplay implements La - use SectionStorageTrait; +@@ -32,6 +33,25 @@ class LayoutBuilderEntityViewDisplay extends BaseEntityViewDisplay implements La use LayoutEntityHelperTrait; -+ /** + /** + * The number of times this formatter allows rendering the same entity. + * + * @var int @@ -33,10 +32,11 @@ + */ + protected static $recursiveRenderDepth = []; + - /** ++ /** * The entity field manager. * -@@ -299,6 +319,10 @@ protected function buildSections(FieldableEntityInterface $entity) { + * @var \Drupal\Core\Entity\EntityFieldManagerInterface +@@ -314,6 +334,10 @@ protected function buildSections(FieldableEntityInterface $entity) { $build = []; if ($storage) { foreach ($storage->getSections() as $delta => $section) { @@ -47,11 +47,10 @@ $build[$delta] = $section->toRenderArray($contexts); } } -@@ -467,6 +491,48 @@ protected function getDefaultSection() { - return $this->getSection(0); +@@ -483,6 +507,48 @@ protected function getDefaultSection() { } -+ /** + /** + * Tests if this section has been rendered beyond the recursive limit. + * + * @param \Drupal\Core\Entity\FieldableEntityInterface $entity @@ -93,11 +92,12 @@ + return FALSE; + } + - /** ++ /** * Gets the section storage manager. * + * @return \Drupal\layout_builder\SectionStorage\SectionStorageManagerInterface diff --git a/core/modules/layout_builder/src/EventSubscriber/BlockComponentRenderArray.php b/core/modules/layout_builder/src/EventSubscriber/BlockComponentRenderArray.php -index e1a9773959..a6b6d6303c 100644 +index 8cde767..e188a10 100644 --- a/core/modules/layout_builder/src/EventSubscriber/BlockComponentRenderArray.php +++ b/core/modules/layout_builder/src/EventSubscriber/BlockComponentRenderArray.php @@ -12,6 +12,7 @@ @@ -116,11 +116,10 @@ use StringTranslationTrait; /** -@@ -32,6 +34,23 @@ class BlockComponentRenderArray implements EventSubscriberInterface { - */ +@@ -33,6 +35,23 @@ class BlockComponentRenderArray implements EventSubscriberInterface { protected $currentUser; -+ /** + /** + * An array of counters used for Views block recursive rendering protection. + * + * The counter records every time a specific entity has been rendered by a @@ -137,9 +136,10 @@ + */ + const VIEWS_RECURSIVE_RENDER_LIMIT = 2; + - /** ++ /** * Creates a BlockComponentRenderArray object. * + * @param \Drupal\Core\Session\AccountInterface $current_user @@ -57,6 +76,7 @@ public static function getSubscribedEvents() { * The section component render event. */ @@ -148,10 +148,10 @@ $block = $event->getPlugin(); if (!$block instanceof BlockPluginInterface) { return; -@@ -134,7 +154,53 @@ public function onBuildRender(SectionComponentBuildRenderArrayEvent $event) { - if ($is_content_empty && $is_placeholder_ready) { - $build['content']['#markup'] = $this->t('Placeholder for the @preview_fallback', ['@preview_fallback' => $block->getPreviewFallbackString()]); +@@ -137,7 +157,53 @@ public function onBuildRender(SectionComponentBuildRenderArrayEvent $event) { + } } + - $event->setBuild($build); + + if ($block instanceof ViewsBlock) { @@ -204,25 +204,25 @@ } diff --git a/core/modules/layout_builder/src/QuickEditIntegration.php b/core/modules/layout_builder/src/QuickEditIntegration.php -index 5492b4f335..d103b3972c 100644 +index 9ee5045..e188598 100644 --- a/core/modules/layout_builder/src/QuickEditIntegration.php +++ b/core/modules/layout_builder/src/QuickEditIntegration.php -@@ -129,6 +129,12 @@ public function entityViewAlter(array &$build, EntityInterface $entity, EntityVi +@@ -129,7 +129,11 @@ public function entityViewAlter(array &$build, EntityInterface $entity, EntityVi $plugin_ids_to_update = []; foreach (Element::children($build['_layout_builder']) as $delta) { $section = $build['_layout_builder'][$delta]; -+ +- + // Recursion protection makes it possible for there to be a $section + // without a '#layout' key. Skip when this is the case. + if (!isset($section['#layout'])) { + continue; + } - /** @var \Drupal\Core\Layout\LayoutDefinition $layout */ - $layout = $section['#layout']; - $regions = $layout->getRegionNames(); + if (!Element::isEmpty($section)) { + /** @var \Drupal\Core\Layout\LayoutDefinition $layout */ + $layout = $section['#layout']; diff --git a/core/modules/layout_builder/tests/modules/layout_builder_recursive_test/config/install/core.entity_form_display.node.type_with_recursion.default.yml b/core/modules/layout_builder/tests/modules/layout_builder_recursive_test/config/install/core.entity_form_display.node.type_with_recursion.default.yml new file mode 100644 -index 0000000000..f702bdcb90 +index 0000000..f702bdc --- /dev/null +++ b/core/modules/layout_builder/tests/modules/layout_builder_recursive_test/config/install/core.entity_form_display.node.type_with_recursion.default.yml @@ -0,0 +1,67 @@ @@ -295,7 +295,7 @@ +hidden: { } diff --git a/core/modules/layout_builder/tests/modules/layout_builder_recursive_test/config/install/core.entity_view_display.node.type_with_recursion.default.yml b/core/modules/layout_builder/tests/modules/layout_builder_recursive_test/config/install/core.entity_view_display.node.type_with_recursion.default.yml new file mode 100644 -index 0000000000..c5a47ce29c +index 0000000..c5a47ce --- /dev/null +++ b/core/modules/layout_builder/tests/modules/layout_builder_recursive_test/config/install/core.entity_view_display.node.type_with_recursion.default.yml @@ -0,0 +1,66 @@ @@ -367,7 +367,7 @@ +hidden: { } diff --git a/core/modules/layout_builder/tests/modules/layout_builder_recursive_test/config/install/core.entity_view_display.node.type_with_recursion.teaser.yml b/core/modules/layout_builder/tests/modules/layout_builder_recursive_test/config/install/core.entity_view_display.node.type_with_recursion.teaser.yml new file mode 100644 -index 0000000000..7f2fcada1f +index 0000000..7f2fcad --- /dev/null +++ b/core/modules/layout_builder/tests/modules/layout_builder_recursive_test/config/install/core.entity_view_display.node.type_with_recursion.teaser.yml @@ -0,0 +1,54 @@ @@ -427,7 +427,7 @@ +hidden: { } diff --git a/core/modules/layout_builder/tests/modules/layout_builder_recursive_test/config/install/field.field.node.type_with_recursion.body.yml b/core/modules/layout_builder/tests/modules/layout_builder_recursive_test/config/install/field.field.node.type_with_recursion.body.yml new file mode 100644 -index 0000000000..4fa0b933dc +index 0000000..4fa0b93 --- /dev/null +++ b/core/modules/layout_builder/tests/modules/layout_builder_recursive_test/config/install/field.field.node.type_with_recursion.body.yml @@ -0,0 +1,21 @@ @@ -454,7 +454,7 @@ +field_type: text_with_summary diff --git a/core/modules/layout_builder/tests/modules/layout_builder_recursive_test/config/install/node.type.type_with_recursion.yml b/core/modules/layout_builder/tests/modules/layout_builder_recursive_test/config/install/node.type.type_with_recursion.yml new file mode 100644 -index 0000000000..d351be868d +index 0000000..d351be8 --- /dev/null +++ b/core/modules/layout_builder/tests/modules/layout_builder_recursive_test/config/install/node.type.type_with_recursion.yml @@ -0,0 +1,9 @@ @@ -469,7 +469,7 @@ +display_submitted: true diff --git a/core/modules/layout_builder/tests/modules/layout_builder_recursive_test/config/install/views.view.list_all_nodes.yml b/core/modules/layout_builder/tests/modules/layout_builder_recursive_test/config/install/views.view.list_all_nodes.yml new file mode 100644 -index 0000000000..c6b70d02b3 +index 0000000..c6b70d0 --- /dev/null +++ b/core/modules/layout_builder/tests/modules/layout_builder_recursive_test/config/install/views.view.list_all_nodes.yml @@ -0,0 +1,165 @@ @@ -640,7 +640,7 @@ + tags: { } diff --git a/core/modules/layout_builder/tests/modules/layout_builder_recursive_test/layout_builder_recursive_test.info.yml b/core/modules/layout_builder/tests/modules/layout_builder_recursive_test/layout_builder_recursive_test.info.yml new file mode 100644 -index 0000000000..7025992b06 +index 0000000..7025992 --- /dev/null +++ b/core/modules/layout_builder/tests/modules/layout_builder_recursive_test/layout_builder_recursive_test.info.yml @@ -0,0 +1,8 @@ @@ -653,7 +653,7 @@ +dependencies: + - views diff --git a/core/modules/layout_builder/tests/modules/layout_builder_test/config/schema/layout_builder_test.schema.yml b/core/modules/layout_builder/tests/modules/layout_builder_test/config/schema/layout_builder_test.schema.yml -index 75050837fa..8ba8237a84 100644 +index 7505083..8ba8237 100644 --- a/core/modules/layout_builder/tests/modules/layout_builder_test/config/schema/layout_builder_test.schema.yml +++ b/core/modules/layout_builder/tests/modules/layout_builder_test/config/schema/layout_builder_test.schema.yml @@ -5,3 +5,13 @@ layout_builder_test.test_simple_config.*: @@ -672,7 +672,7 @@ + type: integer diff --git a/core/modules/layout_builder/tests/modules/layout_builder_test/src/Plugin/Block/EntityBlock.php b/core/modules/layout_builder/tests/modules/layout_builder_test/src/Plugin/Block/EntityBlock.php new file mode 100644 -index 0000000000..711684b44e +index 0000000..711684b --- /dev/null +++ b/core/modules/layout_builder/tests/modules/layout_builder_test/src/Plugin/Block/EntityBlock.php @@ -0,0 +1,39 @@ @@ -717,7 +717,7 @@ +} diff --git a/core/modules/layout_builder/tests/src/Functional/LayoutRecursionTest.php b/core/modules/layout_builder/tests/src/Functional/LayoutRecursionTest.php new file mode 100644 -index 0000000000..5ef4957f0d +index 0000000..5ef4957 --- /dev/null +++ b/core/modules/layout_builder/tests/src/Functional/LayoutRecursionTest.php @@ -0,0 +1,66 @@ @@ -788,7 +788,7 @@ + +} diff --git a/core/modules/layout_builder/tests/src/Kernel/LayoutBuilderCompatibilityTestBase.php b/core/modules/layout_builder/tests/src/Kernel/LayoutBuilderCompatibilityTestBase.php -index 72ee01ac60..3f244297ae 100644 +index fa1047c..d2e2488 100644 --- a/core/modules/layout_builder/tests/src/Kernel/LayoutBuilderCompatibilityTestBase.php +++ b/core/modules/layout_builder/tests/src/Kernel/LayoutBuilderCompatibilityTestBase.php @@ -6,6 +6,7 @@ @@ -815,7 +815,7 @@ $actual = array_map(function (\SimpleXMLElement $element) { diff --git a/core/modules/layout_builder/tests/src/Kernel/SectionComponentRecursionTest.php b/core/modules/layout_builder/tests/src/Kernel/SectionComponentRecursionTest.php new file mode 100644 -index 0000000000..e4cafea597 +index 0000000..e4cafea --- /dev/null +++ b/core/modules/layout_builder/tests/src/Kernel/SectionComponentRecursionTest.php @@ -0,0 +1,79 @@