-
Notifications
You must be signed in to change notification settings - Fork 85
Add --auto-update-indicated flag to plugin update command #495
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: main
Are you sure you want to change the base?
Conversation
Co-authored-by: swissspidy <841956+swissspidy@users.noreply.github.com>
Co-authored-by: swissspidy <841956+swissspidy@users.noreply.github.com>
…mments Co-authored-by: swissspidy <841956+swissspidy@users.noreply.github.com>
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Pull request overview
This PR adds support for WordPress.org's server-indicated automatic updates by introducing a --auto-update-indicated flag to the wp plugin update command. WordPress.org sets an autoupdate flag in plugin update API responses to push critical security patches to specific version branches, and this feature enables WP-CLI users to filter updates to only those plugins where the server indicates automatic updates are recommended.
Changes:
- Extracts
autoupdateflag from WordPress.org plugin update API responses and exposes it asauto_update_indicatedfield - Adds
--auto-update-indicatedflag towp plugin updatecommand to filter and update only plugins with server-indicated automatic updates - Includes validation to prevent combining
--versionwith--auto-update-indicatedsince the version is determined by the server
Reviewed changes
Copilot reviewed 3 out of 3 changed files in this pull request and generated 4 comments.
| File | Description |
|---|---|
| src/WP_CLI/CommandWithUpgrade.php | Adds display conversion logic to show auto_update_indicated as "yes"/"no" in plugin list output |
| src/Plugin_Command.php | Core implementation including field extraction from API, filtering logic, and flag validation |
| features/plugin-update.feature | Test scenarios covering field display, flag behavior, validation errors, and dry-run functionality |
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
| # 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 | ||
|
|
||
| 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. | ||
| """ |
Copilot
AI
Feb 4, 2026
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The test coverage for the --auto-update-indicated flag is missing scenarios for incompatibility with --minor and --patch flags. Consider adding test scenarios similar to the existing "Error when using --version with --auto-update-indicated" test (line 303) for these flags:
Scenario: Error when using --minor with --auto-update-indicated
Scenario: Error when using --patch with --auto-update-indicated
This would ensure the validation logic is properly tested.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@copilot apply changes based on this feedback
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Added test scenarios for --minor and --patch incompatibility in commit 7db7e24. The tests now cover:
- Error when using
--minorwith--auto-update-indicated - Error when using
--patchwith--auto-update-indicated - Error when specifying plugin names with
--auto-update-indicated
| 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; | ||
| } | ||
|
|
||
| // Process the updates. | ||
| parent::update_many( $args, $assoc_args ); | ||
| return; | ||
| } |
Copilot
AI
Feb 4, 2026
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
When --auto-update-indicated is used, any plugin names passed in the command arguments are silently ignored. This could be confusing to users who might expect the flag to act as a filter on the specified plugins. Consider adding validation to error if both plugin names and --auto-update-indicated are specified, similar to how the codebase validates that either plugin names or --all must be provided (see check_optional_args_and_all at src/WP_CLI/ParsePluginNameInput.php:19). For example:
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.' );
}
This would make the behavior explicit and prevent user confusion.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Added validation to error when both plugin names and --auto-update-indicated are specified in commit 7db7e24. The error message clearly states: "Cannot specify plugin names with --auto-update-indicated. This flag updates all plugins with server-indicated automatic updates."
This prevents user confusion by making the behavior explicit - the flag is designed to update all plugins with the server-indicated flag, not to filter specific plugins.
Co-authored-by: Copilot <175728472+Copilot@users.noreply.github.com>
Co-authored-by: Copilot <175728472+Copilot@users.noreply.github.com>
…tibility Co-authored-by: swissspidy <841956+swissspidy@users.noreply.github.com>
Implementation Plan: Add --auto-update-indicated flag to plugin update
--auto-update-indicatedflag to Plugin_Command::update() methodSummary
This PR implements support for WordPress.org's server-indicated automatic updates by adding a
--auto-update-indicatedflag towp plugin update.Changes Made
auto_update_indicated: Extracted from WordPress.org API response and displayed in plugin lists--auto-update-indicated: Filters updates to only plugins with server-indicated automatic updates--version(version determined by server)--minoror--patch(version determined by server)Usage
Files Changed
src/Plugin_Command.php: Main implementation with validationsrc/WP_CLI/CommandWithUpgrade.php: Display conversionfeatures/plugin-update.feature: 7 comprehensive test scenariosCode Quality
✅ All checks passing (lint, phpcs, phpstan, phpunit, CodeQL)
Original prompt
💬 We'd love your input! Share your thoughts on Copilot coding agent in our 2 minute survey.