diff --git a/features/plugin-update.feature b/features/plugin-update.feature index a028b8df..1cf5e248 100644 --- a/features/plugin-update.feature +++ b/features/plugin-update.feature @@ -267,3 +267,25 @@ Feature: Update WordPress plugins """ Success: Updated 1 of 1 plugins (1 skipped). """ + + @require-wp-5.2 + Scenario: Updating all plugins should show the name of each plugin as it is updated + Given a WP install + And I run `wp plugin delete akismet` + + When I run `wp plugin install health-check --version=1.5.0` + Then STDOUT should not be empty + + When I run `wp plugin install wordpress-importer --version=0.5` + Then STDOUT should not be empty + + When I try `wp plugin update --all` + Then STDOUT should contain: + """ + Updating Health Check & Troubleshooting... + """ + + And STDOUT should contain: + """ + Success: Updated 2 of 2 plugins. + """ diff --git a/features/theme-update.feature b/features/theme-update.feature index 4179b6a6..adc546b0 100644 --- a/features/theme-update.feature +++ b/features/theme-update.feature @@ -154,3 +154,25 @@ Feature: Update WordPress themes """ 1.1.1 """ + + @require-wp-4.5 + Scenario: Updating all themes should show the name of each theme as it is updated + Given a WP install + And I run `wp theme delete --all --force` + + When I run `wp theme install moina --version=1.0.2` + Then STDOUT should not be empty + + When I run `wp theme install twentytwelve --version=1.0` + Then STDOUT should not be empty + + When I try `wp theme update --all` + Then STDOUT should contain: + """ + Updating Moina... + """ + + And STDOUT should contain: + """ + Success: Updated 2 of 2 themes. + """ diff --git a/phpcs.xml.dist b/phpcs.xml.dist index d0cb7801..96cef65a 100644 --- a/phpcs.xml.dist +++ b/phpcs.xml.dist @@ -61,6 +61,7 @@ */src/WP_CLI/CommandWithUpgrade\.php$ */src/WP_CLI/(CommandWith|DestructivePlugin|DestructiveTheme)Upgrader\.php$ */src/WP_CLI/Parse(Plugin|Theme)NameInput\.php$ + */src/WP_CLI/ExtensionUpgraderSkin\.php$ diff --git a/src/WP_CLI/CommandWithUpgrade.php b/src/WP_CLI/CommandWithUpgrade.php index 52f9f5bf..63c7776e 100755 --- a/src/WP_CLI/CommandWithUpgrade.php +++ b/src/WP_CLI/CommandWithUpgrade.php @@ -389,7 +389,14 @@ protected function get_upgrader( $assoc_args ) { $force = Utils\get_flag_value( $assoc_args, 'force', false ); $insecure = Utils\get_flag_value( $assoc_args, 'insecure', false ); $upgrader_class = $this->get_upgrader_class( $force ); - return Utils\get_upgrader( $upgrader_class, $insecure ); + + if ( ! class_exists( '\WP_Upgrader_Skin' ) ) { + if ( file_exists( ABSPATH . 'wp-admin/includes/class-wp-upgrader-skin.php' ) ) { + include ABSPATH . 'wp-admin/includes/class-wp-upgrader-skin.php'; + } + } + + return Utils\get_upgrader( $upgrader_class, $insecure, new ExtensionUpgraderSkin() ); } protected function update_many( $args, $assoc_args ) { diff --git a/src/WP_CLI/ExtensionUpgraderSkin.php b/src/WP_CLI/ExtensionUpgraderSkin.php new file mode 100644 index 00000000..3c9db76e --- /dev/null +++ b/src/WP_CLI/ExtensionUpgraderSkin.php @@ -0,0 +1,24 @@ +plugin_info ) && is_array( $this->plugin_info ) && isset( $this->plugin_info['Name'] ) ) { + WP_CLI::log( sprintf( 'Updating %s...', html_entity_decode( $this->plugin_info['Name'], ENT_QUOTES, get_bloginfo( 'charset' ) ) ) ); + } elseif ( isset( $this->theme_info ) && is_object( $this->theme_info ) && method_exists( $this->theme_info, 'get' ) ) { + WP_CLI::log( sprintf( 'Updating %s...', html_entity_decode( $this->theme_info->get( 'Name' ), ENT_QUOTES, get_bloginfo( 'charset' ) ) ) ); + } + } +}