-
Notifications
You must be signed in to change notification settings - Fork 4.5k
Description
Describe the bug
When using Full Site Editing it is fairly easy to create scenarios which lead to the website failing due to infinite recursion.
Some work has been done to prevent the problems occurring visually in the editor, but once saved it becomes very difficult to recover from the problem.
In the simplest scenario below the recursion involves a single post using the core/post-content
block. More complex scenarios involve multiple posts each with their own core/query
and core/post-content
blocks.
WordPress core needs to appreciate that this infinite recursion can occur, take steps to prevent it and produce relevant information to the content creator and/or front end user to explain the actions taken.
I'm raising this as a separate issue to #26593, although I believe the root cause of both problems is the same.
That is, the inability to detect and prevent infinite recursion while processing potentially recursive constructs.
These recursive constructs include:
- Post Content ( core/post-content )
- Reusable blocks ( core/block )
- Template parts ( core/template-parts )
plus, to be confirmed
- possibly Post Excerpt ( core/post-excerpt )
- Combinations of the above, if that's possible.
To reproduce
Steps to reproduce the behavior:
- Activate a Full Site Editing theme such as Twenty Twenty-One Blocks
- Activate Gutenberg as the only plugin.
- Create a new post.
- Insert a Post Content block
- Save
- View
- See the Fatal error
Notes:
- You may get a Publishing failed message while attempting to Publish the post.
- This message is the first evidence of the problem.
- If you change the post to remove the
core/post-content
block and save again then you're in Infinite recursion trying to edit a wp_template with revisions containing wp:post-content blocks #26593 territory. - Once published you will get Fatal errors if you try to Edit the post.
Expected behavior
The infinite recursion should be detected, halted gracefully and an appropriate message reported to the user.
In WP_DEBUG
mode contextual information should be displayed to assist with problem resolution.
Screenshots
In this screenshot the Fatal error occurs when the Allowed memory is exceeded.
Editor version (please complete the following information):
- WordPress version: [e.g: 5.3.2] 5.6-beta3
- Does the website has Gutenberg plugin installed, or is it using the block editor that comes by default? [e.g: "gutenberg plugin", "default"] Gutenberg 9.3.0 and/or Gutenberg built from source
Desktop (please complete the following information):
- OS: [e.g. iOS] Windows
- Browser [e.g. chrome, safari] Chrome
- Version [e.g. 22] Latest
Additional context
- See also FSE: Adding a post content block to a post causes a WSOD #22080 (comment) where the basic problem was first mentioned.
- Infinite recursion trying to edit a wp_template with revisions containing wp:post-content blocks #26593 - which is a convoluted form of the basic problem
- I have not yet looked at 500 error and 'Reusable' tab disappears when a reusable block is embedded into itself #18704
- For a more complex scenario involving multiple posts containing
core/query
blocks withcore/post-content
within thecore/query-loop
see Fatal error: memory exhausted viewing a post containing acore/post-content
block bobbingwide/fizzie#27 - I've developed a solution to the problem which is along the lines of the solution I developed for a parallel scenario involving shortcodes. See [bw_pages] - Infinite recursion processing post content bobbingwide/oik#166