Skip to content

Commit 1eca572

Browse files
committed
Fix bug in meta patch STDIN detection
1 parent ecee37a commit 1eca572

File tree

1 file changed

+7
-5
lines changed

1 file changed

+7
-5
lines changed

src/WP_CLI/CommandWithMeta.php

Lines changed: 7 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,7 @@
44

55
use WP_CLI;
66
use WP_CLI\Entity\RecursiveDataStructureTraverser;
7+
use WP_CLI\Entity\Utils as EntityUtils;
78

89
/**
910
* Base class for WP-CLI commands that deal with metadata
@@ -396,12 +397,13 @@ public function patch( $args, $assoc_args ) {
396397

397398
if ( 'delete' == $action ) {
398399
$patch_value = null;
399-
} elseif ( Entity\Utils::has_stdin() ) {
400-
$stdin_value = WP_CLI::get_value_from_arg_or_stdin( $args, -1 );
401-
$patch_value = WP_CLI::read_value( trim( $stdin_value ), $assoc_args );
402400
} else {
403-
// Take the patch value as the last positional argument. Mutates $key_path to be 1 element shorter!
404-
$patch_value = WP_CLI::read_value( array_pop( $key_path ), $assoc_args );
401+
$stdin_value = EntityUtils::has_stdin()
402+
? trim( WP_CLI::get_value_from_arg_or_stdin( $args, -1 ) )
403+
: null;
404+
$patch_value = ! empty( $stdin_value )
405+
? WP_CLI::read_value( $stdin_value, $assoc_args )
406+
: WP_CLI::read_value( array_pop( $key_path ), $assoc_args );
405407
}
406408

407409
/* Need to make a copy of $current_meta_value here as it is modified by reference */

0 commit comments

Comments
 (0)