Repository navigation
Prevent endless expansion of cyclic synced patterns - #126
Merged
Merged
Conversation
alecgeatches
requested changes
Nov 19, 2026
alecgeatches
left a comment
Contributor
There was a problem hiding this comment.
@ingeniumed Cool audit and fix! Added some suggestions to make comments and variable names a bit clearer about what's happening, and an odd recursion bug that's still possible.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Description
A synced pattern can reference itself, directly or through another pattern. WordPress stops these cycles while rendering, but this plugin subsequently loads the referenced patterns again to extract their blocks. That starts the cycle again after core’s recursion guard has finished, allowing an API request to keep expanding the same patterns rather than complete.
Track pattern references along the current ancestor path and stop expanding a reference already on that path. Separate occurrences of the same pattern remain supported.
The plugin also unnecessarily reloads and renders pattern children that WordPress 6.9+ already retains. Reuse those rendered children instead. WordPress 6.8 still needs the existing compatibility path, so its second rendering pass remains unchanged.
Screenshots are not applicable to this API change.
Steps to Test
Run against WordPress 6.8, 6.9 and 7.1:
composer phpcs composer test composer test-multisiteThe regression tests cover direct and indirect cycles, repeated sibling references, render counts, reentrant parsing, and blocks generated inside dynamic callbacks.