From 14fc9be1e987bd3b35a9533bf4c0be0db6aadd95 Mon Sep 17 00:00:00 2001 From: "copilot-swe-agent[bot]" <198982749+Copilot@users.noreply.github.com> Date: Wed, 4 Feb 2026 16:28:03 +0000 Subject: [PATCH 1/7] Initial plan From 5a4ad4e0cc7d30c5c0fa8bd7e6079f151f1c49b7 Mon Sep 17 00:00:00 2001 From: "copilot-swe-agent[bot]" <198982749+Copilot@users.noreply.github.com> Date: Wed, 4 Feb 2026 16:34:38 +0000 Subject: [PATCH 2/7] Add auto_update_indicated field and --auto-update-indicated flag Co-authored-by: swissspidy <841956+swissspidy@users.noreply.github.com> --- src/Plugin_Command.php | 44 ++++++++++++++++++++++++++++--- src/WP_CLI/CommandWithUpgrade.php | 6 +++++ 2 files changed, 47 insertions(+), 3 deletions(-) diff --git a/src/Plugin_Command.php b/src/Plugin_Command.php index c257debbc..110c89f1d 100644 --- a/src/Plugin_Command.php +++ b/src/Plugin_Command.php @@ -67,6 +67,7 @@ class Plugin_Command extends CommandWithUpgrade { 'version', 'update_version', 'auto_update', + 'auto_update_indicated', ); public function __construct() { @@ -707,6 +708,9 @@ protected function install_from_repo( $slug, $assoc_args ) { * [--insecure] * : Retry downloads without certificate validation if TLS handshake fails. Note: This makes the request vulnerable to a MITM attack. * + * [--auto-update-indicated] + * : Only update plugins where the server response indicates an automatic update. Updates to the version indicated by the server, not necessarily the latest version. + * * ## EXAMPLES * * $ wp plugin update bbpress --version=dev @@ -756,7 +760,39 @@ protected function install_from_repo( $slug, $assoc_args ) { * @alias upgrade */ public function update( $args, $assoc_args ) { - $all = Utils\get_flag_value( $assoc_args, 'all', false ); + $all = Utils\get_flag_value( $assoc_args, 'all', false ); + $auto_update_indicated = Utils\get_flag_value( $assoc_args, 'auto-update-indicated', false ); + + // If --auto-update-indicated is set, we need to filter plugins by this flag. + if ( $auto_update_indicated ) { + // Get all plugins with their update info. + $items = $this->get_item_list(); + + // Filter to only include plugins where auto_update_indicated is true. + $auto_update_plugins = array_filter( + $items, + function ( $item ) { + return ! empty( $item['auto_update_indicated'] ); + } + ); + + // Get the plugin names to update. + $args = array_values( wp_list_pluck( $auto_update_plugins, 'name' ) ); + + if ( empty( $args ) ) { + WP_CLI::success( 'No plugins with server-indicated automatic updates available.' ); + return; + } + + // Don't allow --version to be set with --auto-update-indicated, as the version comes from the server. + if ( isset( $assoc_args['version'] ) ) { + WP_CLI::error( 'Cannot use --version with --auto-update-indicated. The version is determined by the server.' ); + } + + // Process the updates. + parent::update_many( $args, $assoc_args ); + return; + } $args = $this->check_optional_args_and_all( $args, $all ); if ( ! $args ) { @@ -806,8 +842,9 @@ protected function get_item_list() { $duplicate_names[ $name ] = array(); } - $requires = isset( $update_info ) && isset( $update_info['requires'] ) ? $update_info['requires'] : null; - $requires_php = isset( $update_info ) && isset( $update_info['requires_php'] ) ? $update_info['requires_php'] : null; + $requires = isset( $update_info ) && isset( $update_info['requires'] ) ? $update_info['requires'] : null; + $requires_php = isset( $update_info ) && isset( $update_info['requires_php'] ) ? $update_info['requires_php'] : null; + $auto_update_indicated = isset( $update_info ) && isset( $update_info['autoupdate'] ) ? (bool) $update_info['autoupdate'] : false; // If an update has requires_php set, check to see if the local version of PHP meets that requirement // The plugins update API already filters out plugins that don't meet WordPress requirements, but does not @@ -849,6 +886,7 @@ protected function get_item_list() { 'description' => wordwrap( $details['Description'] ), 'file' => $file, 'auto_update' => in_array( $file, $auto_updates, true ), + 'auto_update_indicated' => $auto_update_indicated, 'author' => $details['Author'], 'tested_up_to' => '', 'requires' => $requires, diff --git a/src/WP_CLI/CommandWithUpgrade.php b/src/WP_CLI/CommandWithUpgrade.php index 52f9f5bf5..edc433166 100755 --- a/src/WP_CLI/CommandWithUpgrade.php +++ b/src/WP_CLI/CommandWithUpgrade.php @@ -642,6 +642,12 @@ function ( $value ) { } elseif ( false === $value ) { $value = 'off'; } + } elseif ( 'auto_update_indicated' === $field ) { + if ( true === $value ) { + $value = 'yes'; + } elseif ( false === $value ) { + $value = 'no'; + } } } From 4e3d71bf2668ad33a5215430c3b5426c282d04d4 Mon Sep 17 00:00:00 2001 From: "copilot-swe-agent[bot]" <198982749+Copilot@users.noreply.github.com> Date: Wed, 4 Feb 2026 16:35:34 +0000 Subject: [PATCH 3/7] Add Behat tests for auto-update-indicated feature Co-authored-by: swissspidy <841956+swissspidy@users.noreply.github.com> --- features/plugin-update.feature | 49 ++++++++++++++++++++++++++++++++++ 1 file changed, 49 insertions(+) diff --git a/features/plugin-update.feature b/features/plugin-update.feature index a028b8df3..e5830c079 100644 --- a/features/plugin-update.feature +++ b/features/plugin-update.feature @@ -267,3 +267,52 @@ Feature: Update WordPress plugins """ Success: Updated 1 of 1 plugins (1 skipped). """ + + @require-wp-5.2 + Scenario: Show auto_update_indicated field in plugin list + Given a WP install + + When I run `wp plugin install wordpress-importer --version=0.5 --force` + Then STDOUT should not be empty + + When I run `wp plugin list --fields=name,version,update,auto_update_indicated` + Then STDOUT should be a table containing rows: + | name | version | update | auto_update_indicated | + | wordpress-importer | 0.5 | available | no | + + @require-wp-5.2 + Scenario: Using --auto-update-indicated flag when no plugins have auto-update indicated + Given a WP install + + When I run `wp plugin install wordpress-importer --version=0.5 --force` + Then STDOUT should not be empty + + When I run `wp plugin update --auto-update-indicated` + Then STDOUT should be: + """ + Success: No plugins with server-indicated automatic updates available. + """ + + @require-wp-5.2 + Scenario: Error when using --version with --auto-update-indicated + Given a WP install + + When I try `wp plugin update --auto-update-indicated --version=1.0.0` + Then STDERR should be: + """ + Error: Cannot use --version with --auto-update-indicated. The version is determined by the server. + """ + And the return code should be 1 + + @require-wp-5.2 + Scenario: Preview updates with --auto-update-indicated and --dry-run + Given a WP install + + When I run `wp plugin install wordpress-importer --version=0.5 --force` + Then STDOUT should not be empty + + When I run `wp plugin update --auto-update-indicated --dry-run` + Then STDOUT should be: + """ + Success: No plugins with server-indicated automatic updates available. + """ From d1e15003ab669eb7c32936f503634b67961d0ac5 Mon Sep 17 00:00:00 2001 From: "copilot-swe-agent[bot]" <198982749+Copilot@users.noreply.github.com> Date: Wed, 4 Feb 2026 16:36:51 +0000 Subject: [PATCH 4/7] Address code review feedback: move validation earlier and add test comments Co-authored-by: swissspidy <841956+swissspidy@users.noreply.github.com> --- features/plugin-update.feature | 6 ++++++ src/Plugin_Command.php | 10 +++++----- 2 files changed, 11 insertions(+), 5 deletions(-) diff --git a/features/plugin-update.feature b/features/plugin-update.feature index e5830c079..3643a4dd7 100644 --- a/features/plugin-update.feature +++ b/features/plugin-update.feature @@ -268,6 +268,12 @@ Feature: Update WordPress plugins Success: Updated 1 of 1 plugins (1 skipped). """ + # Tests for --auto-update-indicated feature + # Note: These tests verify the flag handling and error cases. + # The actual update behavior when autoupdate is true from the server + # cannot be easily tested as it requires mocking WordPress.org API responses. + # The update functionality itself is handled by the existing update_many method. + @require-wp-5.2 Scenario: Show auto_update_indicated field in plugin list Given a WP install diff --git a/src/Plugin_Command.php b/src/Plugin_Command.php index 110c89f1d..97c2f9a26 100644 --- a/src/Plugin_Command.php +++ b/src/Plugin_Command.php @@ -763,6 +763,11 @@ public function update( $args, $assoc_args ) { $all = Utils\get_flag_value( $assoc_args, 'all', false ); $auto_update_indicated = Utils\get_flag_value( $assoc_args, 'auto-update-indicated', false ); + // Don't allow --version to be set with --auto-update-indicated, as the version comes from the server. + if ( $auto_update_indicated && isset( $assoc_args['version'] ) ) { + WP_CLI::error( 'Cannot use --version with --auto-update-indicated. The version is determined by the server.' ); + } + // If --auto-update-indicated is set, we need to filter plugins by this flag. if ( $auto_update_indicated ) { // Get all plugins with their update info. @@ -784,11 +789,6 @@ function ( $item ) { return; } - // Don't allow --version to be set with --auto-update-indicated, as the version comes from the server. - if ( isset( $assoc_args['version'] ) ) { - WP_CLI::error( 'Cannot use --version with --auto-update-indicated. The version is determined by the server.' ); - } - // Process the updates. parent::update_many( $args, $assoc_args ); return; From 5ad764d6e6c55726b4f06a41a033d25a19744a2a Mon Sep 17 00:00:00 2001 From: Pascal Birchler Date: Wed, 4 Feb 2026 14:24:37 -0500 Subject: [PATCH 5/7] Update src/Plugin_Command.php Co-authored-by: Copilot <175728472+Copilot@users.noreply.github.com> --- src/Plugin_Command.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/Plugin_Command.php b/src/Plugin_Command.php index 97c2f9a26..dd1e39bae 100644 --- a/src/Plugin_Command.php +++ b/src/Plugin_Command.php @@ -709,7 +709,7 @@ protected function install_from_repo( $slug, $assoc_args ) { * : Retry downloads without certificate validation if TLS handshake fails. Note: This makes the request vulnerable to a MITM attack. * * [--auto-update-indicated] - * : Only update plugins where the server response indicates an automatic update. Updates to the version indicated by the server, not necessarily the latest version. + * : Only update plugins where the server response indicates an automatic update. Updates to the version indicated by the server, not necessarily the latest version. Cannot be used with `--version`, `--minor`, or `--patch`. * * ## EXAMPLES * From 27ab4e604abefcb9ade76b4423529a2f9de7a5b4 Mon Sep 17 00:00:00 2001 From: Pascal Birchler Date: Wed, 4 Feb 2026 14:24:46 -0500 Subject: [PATCH 6/7] Update src/Plugin_Command.php Co-authored-by: Copilot <175728472+Copilot@users.noreply.github.com> --- src/Plugin_Command.php | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/src/Plugin_Command.php b/src/Plugin_Command.php index dd1e39bae..ef83a6942 100644 --- a/src/Plugin_Command.php +++ b/src/Plugin_Command.php @@ -768,6 +768,10 @@ public function update( $args, $assoc_args ) { WP_CLI::error( 'Cannot use --version with --auto-update-indicated. The version is determined by the server.' ); } + // Don't allow --minor or --patch to be set with --auto-update-indicated, as the version comes from the server. + if ( $auto_update_indicated && ( isset( $assoc_args['minor'] ) || isset( $assoc_args['patch'] ) ) ) { + WP_CLI::error( 'Cannot use --minor or --patch with --auto-update-indicated. The version is determined by the server.' ); + } // If --auto-update-indicated is set, we need to filter plugins by this flag. if ( $auto_update_indicated ) { // Get all plugins with their update info. From 7db7e24c8cd9a62b7b88eedc5756471430902625 Mon Sep 17 00:00:00 2001 From: "copilot-swe-agent[bot]" <198982749+Copilot@users.noreply.github.com> Date: Wed, 4 Feb 2026 19:27:38 +0000 Subject: [PATCH 7/7] Add validation for plugin names and tests for --minor/--patch incompatibility Co-authored-by: swissspidy <841956+swissspidy@users.noreply.github.com> --- features/plugin-update.feature | 33 +++++++++++++++++++++++++++++++++ src/Plugin_Command.php | 6 ++++++ 2 files changed, 39 insertions(+) diff --git a/features/plugin-update.feature b/features/plugin-update.feature index 3643a4dd7..43db92bc7 100644 --- a/features/plugin-update.feature +++ b/features/plugin-update.feature @@ -310,6 +310,39 @@ Feature: Update WordPress plugins """ And the return code should be 1 + @require-wp-5.2 + Scenario: Error when using --minor with --auto-update-indicated + Given a WP install + + When I try `wp plugin update --auto-update-indicated --minor` + Then STDERR should be: + """ + Error: Cannot use --minor or --patch with --auto-update-indicated. The version is determined by the server. + """ + And the return code should be 1 + + @require-wp-5.2 + Scenario: Error when using --patch with --auto-update-indicated + Given a WP install + + When I try `wp plugin update --auto-update-indicated --patch` + Then STDERR should be: + """ + Error: Cannot use --minor or --patch with --auto-update-indicated. The version is determined by the server. + """ + And the return code should be 1 + + @require-wp-5.2 + Scenario: Error when specifying plugin names with --auto-update-indicated + Given a WP install + + When I try `wp plugin update akismet --auto-update-indicated` + Then STDERR should be: + """ + Error: Cannot specify plugin names with --auto-update-indicated. This flag updates all plugins with server-indicated automatic updates. + """ + And the return code should be 1 + @require-wp-5.2 Scenario: Preview updates with --auto-update-indicated and --dry-run Given a WP install diff --git a/src/Plugin_Command.php b/src/Plugin_Command.php index ef83a6942..b9c4a5a3a 100644 --- a/src/Plugin_Command.php +++ b/src/Plugin_Command.php @@ -772,6 +772,12 @@ public function update( $args, $assoc_args ) { if ( $auto_update_indicated && ( isset( $assoc_args['minor'] ) || isset( $assoc_args['patch'] ) ) ) { WP_CLI::error( 'Cannot use --minor or --patch with --auto-update-indicated. The version is determined by the server.' ); } + + // Don't allow plugin names to be specified with --auto-update-indicated. + if ( $auto_update_indicated && ! empty( $args ) ) { + WP_CLI::error( 'Cannot specify plugin names with --auto-update-indicated. This flag updates all plugins with server-indicated automatic updates.' ); + } + // If --auto-update-indicated is set, we need to filter plugins by this flag. if ( $auto_update_indicated ) { // Get all plugins with their update info.