-
Notifications
You must be signed in to change notification settings - Fork 4.3k
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
Blocks: Implement recursion checking and reporting for template-parts, post-content and reusable blocks (#26923) #27012
Conversation
So, compared to my PR, the only advantage of this one is it reports the error depending on I'm happy to add that feature to my PR, considering mine solves the same bug with 4% of the amount of code that yours does.
Regarding this point, I should also point out that any third-party plugin can add a block type that has the potential for infinite recursion, and my PR proactively prevents those as well. |
@carlomanf depending on how you're checking for recursions, I'm not sure catching all blocks is a good thing. For example, we can use group blocks inside group blocks that's fine and potentially we could build dynamic group blocks that render inside dynamic group blocks, that's fine too. |
@youknowriad I've added a comment to @carlomanf's PR that covers this problem - for the
Whichever solution is chosen, we will need to ensure that it's usable and extendable by third party plugins. |
The only things my patch is designed to "catch" are fatal errors. Everything else, it should let pass. That said, @bobbingwide has been very helpful in discovering some false positives, which I have since corrected. He believes he's found another one with the post title block, but I'm not able to reproduce it. It would be much appreciated if you could test the patch at #26951 and confirm whether you can reproduce Herb's false positive with the post title, or this other hypothetical scenario with group blocks. As far as I can tell, the patch works correctly and doesn't escape anything that wouldn't have otherwise caused a fatal error. |
@bobbingwide: thanks for the PR. However, in light of #28405 (merged) and #28456 (to be approved), is there anything left before it can be closed? |
Description
core/template-part
and/orcore/post-content
blocks.core/block
) was reported 500 error and 'Reusable' tab disappears when a reusable block is embedded into itself #18704.WP_Block
class.core/post-content
core/template-part
core/block
core/post-excerpt
to recurse.Both solutions rely on a test to see if the block that's about to be rendered is already being processed.
The logic implemented in each solution is:
Check if the block that's about to be rendered is already being rendered.
If it isn't already being rendered. ie It's safe to render
else don't render it
In the
WP_Block
fix the recursive block is rendered as an empty string. Neither the end user nor the site administrator is made aware that there was a recursion problem.In this solution, there is an option to report the recursion error.
The level of detail reported depends on the setting for
WP_DEBUG
This solution also supports extending the base solution for reporting recursion errors.
Regarding the reusable blocks issue ( #18704 )
How has this been tested?
Environment
Screenshots
Scenarios
Front end
404.html
template and a couple of recursive template parts.Types of changes
These changes also include the fixes applied for:
The solution introduces
load.php
Checklist:
My code is tested.
My code follows the WordPress code style.
My code follows the accessibility standards.
My code has proper inline documentation.
I've included developer documentation if appropriate.
I've updated all React Native files affected by any refactorings/renamings in this PR.
I've not delivered any automated tests.
I imagine the new functions will need documenting so that they can be used by other block developers who may have had to develop their own recursion checking.