Able to create recursive blocks in Layout Builder

Created on 5 September 2023, over 1 year ago
Updated 17 April 2024, 8 months ago

Problem/Motivation

Within Layout Builder - If you are really REALLY stupid - it is possible to recursively reference the block that you are building the layout for, by inserting it into itself, and then throw your site into an Escher-esk Death Spiral. This works especially well if you put your apocalypse-block into your sites footer, where it will cause your site to crash whichever page you try to display. An additional bonus is that it is then basically impossible to remove your block-of-doom, because it is ALWAYS in use somewhere inside itself.

Steps to reproduce

Structure > Block Types > Add block Type
Label = Test_recursive_block
Save

Structure > Block Types > Test_recursive_block - Manage Display
Use Layout Builder = Ticked
Save

Edit layout for Test_recursive_block >
- Remove the existing Section 1
- Add Section, 1 column, Admin label = XYZ, Add section
- Add block, Create content block = Test_recursive_block, Title = Blah, Style = block1, Add Block

Then put Test_recursive_block on a page somewhere, or better yet, incorporate it into your site's footer.

Proposed resolution

In Layout Builder - prevent the name of the block that you are currently building the layout for from appearing in the list of blocks available under Create content block.

At the time I was trying to style a block using Builder Styles + Asset Injector. If I remember correctly this resulted in a 500 error, but I was pretty traumatized at the time so it may have been something else.

Remaining tasks

User interface changes

API changes

Data model changes

Release notes snippet

🐛 Bug report
Status

Closed: duplicate

Version

11.0 🔥

Component
Layout builder 

Last updated 4 days ago

Created by

Live updates comments and jobs are added and updated live.
  • Needs tests

    The change is currently missing an automated test that fails when run with the original code, and succeeds when the bug has been fixed.

Sign in to follow issues

Merge Requests

Comments & Activities

Production build 0.71.5 2024