Skip to content

wp package update reports a wrong count when the same package is named more than once #267

Done

Description

@manishsongirkar

Description

When one package is named more than once, wp package update counts it once per mention in the success message.

Where

src/Package_Command.php, in update(). The loop that validates the arguments keeps duplicate names in $packages_to_update:

foreach ( $args as $package_name ) {
	$package = $this->get_installed_package_by_name( $package_name );
	...
	$packages_to_update[] = $package['name'];
}

Later, $num_packages = count( $packages_to_update ) is 2. array_intersect( $packages_to_update, $updated_packages ) also keeps the duplicates, so $num_updated is 2. The two counts match and the plural message is printed.

Steps to reproduce

  1. Run wp package install wp-cli-test/updateable-package:v3.0.0.
  2. Change the constraint in the packages composer.json from v3.0.0 to >=3.0.0.
  3. Run wp package update wp-cli-test/updateable-package wp-cli-test/updateable-package.

Expected

Success: Package updated successfully.

Actual

Success: All 2 packages updated successfully.

If the package has no update, the output is Packages already at latest versions. (plural) instead of Package already at latest version.

Suggested fix

Remove duplicate names after the validation loop, for example with array_unique().

I would like to work on this. Please assign it to me.

Activity

  1. added
    command:package-update
    on Dec 2, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    bugcommand:package-update

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions