Skip to content
Closed
Show file tree
Hide file tree
Changes from 2 commits
Commits
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
20 changes: 19 additions & 1 deletion src/wp-includes/class-wp-dependencies.php
Original file line number Diff line number Diff line change
Expand Up @@ -200,9 +200,27 @@ public function all_deps( $handles, $recursion = false, $group = false ) {
}

$keep_going = true;
$missing_dependencies = ( isset( $this->registered[ $handle ] ) && $this->registered[ $handle ]->deps ) ? array_diff( $this->registered[ $handle ]->deps, array_keys( $this->registered ) ) : array();
Comment thread
deepakpra marked this conversation as resolved.
Outdated
if ( ! isset( $this->registered[ $handle ] ) ) {
$keep_going = false; // Item doesn't exist.
} elseif ( $this->registered[ $handle ]->deps && array_diff( $this->registered[ $handle ]->deps, array_keys( $this->registered ) ) ) {
} elseif ( $missing_dependencies ) {
Comment thread
deepakpra marked this conversation as resolved.
Outdated
// Prevent duplicate notices.
static $reported = array();

if ( ! isset( $reported[ $handle ] ) ) {
$reported[ $handle ] = true;
Comment thread
deepakpra marked this conversation as resolved.
Outdated

_doing_it_wrong(
__METHOD__,
sprintf(
/* translators: 1: Script module ID, 2: Comma-separated list of missing dependency IDs. */
__( 'The script with the handle %1$s was enqueued with dependencies that are not registered: %2$s.' ),
Comment thread
deepakpra marked this conversation as resolved.
Outdated
$handle,
implode( ', ', $missing_dependencies )
),
'7.0.0'
);
}
$keep_going = false; // Item requires dependencies that don't exist.
} elseif ( $this->registered[ $handle ]->deps && ! $this->all_deps( $this->registered[ $handle ]->deps, true, $new_group ) ) {
$keep_going = false; // Item requires dependencies that don't exist.
Expand Down
21 changes: 20 additions & 1 deletion src/wp-includes/class-wp-script-modules.php
Original file line number Diff line number Diff line change
Expand Up @@ -722,7 +722,26 @@ private function sort_item_dependencies( string $id, array $import_types, array
}

// If the item requires dependencies that do not exist, fail.
if ( count( array_diff( $dependency_ids, array_keys( $this->registered ) ) ) > 0 ) {
$missing_dependencies = array_diff( $dependency_ids, array_keys( $this->registered ) );
if ( count( $missing_dependencies ) > 0 ) {
// Prevent duplicate notices.
static $reported = array();

if ( ! isset( $reported[ $id ] ) ) {
$reported[ $id ] = true;

_doing_it_wrong(
__METHOD__,
sprintf(
/* translators: 1: Script module ID, 2: Comma-separated list of missing dependency IDs. */
__( 'The script module %1$s was enqueued with dependencies that are not registered: %2$s.' ),
$id,
implode( ', ', $missing_dependencies )
),
'7.0.0'
);
}

return false;
}

Expand Down
Loading