From 0cde19b503ec876142c94ffd88f989c77b0beb77 Mon Sep 17 00:00:00 2001 From: Sergey Biryukov Date: Sun, 27 Mar 2022 14:45:04 +0000 Subject: [PATCH] Code Modernization: Rename parameters that use reserved keywords in `wp-admin/includes/class-plugin-upgrader.php`. While using reserved PHP keywords as parameter name labels is allowed, in the context of function calls using named parameters in PHP 8.0+, this will easily lead to confusion. To avoid that, it is recommended not to use reserved keywords as function parameter names. This commit renames the `$return` variable in `Plugin_Upgrader` class methods to `$response` and updates the documentation accordingly. Follow-up to [47409], [52946], [52996]. Props jrf, aristath, poena, justinahinon, SergeyBiryukov. See #55327. Built from https://develop.svn.wordpress.org/trunk@52997 git-svn-id: http://core.svn.wordpress.org/trunk@52586 1a063a9b-81f0-0310-95a4-ce76da25c4cd --- wp-admin/includes/class-plugin-upgrader.php | 54 ++++++++++----------- wp-admin/includes/class-wp-upgrader.php | 4 +- wp-includes/version.php | 2 +- 3 files changed, 30 insertions(+), 30 deletions(-) diff --git a/wp-admin/includes/class-plugin-upgrader.php b/wp-admin/includes/class-plugin-upgrader.php index 76083b5211..a8ccf7cd78 100644 --- a/wp-admin/includes/class-plugin-upgrader.php +++ b/wp-admin/includes/class-plugin-upgrader.php @@ -505,19 +505,19 @@ class Plugin_Upgrader extends WP_Upgrader { * @since 2.8.0 * @since 4.1.0 Added a return value. * - * @param bool|WP_Error $return Upgrade offer return. - * @param array $plugin Plugin package arguments. - * @return bool|WP_Error The passed in $return param or WP_Error. + * @param bool|WP_Error $response The installation response before the installation has started. + * @param array $plugin Plugin package arguments. + * @return bool|WP_Error The original `$response` parameter or WP_Error. */ - public function deactivate_plugin_before_upgrade( $return, $plugin ) { + public function deactivate_plugin_before_upgrade( $response, $plugin ) { - if ( is_wp_error( $return ) ) { // Bypass. - return $return; + if ( is_wp_error( $response ) ) { // Bypass. + return $response; } // When in cron (background updates) don't deactivate the plugin, as we require a browser to reactivate it. if ( wp_doing_cron() ) { - return $return; + return $response; } $plugin = isset( $plugin['plugin'] ) ? $plugin['plugin'] : ''; @@ -530,7 +530,7 @@ class Plugin_Upgrader extends WP_Upgrader { deactivate_plugins( $plugin, true ); } - return $return; + return $response; } /** @@ -540,25 +540,25 @@ class Plugin_Upgrader extends WP_Upgrader { * * @since 5.4.0 * - * @param bool|WP_Error $return Upgrade offer return. - * @param array $plugin Plugin package arguments. - * @return bool|WP_Error The passed in $return param or WP_Error. + * @param bool|WP_Error $response The installation response before the installation has started. + * @param array $plugin Plugin package arguments. + * @return bool|WP_Error The original `$response` parameter or WP_Error. */ - public function active_before( $return, $plugin ) { - if ( is_wp_error( $return ) ) { - return $return; + public function active_before( $response, $plugin ) { + if ( is_wp_error( $response ) ) { + return $response; } // Only enable maintenance mode when in cron (background update). if ( ! wp_doing_cron() ) { - return $return; + return $response; } $plugin = isset( $plugin['plugin'] ) ? $plugin['plugin'] : ''; // Only run if plugin is active. if ( ! is_plugin_active( $plugin ) ) { - return $return; + return $response; } // Change to maintenance mode. Bulk edit handles this separately. @@ -566,7 +566,7 @@ class Plugin_Upgrader extends WP_Upgrader { $this->maintenance_mode( true ); } - return $return; + return $response; } /** @@ -576,25 +576,25 @@ class Plugin_Upgrader extends WP_Upgrader { * * @since 5.4.0 * - * @param bool|WP_Error $return Upgrade offer return. - * @param array $plugin Plugin package arguments. - * @return bool|WP_Error The passed in $return param or WP_Error. + * @param bool|WP_Error $response The installation response after the installation has finished. + * @param array $plugin Plugin package arguments. + * @return bool|WP_Error The original `$response` parameter or WP_Error. */ - public function active_after( $return, $plugin ) { - if ( is_wp_error( $return ) ) { - return $return; + public function active_after( $response, $plugin ) { + if ( is_wp_error( $response ) ) { + return $response; } // Only disable maintenance mode when in cron (background update). if ( ! wp_doing_cron() ) { - return $return; + return $response; } $plugin = isset( $plugin['plugin'] ) ? $plugin['plugin'] : ''; - // Only run if plugin is active + // Only run if plugin is active. if ( ! is_plugin_active( $plugin ) ) { - return $return; + return $response; } // Time to remove maintenance mode. Bulk edit handles this separately. @@ -602,7 +602,7 @@ class Plugin_Upgrader extends WP_Upgrader { $this->maintenance_mode( false ); } - return $return; + return $response; } /** diff --git a/wp-admin/includes/class-wp-upgrader.php b/wp-admin/includes/class-wp-upgrader.php index e30da50c2c..38db50e09d 100644 --- a/wp-admin/includes/class-wp-upgrader.php +++ b/wp-admin/includes/class-wp-upgrader.php @@ -477,14 +477,14 @@ class WP_Upgrader { $this->skin->feedback( 'installing_package' ); /** - * Filters the install response before the installation has started. + * Filters the installation response before the installation has started. * * Returning a value that could be evaluated as a `WP_Error` will effectively * short-circuit the installation, returning that value instead. * * @since 2.8.0 * - * @param bool|WP_Error $response Response. + * @param bool|WP_Error $response Installation response. * @param array $hook_extra Extra arguments passed to hooked filters. */ $res = apply_filters( 'upgrader_pre_install', true, $args['hook_extra'] ); diff --git a/wp-includes/version.php b/wp-includes/version.php index 60bfb3f39a..26c20f1c73 100644 --- a/wp-includes/version.php +++ b/wp-includes/version.php @@ -16,7 +16,7 @@ * * @global string $wp_version */ -$wp_version = '6.0-alpha-52996'; +$wp_version = '6.0-alpha-52997'; /** * Holds the WordPress DB revision, increments when changes are made to the WordPress DB schema.