Gutenberg: Self-Referencing Reusable Block Crashes Blocks and Pages/Posts

Created on 24 Mar 2020  路  3Comments  路  Source: WordPress/gutenberg

Describe the bug
I'm not 100% sure how users are figuring this out, but I have figured out a way to replicate.

If a Reusable Block self-references, it will crash the post and the editor. This was originally found on a WordPress.com site, and can be replicated on WordPress.com. When tested on a core install, it was able to reproduced as well.

I also tested on a core install and was able to reproduce issues there, specifically fatal errors due to timeouts in /wp-includes/class-wp-block-parser.php on line 417 and /wp-includes/class-wp-block-parser.php on line 417.

The original bug report was filed in wp-calypso, here: https://github.com/Automattic/wp-calypso/issues/38929

It looks like this was also reported in 2018 (https://github.com/WordPress/gutenberg/issues/11206), but was closed. We've had a number of users somehow replicate this on .com, so reopening to see if this can be looked into again.

To reproduce
Steps to reproduce the behavior:

  1. Create a post. Add a Paragraph Block with some text in it.
  2. Make that block a Reusable Block. Give it a name (just to distinguish it). Save. Publish the post. Open the post in a new tab.
  3. Create a new post.
  4. Click to add a block, go to Reusable Blocks - Manage All Reusable Blocks. (At the moment on WordPress.com at least, you need to open this in a new tab. Opening it in the same window will fail. See https://github.com/Automattic/wp-calypso/issues/38928) It appears on core, this works as intended.
  5. Hover over the block you've created, and click Classic Editor.
  6. When editing the block in the classic editor, make the block refer to itself by adding:
    <!-- wp:block {"ref":BLOCK-NUMBER-HERE} /-->
  7. If you don't have the Classic Editor option, change from Visual Editor to Code Editor, and make the block refer to itself by adding:
    <!-- wp:block {"ref":BLOCK-NUMBER-HERE} /-->
  8. The Block Number can be found in the URL.
  9. Update the Block. You may get an error here, or it might update cleanly.
  10. Refresh the post this reusable block appears on. The post will be broken.
  11. The editor for the post may also fail to load, and the editor for the block could also fail to load.
  12. At least on WordPress.com, this would also make posts/pages disappear entirely until the Reusable Block that self-references is accessed and removed.

Expected behavior
The Reusable Block to not crash the editor and the pages.

Screenshots
This .gif was taken from the original report on a WordPress.com hosted site:
72672023-a1fbbb00-3a08-11ea-8586-bb3b292795d7

Desktop (please complete the following information):
This works on all desktops/browsers. Originally discovered on:
Windows 10
Chrome Version 80.0.3987.149 (Official Build) (64-bit)

Additional context

  • Please add the version of Gutenberg you are using in the description.
    Testing was done on WordPress Version 5.3.2
Needs Testing [Block] Block [Feature] Reusable Blocks

All 3 comments

@scosgro It looks like some of the instructions in your steps for reproduction are missing. Would be great if you could update that.

  1. When editing the block in the classic editor, make the block refer to itself by adding:
  1. If you don't have the Classic Editor option, change from Visual Editor to Code Editor, and make the block refer to itself by adding:

Code was disappearing. Sorry about that. Fixed!

Was this page helpful?
0 / 5 - 0 ratings

Related issues

wpalchemist picture wpalchemist  路  3Comments

davidsword picture davidsword  路  3Comments

jasmussen picture jasmussen  路  3Comments

BE-Webdesign picture BE-Webdesign  路  3Comments

aaronjorbin picture aaronjorbin  路  3Comments