From 3dba61bc347aca7ae4b27e56eeec319abcb47bbe Mon Sep 17 00:00:00 2001 From: Weston Ruter Date: Mon, 27 Oct 2025 16:12:36 +0000 Subject: [PATCH] Script Loader: Restore original return value for `WP_Script_Modules::get_dependencies()`. Even though this method is private, there are some usages of it in the ecosystem via the Reflection API. So this reverts the script module IDs `string[]` return value in favor of the original `array` return value. This re-emphasizes the need for more public accessor methods being tracked in #60597. Developed in https://github.com/WordPress/wordpress-develop/pull/10403 Follow-up to [60999]. Props pbiron, westonruter, johnbillion. See #63486, #60597. Built from https://develop.svn.wordpress.org/trunk@61073 git-svn-id: http://core.svn.wordpress.org/trunk@60409 1a063a9b-81f0-0310-95a4-ce76da25c4cd --- wp-includes/class-wp-script-modules.php | 10 +++++----- wp-includes/version.php | 2 +- 2 files changed, 6 insertions(+), 6 deletions(-) diff --git a/wp-includes/class-wp-script-modules.php b/wp-includes/class-wp-script-modules.php index 838c0eaf9c..6a919e2625 100644 --- a/wp-includes/class-wp-script-modules.php +++ b/wp-includes/class-wp-script-modules.php @@ -398,7 +398,7 @@ class WP_Script_Modules { ! $this->registered[ $id ]['in_footer'] ) { // If any dependency is set to be printed in footer, skip printing this module in head. - $dependencies = $this->get_dependencies( array( $id ) ); + $dependencies = array_keys( $this->get_dependencies( array( $id ) ) ); foreach ( $dependencies as $dependency_id ) { if ( in_array( $dependency_id, $this->queue, true ) && @@ -528,7 +528,7 @@ class WP_Script_Modules { */ private function get_import_map(): array { $imports = array(); - foreach ( $this->get_dependencies( $this->queue ) as $id ) { + foreach ( array_keys( $this->get_dependencies( $this->queue ) ) as $id ) { $src = $this->get_src( $id ); if ( '' !== $src ) { $imports[ $id ] = $src; @@ -566,7 +566,7 @@ class WP_Script_Modules { * @param string[] $ids The identifiers of the script modules for which to gather dependencies. * @param string[] $import_types Optional. Import types of dependencies to retrieve: 'static', 'dynamic', or both. * Default is both. - * @return string[] List of IDs for script module dependencies. + * @return array List of dependencies, keyed by script module identifier. */ private function get_dependencies( array $ids, array $import_types = array( 'static', 'dynamic' ) ): array { $all_dependencies = array(); @@ -584,7 +584,7 @@ class WP_Script_Modules { in_array( $dependency['import'], $import_types, true ) && isset( $this->registered[ $dependency['id'] ] ) ) { - $all_dependencies[ $dependency['id'] ] = true; + $all_dependencies[ $dependency['id'] ] = $this->registered[ $dependency['id'] ]; // Add this dependency to the list to get dependencies for. $id_queue[] = $dependency['id']; @@ -592,7 +592,7 @@ class WP_Script_Modules { } } - return array_keys( $all_dependencies ); + return $all_dependencies; } /** diff --git a/wp-includes/version.php b/wp-includes/version.php index 8c61b0577c..73298ef1ec 100644 --- a/wp-includes/version.php +++ b/wp-includes/version.php @@ -16,7 +16,7 @@ * * @global string $wp_version */ -$wp_version = '6.9-beta1-61072'; +$wp_version = '6.9-beta1-61073'; /** * Holds the WordPress DB revision, increments when changes are made to the WordPress DB schema.