From 98604703604007ff635d61e180ee996b137a36f6 Mon Sep 17 00:00:00 2001 From: John Blackbourn Date: Tue, 3 Mar 2020 00:29:06 +0000 Subject: [PATCH] Upgrade/Install: Improved inline docs for the plugin and theme updater maintenance mode functionality. Props bookdude13 See #49400 Built from https://develop.svn.wordpress.org/trunk@47409 git-svn-id: http://core.svn.wordpress.org/trunk@47196 1a063a9b-81f0-0310-95a4-ce76da25c4cd --- wp-admin/includes/class-plugin-upgrader.php | 36 +++++++++++---------- wp-admin/includes/class-theme-upgrader.php | 22 +++++++------ wp-includes/version.php | 2 +- 3 files changed, 32 insertions(+), 28 deletions(-) diff --git a/wp-admin/includes/class-plugin-upgrader.php b/wp-admin/includes/class-plugin-upgrader.php index be5b926e4a..b99547c60b 100644 --- a/wp-admin/includes/class-plugin-upgrader.php +++ b/wp-admin/includes/class-plugin-upgrader.php @@ -444,15 +444,15 @@ class Plugin_Upgrader extends WP_Upgrader { } /** - * Turn on maintenance mode before attempting to background update an active plugin. + * Turns on maintenance mode before attempting to background update an active plugin. * * Hooked to the {@see 'upgrader_pre_install'} filter by Plugin_Upgrader::upgrade(). * * @since 5.4.0 * - * @param bool|WP_Error $return - * @param array $plugin - * @return bool|WP_Error + * @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. */ public function active_before( $return, $plugin ) { if ( is_wp_error( $return ) ) { @@ -466,11 +466,12 @@ class Plugin_Upgrader extends WP_Upgrader { $plugin = isset( $plugin['plugin'] ) ? $plugin['plugin'] : ''; - if ( ! is_plugin_active( $plugin ) ) { // If not active. + // Only run if plugin is active + if ( ! is_plugin_active( $plugin ) ) { return $return; } - // Bulk edit handles maintenance mode separately. + // Change to maintenance mode. Bulk edit handles this separately. if ( ! $this->bulk ) { $this->maintenance_mode( true ); } @@ -479,15 +480,15 @@ class Plugin_Upgrader extends WP_Upgrader { } /** - * Turn off maintenance mode after upgrading an active plugin. + * Turns off maintenance mode after upgrading an active plugin. * * Hooked to the {@see 'upgrader_post_install'} filter by Plugin_Upgrader::upgrade(). * * @since 5.4.0 * - * @param bool|WP_Error $return - * @param array $plugin - * @return bool|WP_Error + * @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. */ public function active_after( $return, $plugin ) { if ( is_wp_error( $return ) ) { @@ -501,11 +502,12 @@ class Plugin_Upgrader extends WP_Upgrader { $plugin = isset( $plugin['plugin'] ) ? $plugin['plugin'] : ''; - if ( ! is_plugin_active( $plugin ) ) { // If not active. + // Only run if plugin is active + if ( ! is_plugin_active( $plugin ) ) { return $return; } - // Bulk edit handles maintenance mode separately. + // Time to remove maintenance mode. Bulk edit handles this separately. if ( ! $this->bulk ) { $this->maintenance_mode( false ); } @@ -514,7 +516,7 @@ class Plugin_Upgrader extends WP_Upgrader { } /** - * Delete the old plugin during an upgrade. + * Deletes the old plugin during an upgrade. * * Hooked to the {@see 'upgrader_clear_destination'} filter by * Plugin_Upgrader::upgrade() and Plugin_Upgrader::bulk_upgrade(). @@ -523,10 +525,10 @@ class Plugin_Upgrader extends WP_Upgrader { * * @global WP_Filesystem_Base $wp_filesystem WordPress filesystem subclass. * - * @param bool|WP_Error $removed - * @param string $local_destination - * @param string $remote_destination - * @param array $plugin + * @param bool|WP_Error $removed Whether the destination was cleared. true on success, WP_Error on failure. + * @param string $local_destination The local package destination. + * @param string $remote_destination The remote package destination. + * @param array $plugin Extra arguments passed to hooked filters. * @return bool|WP_Error */ public function delete_old_plugin( $removed, $local_destination, $remote_destination, $plugin ) { diff --git a/wp-admin/includes/class-theme-upgrader.php b/wp-admin/includes/class-theme-upgrader.php index 261987401e..aae2a8a2a1 100644 --- a/wp-admin/includes/class-theme-upgrader.php +++ b/wp-admin/includes/class-theme-upgrader.php @@ -528,9 +528,9 @@ class Theme_Upgrader extends WP_Upgrader { * * @since 2.8.0 * - * @param bool|WP_Error $return - * @param array $theme - * @return bool|WP_Error + * @param bool|WP_Error $return Upgrade offer return. + * @param array $theme Theme arguments. + * @return bool|WP_Error The passed in $return param or WP_Error. */ public function current_before( $return, $theme ) { if ( is_wp_error( $return ) ) { @@ -539,11 +539,12 @@ class Theme_Upgrader extends WP_Upgrader { $theme = isset( $theme['theme'] ) ? $theme['theme'] : ''; - if ( get_stylesheet() !== $theme ) { // If not current. + // Only run if current theme + if ( get_stylesheet() !== $theme ) { return $return; } - // Change to maintenance mode now. + // Change to maintenance mode. Bulk edit handles this separately. if ( ! $this->bulk ) { $this->maintenance_mode( true ); } @@ -559,9 +560,9 @@ class Theme_Upgrader extends WP_Upgrader { * * @since 2.8.0 * - * @param bool|WP_Error $return - * @param array $theme - * @return bool|WP_Error + * @param bool|WP_Error $return Upgrade offer return. + * @param array $theme Theme arguments. + * @return bool|WP_Error The passed in $return param or WP_Error. */ public function current_after( $return, $theme ) { if ( is_wp_error( $return ) ) { @@ -570,7 +571,8 @@ class Theme_Upgrader extends WP_Upgrader { $theme = isset( $theme['theme'] ) ? $theme['theme'] : ''; - if ( get_stylesheet() !== $theme ) { // If not current. + // Only run if current theme + if ( get_stylesheet() !== $theme ) { return $return; } @@ -581,7 +583,7 @@ class Theme_Upgrader extends WP_Upgrader { switch_theme( $stylesheet ); } - // Time to remove maintenance mode. + // Time to remove maintenance mode. Bulk edit handles this separately. if ( ! $this->bulk ) { $this->maintenance_mode( false ); } diff --git a/wp-includes/version.php b/wp-includes/version.php index e3d5f03327..c3a5bac66a 100644 --- a/wp-includes/version.php +++ b/wp-includes/version.php @@ -13,7 +13,7 @@ * * @global string $wp_version */ -$wp_version = '5.4-beta3-47408'; +$wp_version = '5.4-beta3-47409'; /** * Holds the WordPress DB revision, increments when changes are made to the WordPress DB schema.