Skip to content
Closed
Changes from 1 commit
Commits
Show all changes
22 commits
Select commit Hold shift + click to select a range
ee14eb6
Script Modules: Bump fetchpriority for dependencies to be as high as …
westonruter Sep 6, 2025
0222ca9
Add missing phpdoc param
westonruter Sep 6, 2025
e2d4676
Explicitly set a11y module to have fetchpriority=low
westonruter Sep 6, 2025
c76ceb0
Add support for fetchpriority bumping in WP_Scripts
westonruter Sep 6, 2025
e652cbd
Account for whether a dependent script is actually enqueued
westonruter Sep 6, 2025
3dd0e0f
Add tests for complex dependency graphs
westonruter Sep 11, 2025
c59f440
Let fetchpriority of script module be determined be enqueued module
westonruter Sep 17, 2025
e453a53
Merge branch 'trunk' of https://github.com/WordPress/wordpress-develo…
westonruter Sep 29, 2025
546e7a7
Stop iterating once highest priority found
westonruter Sep 29, 2025
a03337a
Simplify get_recursive_dependents() with better defensive coding
westonruter Sep 29, 2025
0b0f328
Merge branch 'trunk' into add/dependent-fetchpriority-harmony
westonruter Oct 8, 2025
334a82b
Better harmonize get_highest_fetchpriority implementations
westonruter Oct 8, 2025
cf809c8
Merge branch 'trunk' into add/dependent-fetchpriority-harmony
westonruter Oct 10, 2025
3f5ae8d
Update _WP_Dependency::$ver to allow null in addition to string|false
westonruter Oct 12, 2025
4dd633f
Account for directly printed scripts without enqueueing
westonruter Oct 12, 2025
95789ba
Ensure fetchpriority is processed for scripts without extra key set
westonruter Oct 12, 2025
86c13c9
Merge branch 'trunk' of https://github.com/WordPress/wordpress-develo…
westonruter Oct 13, 2025
98abb51
Switch back to enqueue
westonruter Oct 13, 2025
eada641
Merge branch 'trunk' of https://github.com/WordPress/wordpress-develo…
westonruter Oct 14, 2025
05e3173
Restore array_unique()
westonruter Oct 14, 2025
ed8a53f
Add test for wp_default_script_modules()
westonruter Oct 14, 2025
9d021ae
Test that high priority dependent of default script modules causes de…
westonruter Oct 14, 2025
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Prev Previous commit
Next Next commit
Simplify get_recursive_dependents() with better defensive coding
  • Loading branch information
westonruter committed Sep 29, 2025
commit a03337a694c65f291a1590300a3359c0ec2a743a
15 changes: 7 additions & 8 deletions src/wp-includes/class-wp-script-modules.php
Original file line number Diff line number Diff line change
Expand Up @@ -502,24 +502,23 @@ private function get_dependents( string $id ): array {
* @return string[] Script module IDs.
*/
private function get_recursive_dependents( string $id ): array {
$get = function ( string $id, array $checked = array() ) use ( &$get ): ?array {
$get = function ( string $id, array $checked = array() ) use ( &$get ): array {

// If by chance an unregistered script module is checked or there is a recursive dependency, return early.
if ( ! isset( $this->registered[ $id ] ) || isset( $checked[ $id ] ) ) {
return null;
return array();
}

// Mark this script module as checked to guard against infinite recursion.
$checked[ $id ] = true;

$dependents = array();
foreach ( $this->get_dependents( $id ) as $dependent ) {
$dependents[] = $dependent;

$recursive_dependents = $get( $dependent, $checked );
if ( is_array( $recursive_dependents ) ) {
$dependents = array_merge( $dependents, $recursive_dependents );
}
$dependents = array_merge(
$dependents,
array( $dependent ),
$get( $dependent, $checked )
);
}

return $dependents;
Expand Down
Loading