Layout builder does not protect against recursion

Created on 12 June 2018, over 6 years ago
Updated 21 June 2024, 6 months ago

Problem/Motivation

The Layout builder module does not protect against recursion. If a Block Plugin which renders an entity is placed inside the same entity's layout, you will receive "Maximum function nesting level" errors. This was originally reported in #2976152: Don't allow placing a Custom Block in the layout override for itself or a default layout โ†’ , and is being mitigated in that issue by hiding known Block Plugins that cause this issue.

Steps to reproduce

We can work over the default "basic page" content type
1. Create a node for basic page content type.
2. Enable the core module "Layout Builder"
3. Create a view to show basic pages as a block:
- With contextual filter by "content ID"
- With a show as "content" and display as "default"
4. Alter the basic page "manage display" to show "default" as "layout builder"
5. Add to layout builder the block that you created at 3 step.
6. Show the node that you created at 1 step and should get the error "The website encountered an unexpected error. Please try again later." and at drupal log this is "Error: Xdebug has detected a possible infinite loop, and aborted your script with a stack depth of '256' frames in Drupal\Component\Plugin\PluginBase->__construct() (line 53 of /var/www/html/contributedrupal10/core/lib/Drupal/Component/Plugin/PluginBase.php)."

Proposed resolution

The mitigation is fine for now, but the Layout builder should have higher level recursion protection, similar to what the Entity Reference formatter does today.

Remaining tasks

Write a patch and tests.

User interface changes

None.

API changes

None.

Data model changes

None.

๐Ÿ› Bug report
Status

Needs work

Version

11.0 ๐Ÿ”ฅ

Component
Layout builderย  โ†’

Last updated 3 days ago

Created by

๐Ÿ‡บ๐Ÿ‡ธUnited States samuel.mortenson

Live updates comments and jobs are added and updated live.
  • Blocks-Layouts

    Blocks and Layouts Initiative. See the #2811175 Add layouts to Drupal issue.

  • Needs change record

    A change record needs to be drafted before an issue is committed. Note: Change records used to be called change notifications.

Sign in to follow issues

Merge Requests

Comments & Activities

Not all content is available!

It's likely this issue predates Contrib.social: some issue and comment data are missing.

Production build 0.71.5 2024