Repository navigation
Script Loader: Prevent infinite recursion on circular dependencies in WP_Dependencies::all_deps() - #16245
Script Loader: Prevent infinite recursion on circular dependencies in WP_Dependencies::all_deps()#16245irozum wants to merge 2 commits into
Conversation
… WP_Dependencies::all_deps()
|
The following accounts have interacted with this PR and/or linked issues. I will continue to update these lists as activity occurs. Core Committers: Use this line as a base for the props when committing in SVN: To understand the WordPress project's expectations around crediting contributors, please review the Contributor Attribution page in the Core Handbook. Props Bot commandsYou can trigger Props Bot actions by commenting on this PR:
|
Test using WordPress PlaygroundThe changes in this pull request can previewed and tested using a WordPress Playground instance. WordPress Playground is an experimental project that creates a full WordPress instance entirely within the browser. Some things to be aware of
For more details about these limitations and more, check out the Limitations page in the WordPress Playground documentation. |
WP_Dependencies::all_deps()recurses into a handle's dependencies without tracking which handles are already being resolved, so any self-dependency or circular dependency recurses until PHP runs out of memory. The ticket's trigger iswp_set_script_translations( 'wp-i18n' ), which addswp-i18nas a dependency of itself, but the same happens for any cycle (for examplewp_set_script_translations( 'wp-hooks' )whenwp-i18ndepends onwp-hooks).WP_ScriptsandWP_Stylesboth inherit this behaviour.Changes
$handles_being_resolvedproperty ofWP_Dependencies.all_deps()meets a handle that is already being resolved further up the stack, it treats it as resolved instead of recursing again. The check runs beforeset_group(), so a circular revisit can't move the handle's group.all_deps()docblock, which previously said it does not catch infinite loops.Notes
WP_Scripts::set_translations()is intentionally unchanged. A_doing_it_wrong()notice forwp_set_script_translations( 'wp-i18n' )could be a follow-up.Tests
Tests_Dependencies: self-dependency, circular, indirect circular, shared dependency, and circular with a missing dependency.Tests_Dependencies_Scripts:wp_set_script_translations()onwp-i18n, and a cycle throughwp-i18n.Trac ticket: https://core.trac.wordpress.org/ticket/46089
Use of AI Tools
AI assistance: Yes
Tool(s): Claude Code
Model(s): Claude Sonnet 5.5
Used for: Implementation, tests, and PR description.
This Pull Request is for code review only. Please keep all other discussion in the Trac ticket. Do not merge this Pull Request. See GitHub Pull Requests for Code Review in the Core Handbook for more details.
🤖 Generated with Claude Code