22
33use WP_CLI \Entity \RecursiveDataStructureTraverser ;
44use WP_CLI \Utils ;
5+ use WP_CLI \Entity \Utils as EntityUtils ;
56
67/**
78 * Adds, updates, deletes, and lists site options in a multisite installation.
@@ -174,7 +175,7 @@ public function list_( $args, $assoc_args ) {
174175 $ fields = explode ( ', ' , $ assoc_args ['fields ' ] );
175176 }
176177
177- if ( \ WP_CLI \ Utils \get_flag_value ( $ assoc_args , 'format ' ) === 'total_bytes ' ) {
178+ if ( Utils \get_flag_value ( $ assoc_args , 'format ' ) === 'total_bytes ' ) {
178179 $ fields = array ( 'size_bytes ' );
179180 $ size_query = ",SUM(LENGTH(meta_value)) AS `size_bytes` " ;
180181 }
@@ -190,7 +191,7 @@ public function list_( $args, $assoc_args ) {
190191 }
191192 $ results = $ wpdb ->get_results ( $ query );
192193
193- if ( \ WP_CLI \ Utils \get_flag_value ( $ assoc_args , 'format ' ) === 'total_bytes ' ) {
194+ if ( Utils \get_flag_value ( $ assoc_args , 'format ' ) === 'total_bytes ' ) {
194195 WP_CLI ::line ( $ results [0 ]->size_bytes );
195196 } else {
196197 $ formatter = new \WP_CLI \Formatter (
@@ -362,12 +363,13 @@ public function patch( $args, $assoc_args ) {
362363
363364 if ( 'delete ' == $ action ) {
364365 $ patch_value = null ;
365- } elseif ( \WP_CLI \Entity \Utils::has_stdin () ) {
366- $ stdin_value = WP_CLI ::get_value_from_arg_or_stdin ( $ args , -1 );
367- $ patch_value = WP_CLI ::read_value ( trim ( $ stdin_value ), $ assoc_args );
368366 } else {
369- // Take the patch value as the last positional argument. Mutates $key_path to be 1 element shorter!
370- $ patch_value = WP_CLI ::read_value ( array_pop ( $ key_path ), $ assoc_args );
367+ $ stdin_value = EntityUtils::has_stdin ()
368+ ? trim ( WP_CLI ::get_value_from_arg_or_stdin ( $ args , -1 ) )
369+ : null ;
370+ $ patch_value = ! empty ( $ stdin_value )
371+ ? WP_CLI ::read_value ( $ stdin_value , $ assoc_args )
372+ : WP_CLI ::read_value ( array_pop ( $ key_path ), $ assoc_args );
371373 }
372374
373375 /* Need to make a copy of $current_value here as it is modified by reference */
0 commit comments