diff --git a/features/plugin-update.feature b/features/plugin-update.feature index 46513e14..4567d938 100644 --- a/features/plugin-update.feature +++ b/features/plugin-update.feature @@ -371,6 +371,67 @@ Feature: Update WordPress plugins Success: Updated 2 of 2 plugins. """ + @require-wp-5.2 + Scenario: Updating several plugins downloads their packages side by side + Given a WP install + And an empty cache + 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: + """ + Downloading 2 packages... + """ + And STDOUT should contain: + """ + Using cached file + """ + And STDOUT should contain: + """ + Success: Updated 2 of 2 plugins. + """ + + When I run `wp plugin install health-check --version=1.5.0 --force` + And I run `wp plugin install wordpress-importer --version=0.5 --force` + And I try `wp plugin update --all` + Then STDOUT should not contain: + """ + Downloading 2 packages... + """ + And STDOUT should contain: + """ + Success: Updated 2 of 2 plugins. + """ + + @require-wp-5.2 + Scenario: Updating a single plugin downloads its package on its own + Given a WP install + And an empty cache + And I run `wp plugin delete akismet` + + 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 not contain: + """ + Downloading 1 package + """ + And STDOUT should not contain: + """ + Using cached file + """ + And STDOUT should contain: + """ + Success: Updated 1 of 1 plugins. + """ + @require-wp-5.2 @skip-windows Scenario: Failed plugin update keeps JSON output parseable Given a WP install diff --git a/features/theme-update.feature b/features/theme-update.feature index c93d9377..a5c5ab91 100644 --- a/features/theme-update.feature +++ b/features/theme-update.feature @@ -258,6 +258,32 @@ Feature: Update WordPress themes Success: Updated 2 of 2 themes. """ + @require-wp-4.5 + Scenario: Updating several themes downloads their packages side by side + Given a WP install + And an empty cache + And I run `wp theme delete --all --force` + + When I run `wp theme install storefront --version=1.0.0` + 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: + """ + Downloading 2 packages... + """ + And STDOUT should contain: + """ + Using cached file + """ + And STDOUT should contain: + """ + Success: Updated 2 of 2 themes. + """ + Scenario: Skip theme update when theme directory is a VCS checkout Given a WP install And I run `wp theme install twentytwelve --version=3.0 --force` diff --git a/src/WP_CLI/CommandWithUpgrade.php b/src/WP_CLI/CommandWithUpgrade.php index 4ad5032b..b7260c72 100755 --- a/src/WP_CLI/CommandWithUpgrade.php +++ b/src/WP_CLI/CommandWithUpgrade.php @@ -807,6 +807,10 @@ function ( $item ) { foreach ( $items_to_update as $item ) { $cache_manager->whitelist_package( $item['update_package'], $this->item_type, $item['name'], $item['update_version'] ); } + // Fetch the packages side by side before the upgrader asks for them one at a time. + if ( method_exists( $cache_manager, 'prefetch' ) ) { + $cache_manager->prefetch( wp_list_pluck( $items_to_update, 'update_package' ) ); + } $upgrader = $this->get_upgrader( $assoc_args ); // Ensure the upgrader uses the download offer present in each item. $transient_filter = function ( $transient ) use ( $items_to_update ) {