From 76114c90210613d0ea11e9ff2bbae715c6a164c0 Mon Sep 17 00:00:00 2001 From: Sabith Ahammad Date: Mon, 17 Feb 2025 16:01:20 +0300 Subject: [PATCH 1/2] fixed date_query argument not working for post list command --- src/Post_Command.php | 8 +++++--- 1 file changed, 5 insertions(+), 3 deletions(-) diff --git a/src/Post_Command.php b/src/Post_Command.php index 2c7ee0cf..0bf4634d 100644 --- a/src/Post_Command.php +++ b/src/Post_Command.php @@ -632,12 +632,14 @@ protected function delete_callback( $post_id, $assoc_args ) { public function list_( $args, $assoc_args ) { $formatter = $this->get_formatter( $assoc_args ); - $defaults = [ + $defaults = [ 'posts_per_page' => -1, 'post_status' => 'any', ]; - $query_args = array_merge( $defaults, $assoc_args ); - $query_args = self::process_csv_arguments_to_arrays( $query_args ); + $array_arguments = [ 'date_query' ]; + $assoc_args = Utils\parse_shell_arrays( $assoc_args, $array_arguments ); + $query_args = array_merge( $defaults, $assoc_args ); + $query_args = self::process_csv_arguments_to_arrays( $query_args ); if ( isset( $query_args['post_type'] ) && 'any' !== $query_args['post_type'] ) { $query_args['post_type'] = explode( ',', $query_args['post_type'] ); } From d9d24c5871d26cb1650e4a5d6612904eb27016c5 Mon Sep 17 00:00:00 2001 From: Sabith Ahammad Date: Wed, 19 Feb 2025 00:49:26 +0300 Subject: [PATCH 2/2] test added for fixed date_query not working for post list command --- features/post.feature | 12 ++++++++++++ 1 file changed, 12 insertions(+) diff --git a/features/post.feature b/features/post.feature index b1d9d84e..d40eb996 100644 --- a/features/post.feature +++ b/features/post.feature @@ -365,6 +365,18 @@ Feature: Manage WordPress posts | Publish post | publish-post | publish | | Sample Page | sample-page | publish | + When I run `wp post create --post_title='old post' --post_date='2023-01-24T09:52:00.000Z'` + And I run `wp post create --post_title='new post' --post_date='2025-01-24T09:52:00.000Z'` + And I run `wp post list --field=post_title --date_query='{"before":{"year":"2024"}}'` + Then STDOUT should contain: + """ + old post + """ + And STDOUT should not contain: + """ + new post + """ + Scenario: Update categories on a post When I run `wp term create category "Test Category" --porcelain` Then save STDOUT as {TERM_ID}