Skip to content

Commit 7db7e24

Browse files
Copilotswissspidy
andcommitted
Add validation for plugin names and tests for --minor/--patch incompatibility
Co-authored-by: swissspidy <841956+swissspidy@users.noreply.github.com>
1 parent 27ab4e6 commit 7db7e24

2 files changed

Lines changed: 39 additions & 0 deletions

File tree

features/plugin-update.feature

Lines changed: 33 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -310,6 +310,39 @@ Feature: Update WordPress plugins
310310
"""
311311
And the return code should be 1
312312

313+
@require-wp-5.2
314+
Scenario: Error when using --minor with --auto-update-indicated
315+
Given a WP install
316+
317+
When I try `wp plugin update --auto-update-indicated --minor`
318+
Then STDERR should be:
319+
"""
320+
Error: Cannot use --minor or --patch with --auto-update-indicated. The version is determined by the server.
321+
"""
322+
And the return code should be 1
323+
324+
@require-wp-5.2
325+
Scenario: Error when using --patch with --auto-update-indicated
326+
Given a WP install
327+
328+
When I try `wp plugin update --auto-update-indicated --patch`
329+
Then STDERR should be:
330+
"""
331+
Error: Cannot use --minor or --patch with --auto-update-indicated. The version is determined by the server.
332+
"""
333+
And the return code should be 1
334+
335+
@require-wp-5.2
336+
Scenario: Error when specifying plugin names with --auto-update-indicated
337+
Given a WP install
338+
339+
When I try `wp plugin update akismet --auto-update-indicated`
340+
Then STDERR should be:
341+
"""
342+
Error: Cannot specify plugin names with --auto-update-indicated. This flag updates all plugins with server-indicated automatic updates.
343+
"""
344+
And the return code should be 1
345+
313346
@require-wp-5.2
314347
Scenario: Preview updates with --auto-update-indicated and --dry-run
315348
Given a WP install

src/Plugin_Command.php

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -772,6 +772,12 @@ public function update( $args, $assoc_args ) {
772772
if ( $auto_update_indicated && ( isset( $assoc_args['minor'] ) || isset( $assoc_args['patch'] ) ) ) {
773773
WP_CLI::error( 'Cannot use --minor or --patch with --auto-update-indicated. The version is determined by the server.' );
774774
}
775+
776+
// Don't allow plugin names to be specified with --auto-update-indicated.
777+
if ( $auto_update_indicated && ! empty( $args ) ) {
778+
WP_CLI::error( 'Cannot specify plugin names with --auto-update-indicated. This flag updates all plugins with server-indicated automatic updates.' );
779+
}
780+
775781
// If --auto-update-indicated is set, we need to filter plugins by this flag.
776782
if ( $auto_update_indicated ) {
777783
// Get all plugins with their update info.

0 commit comments

Comments
 (0)