From bf3296a9a05b99dc1a82af56351759eea4adddef Mon Sep 17 00:00:00 2001 From: Sergey Biryukov Date: Wed, 6 May 2020 16:27:12 +0000 Subject: [PATCH] Script Loader: Add the `$group` parameter to `WP_Dependencies::do_item()`. Previously, the method was called with two parameters in `::do_items()`, while the method signature only included one parameter. Technically, this was not an issue as `WP_Dependencies::do_item()` is a placeholder meant to be overwritten when extending the class. When handling scripts, `WP_Dependencies` is extended with `WP_Scripts`, and the `$group` parameter was only used in `WP_Scripts::do_item()`, which does expect a second argument. However, officially adding the parameter to `WP_Dependencies::do_item()` signature prevents code misunderstanding and avoids a warning in PHP code inspection tools. Props kaggdesign, soulseekah, azaozz, SergeyBiryukov. Fixes #43627. Built from https://develop.svn.wordpress.org/trunk@47769 git-svn-id: http://core.svn.wordpress.org/trunk@47545 1a063a9b-81f0-0310-95a4-ce76da25c4cd --- wp-includes/class.wp-dependencies.php | 7 +++++-- wp-includes/class.wp-styles.php | 7 +++++-- wp-includes/version.php | 2 +- 3 files changed, 11 insertions(+), 5 deletions(-) diff --git a/wp-includes/class.wp-dependencies.php b/wp-includes/class.wp-dependencies.php index 313faa19ed..9ed26568ed 100644 --- a/wp-includes/class.wp-dependencies.php +++ b/wp-includes/class.wp-dependencies.php @@ -128,11 +128,14 @@ class WP_Dependencies { * Processes a dependency. * * @since 2.6.0 + * @since 5.5.0 Added the `$group` parameter. * - * @param string $handle Name of the item. Should be unique. + * @param string $handle Name of the item. Should be unique. + * @param int|false $group Optional. Group level: level (int), no groups (false). + * Default false. * @return bool True on success, false if not set. */ - public function do_item( $handle ) { + public function do_item( $handle, $group = false ) { return isset( $this->registered[ $handle ] ); } diff --git a/wp-includes/class.wp-styles.php b/wp-includes/class.wp-styles.php index a84efb278f..2a4780222a 100644 --- a/wp-includes/class.wp-styles.php +++ b/wp-includes/class.wp-styles.php @@ -139,13 +139,16 @@ class WP_Styles extends WP_Dependencies { * Processes a style dependency. * * @since 2.6.0 + * @since 5.5.0 Added the `$group` parameter. * * @see WP_Dependencies::do_item() * - * @param string $handle The style's registered handle. + * @param string $handle The style's registered handle. + * @param int|false $group Optional. Group level: level (int), no groups (false). + * Default false. * @return bool True on success, false on failure. */ - public function do_item( $handle ) { + public function do_item( $handle, $group = false ) { if ( ! parent::do_item( $handle ) ) { return false; } diff --git a/wp-includes/version.php b/wp-includes/version.php index ad2bb8b4ce..b5b4321650 100644 --- a/wp-includes/version.php +++ b/wp-includes/version.php @@ -13,7 +13,7 @@ * * @global string $wp_version */ -$wp_version = '5.5-alpha-47768'; +$wp_version = '5.5-alpha-47769'; /** * Holds the WordPress DB revision, increments when changes are made to the WordPress DB schema.