-
Notifications
You must be signed in to change notification settings - Fork 4.2k
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 errors due to infinite recursion with Full Site Editing #26923
Comments
I agree with you about most of the recursive constructs you mentioned and reported the same issue myself (it was closed as a duplicate of #18704, this one probably will be too.) The one recursive construct you mentioned that I would dispute is the post excerpt. This shouldn't ever cause infinite recursion because it's only plain text. The other 3 and combinations of them are the only cases I'm aware of. |
I also agree a more holistic solution needs to be found to this. The solution that was deployed to #22080 was a bit of a band-aid that overlooked the many other ways this can present. |
On closer inspection, you might be right about the post excerpt. Although it doesn't output blocks on the front-end, it does process blocks behind the scenes. That said, any block at all could process blocks behind the scenes and that just highlights the need for a holistic solution rather than block-specific fixes. |
I think this could be fixed with some kind of global/static array that keeps track of the blocks currently being rendered. This could be done by modifying Here is an example with some pseudocode: Block A renders blocks B and C
|
Hi @carlomanf looks like we're both working to solve the issue. Your PR is a simpler version of the solution I developed. I suppose I should make comments in the PR. Meanwhile I'm working on developing my own fix that attempts to report to the user the fact that recursion has occurred. I have an idea how I can deal with the recursive reusable blocks in the editor. I really hope no one attempts to close this as a duplicate of #18704. |
It should be as simple as defining a flag in supports that prevents you from inserting a given block inside the same type of block. We have a very similar |
Only the simplest case is simple. Users and developers find all sorts of ways to create infinitely recursive constructs. For my reusable blocks scenario I found an edge case where my logic didn't detect recursion. I believe this was because the post being edited, that was eventually being called recursively was a Draft. |
Surely you can tweak the content in the database or provide a template that is broken by design. The question is how it should be handled. Maybe it should throw an error to give some feedback to developers/designers. I still think that we have to prevent it from happening through UI. So that's two tasks in one. |
That's what I'm working on right now. I managed to handle the recursion in the front end - with visual feeback indicating where the recursion happened. Now I'm looking at handling it in the editor. For the reusable blocks issue, even though I've prevented recursion in the REST API while rendering the post_content, the front end is still trying to process each When recursion has been detected in the back end I'm hoping to effectively disable the culprit block in the raw
|
When recursion is detected in the server I have managed to fiddle the REST API response to allow the block editor to load up a modified version of the Reusable block, with any This however doesn't prevent the user from inserting the original reusable block again, nor any of the other blocks that cause the recursion. I've not looked at the .js code so don't know what it's doing, but I can see that it's looping itself and not talking to the server. |
That's correct. There are two tasks:
I don't think there should be feedback on the front-end, because it's visible to all site visitors. My patch at #26951 just escapes it with an empty string so site visitors are none the wiser. |
|
Maybe, but if the system can detect it at the time of editing then it should be reported there and then, instead of waiting for someone to load the front-end. |
I take it you're agreeing that there should be some ability to provide feedback to the user, preferably in the editor. How that is achieved has yet to be designed. My requirements would include:
|
With Gutenberg 10.0.0 this problem has now become worse. If you try to insert a To reproduce
Two things can happen.
In the console the message is Uncaught Error: Maximum update depth exceeded. This can happen when a component repeatedly calls setState inside componentWillUpdate or componentDidUpdate. React limits the number of nested updates to prevent infinite loops. or |
I've found a new scenario where the post-content block causes the browser to hang. I wrote a plugin called oik-patterns to load patterns directly from I reduced the problem to the simplest... inserting a I've had multiple results:
|
I believe a solution for this have been already implemented. Closing for now. cc @mcsf |
Correct. For the editor, there is now a RecursionProvider component, as well as simple conventions for preventing recursion on the front end. Originally implemented in #28405, #28456, #31455. |
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 owncore/query
andcore/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:
plus, to be confirmed
To reproduce
Steps to reproduce the behavior:
Notes:
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.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):
Desktop (please complete the following information):
Additional context
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#27The text was updated successfully, but these errors were encountered: