Skip to content

Commit 3dba61b

Browse files
committed
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 WordPress/wordpress-develop#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
1 parent 94a866a commit 3dba61b

File tree

2 files changed

+6
-6
lines changed

2 files changed

+6
-6
lines changed

wp-includes/class-wp-script-modules.php

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -398,7 +398,7 @@ public function print_head_enqueued_script_modules() {
398398
! $this->registered[ $id ]['in_footer']
399399
) {
400400
// If any dependency is set to be printed in footer, skip printing this module in head.
401-
$dependencies = $this->get_dependencies( array( $id ) );
401+
$dependencies = array_keys( $this->get_dependencies( array( $id ) ) );
402402
foreach ( $dependencies as $dependency_id ) {
403403
if (
404404
in_array( $dependency_id, $this->queue, true ) &&
@@ -528,7 +528,7 @@ public function print_import_map() {
528528
*/
529529
private function get_import_map(): array {
530530
$imports = array();
531-
foreach ( $this->get_dependencies( $this->queue ) as $id ) {
531+
foreach ( array_keys( $this->get_dependencies( $this->queue ) ) as $id ) {
532532
$src = $this->get_src( $id );
533533
if ( '' !== $src ) {
534534
$imports[ $id ] = $src;
@@ -566,7 +566,7 @@ private function get_marked_for_enqueue(): array {
566566
* @param string[] $ids The identifiers of the script modules for which to gather dependencies.
567567
* @param string[] $import_types Optional. Import types of dependencies to retrieve: 'static', 'dynamic', or both.
568568
* Default is both.
569-
* @return string[] List of IDs for script module dependencies.
569+
* @return array<string, array> List of dependencies, keyed by script module identifier.
570570
*/
571571
private function get_dependencies( array $ids, array $import_types = array( 'static', 'dynamic' ) ): array {
572572
$all_dependencies = array();
@@ -584,15 +584,15 @@ private function get_dependencies( array $ids, array $import_types = array( 'sta
584584
in_array( $dependency['import'], $import_types, true ) &&
585585
isset( $this->registered[ $dependency['id'] ] )
586586
) {
587-
$all_dependencies[ $dependency['id'] ] = true;
587+
$all_dependencies[ $dependency['id'] ] = $this->registered[ $dependency['id'] ];
588588

589589
// Add this dependency to the list to get dependencies for.
590590
$id_queue[] = $dependency['id'];
591591
}
592592
}
593593
}
594594

595-
return array_keys( $all_dependencies );
595+
return $all_dependencies;
596596
}
597597

598598
/**

wp-includes/version.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,7 @@
1616
*
1717
* @global string $wp_version
1818
*/
19-
$wp_version = '6.9-beta1-61072';
19+
$wp_version = '6.9-beta1-61073';
2020

2121
/**
2222
* Holds the WordPress DB revision, increments when changes are made to the WordPress DB schema.

0 commit comments

Comments
 (0)