diff --git a/features/package-update.feature b/features/package-update.feature index b2f72295..faa87dd9 100644 --- a/features/package-update.feature +++ b/features/package-update.feature @@ -132,6 +132,28 @@ Feature: Update WP-CLI packages | name | update | | wp-cli-test/updateable-package | none | + Scenario: Update a package named more than once counts it once + Given an empty directory + + When I run `wp package install wp-cli-test/updateable-package:v3.0.0` + Then STDOUT should contain: + """ + Success: Package installed. + """ + + When I run `wp eval "file_put_contents( '{PACKAGE_PATH}composer.json', str_replace( 'v3.0.0', '>=3.0.0', file_get_contents( '{PACKAGE_PATH}composer.json' ) ) );" --skip-wordpress` + Then the return code should be 0 + + When I run `wp package update wp-cli-test/updateable-package wp-cli-test/updateable-package` + Then STDOUT should contain: + """ + Success: Package updated successfully. + """ + And STDOUT should not contain: + """ + All 2 packages + """ + Scenario: Update multiple specific packages by name Given an empty directory diff --git a/src/Package_Command.php b/src/Package_Command.php index 73085008..21e2c1af 100644 --- a/src/Package_Command.php +++ b/src/Package_Command.php @@ -694,7 +694,8 @@ public function update( $args, $assoc_args = [] ) { // Validate package names if provided $packages_to_update = []; if ( ! empty( $args ) ) { - foreach ( $args as $package_name ) { + // Look up and report each package once, even if it was named more than once. + foreach ( array_unique( $args ) as $package_name ) { $package = $this->get_installed_package_by_name( $package_name ); if ( false === $package ) { WP_CLI::error( sprintf( "Package '%s' is not installed.", $package_name ) );