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<string, 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
This commit is contained in:
@@ -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<string, 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;
|
||||
}
|
||||
|
||||
/**
|
||||
|
||||
@@ -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.
|
||||
|
||||
Reference in New Issue
Block a user