Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fatal error: cyclical embedded blocks #25472

Closed
carlomanf opened this issue Sep 19, 2020 · 1 comment
Closed

Fatal error: cyclical embedded blocks #25472

carlomanf opened this issue Sep 19, 2020 · 1 comment
Labels
[Feature] Synced Patterns Related to synced patterns (formerly reusable blocks) [Status] Duplicate Used to indicate that a current issue matches an existing one and can be closed [Type] Bug An existing feature does not function as intended

Comments

@carlomanf
Copy link

Describe the bug
#22080 fixed the infinite loop that occurred when the post content block tries to render the same post that it's embedded in.

This, however, isn't the only scenario where an infinite loop could occur. In theory, it could occur through:

  • any block that embeds block-based content (post content block, reusable block, template part and so on)
  • any cyclical combination of any of the above blocks embedding each other (cycle of 1 or more)

For example, I was able to produce a fatal error with two reusable blocks that embed each other:

Example 1
Steps to reproduce the behavior:

  1. Created a reusable block with id 168 and the following content:
<!-- wp:paragraph -->
<p>reusable 1 paragraph 1</p>
<!-- /wp:paragraph -->

<!-- wp:paragraph -->
<p>reusable 1 paragraph 2</p>
<!-- /wp:paragraph -->

<!-- wp:block {"ref":169} /-->
  1. Created a reusable block with id 169 and the following content:
<!-- wp:paragraph -->
<p>reusable 2 paragraph 1</p>
<!-- /wp:paragraph -->

<!-- wp:paragraph -->
<p>reusable 2 paragraph 2</p>
<!-- /wp:paragraph -->

<!-- wp:block {"ref":168} /-->
  1. See fatal error whenever either of these blocks is rendered

Example 2

  1. To illustrate that this happens with any cyclical combination of any of these block types, I changed the post type of 169 from wp_block to wp_template_part and updated the content of 168 accordingly:
<!-- wp:paragraph -->
<p>reusable 1 paragraph 1</p>
<!-- /wp:paragraph -->

<!-- wp:paragraph -->
<p>reusable 1 paragraph 2</p>
<!-- /wp:paragraph -->

<!-- wp:template-part {"postId":169,"slug":"untitled-reusable-block-2","theme":""} /-->
  1. 169 retains the same post content as example 1

  2. See fatal error whenever either reusable block or template part is rendered

Expected behavior
The expected behavior that I would suggest is to keep rendering a cycle of embedded blocks until one block tries to render a piece of content that is already part of the cycle, and then render a placeholder instead to break the cycle.

Editor version (please complete the following information):

  • WordPress 5.5 and Gutenberg 9.0
@talldan talldan added [Feature] Synced Patterns Related to synced patterns (formerly reusable blocks) [Status] Duplicate Used to indicate that a current issue matches an existing one and can be closed [Type] Bug An existing feature does not function as intended labels Sep 24, 2020
@talldan
Copy link
Contributor

talldan commented Sep 24, 2020

Closing as a duplicate of #18704

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
[Feature] Synced Patterns Related to synced patterns (formerly reusable blocks) [Status] Duplicate Used to indicate that a current issue matches an existing one and can be closed [Type] Bug An existing feature does not function as intended
Projects
None yet
Development

No branches or pull requests

2 participants