From 96715e982f2d8a1c05bdd8b7e67591ddcc605913 Mon Sep 17 00:00:00 2001 From: Claude Date: Wed, 23 Sep 2026 05:37:37 +0000 Subject: [PATCH 1/2] Make invalid --porcelain test compatible with core option validation wp-cli/wp-cli#6410 validates `options` for optional-value flags such as `[--porcelain[=]]` in the framework, so `--porcelain=invalid` is now rejected with a generic "Parameter errors" message before the command runs. Assert on the parts common to both the old command-level error and the new framework error so the scenario passes with either wp-cli version. Co-Authored-By: Claude Opus 5.5 Claude-Session: https://claude.ai/code/session_013PyGcB6bxx6zExR9LLHv99 --- features/media-import.feature | 14 ++++++++++++-- 1 file changed, 12 insertions(+), 2 deletions(-) diff --git a/features/media-import.feature b/features/media-import.feature index 660f63cb..41153a73 100644 --- a/features/media-import.feature +++ b/features/media-import.feature @@ -282,10 +282,20 @@ Feature: Manage WordPress attachments Scenario: Errors when invalid --porcelain flag is applied. When I try `wp media import 'http://wp-cli.github.io/behat-data/codeispoetry.png' --porcelain=invalid` - Then STDERR should be: + Then the return code should be 1 + And STDERR should contain: + """ + Error: + """ + And STDERR should contain: + """ + Invalid value + """ + And STDERR should contain: """ - Error: Invalid value for : invalid. Expected flag or 'url'. + porcelain """ + And STDOUT should be empty Scenario: Import media from STDIN Given download: From a18d944cd8169f4c531c8c370e7ee50339769da1 Mon Sep 17 00:00:00 2001 From: Claude Date: Wed, 23 Sep 2026 05:56:17 +0000 Subject: [PATCH 2/2] Remove redundant --porcelain value check from `media import` WP-CLI now validates `options` for optional-value flags such as `[--porcelain[=]]` itself (wp-cli/wp-cli#6410), so the command-level check is unreachable. Update the scenario to expect the framework's error message. Co-Authored-By: Claude Opus 5.5 Claude-Session: https://claude.ai/code/session_013PyGcB6bxx6zExR9LLHv99 --- features/media-import.feature | 15 +++------------ src/Media_Command.php | 3 --- 2 files changed, 3 insertions(+), 15 deletions(-) diff --git a/features/media-import.feature b/features/media-import.feature index 41153a73..1c800f26 100644 --- a/features/media-import.feature +++ b/features/media-import.feature @@ -282,20 +282,11 @@ Feature: Manage WordPress attachments Scenario: Errors when invalid --porcelain flag is applied. When I try `wp media import 'http://wp-cli.github.io/behat-data/codeispoetry.png' --porcelain=invalid` - Then the return code should be 1 - And STDERR should contain: - """ - Error: - """ - And STDERR should contain: - """ - Invalid value - """ - And STDERR should contain: + Then STDERR should be: """ - porcelain + Error: Parameter errors: + Invalid value specified for 'porcelain' (Output a single field for each imported image. Defaults to attachment ID when used as flag.) """ - And STDOUT should be empty Scenario: Import media from STDIN Given download: diff --git a/src/Media_Command.php b/src/Media_Command.php index aab554ae..6f95308c 100644 --- a/src/Media_Command.php +++ b/src/Media_Command.php @@ -501,9 +501,6 @@ public function import( $args, $assoc_args = array() ) { } $porcelain = Utils\get_flag_value( $assoc_args, 'porcelain' ); - if ( is_string( $porcelain ) && ! in_array( $porcelain, array( 'url' ), true ) ) { - WP_CLI::error( sprintf( 'Invalid value for : %s. Expected flag or \'url\'.', $porcelain ) ); - } if ( isset( $assoc_args['post_id'] ) ) { if ( ! get_post( $assoc_args['post_id'] ) ) {