diff --git a/features/comment-recount.feature b/features/comment-recount.feature index 332fbe9e..538f235c 100644 --- a/features/comment-recount.feature +++ b/features/comment-recount.feature @@ -24,8 +24,8 @@ Feature: Recount comments on a post Updated post 1 comment count to 3. """ - When I run `wp comment recount 99999999` - Then STDOUT should be: + When I try `wp comment recount 99999999` + Then STDERR should be: """ Warning: Post 99999999 doesn't exist. """ diff --git a/src/Comment_Command.php b/src/Comment_Command.php index 2b7172c2..1ff6b361 100644 --- a/src/Comment_Command.php +++ b/src/Comment_Command.php @@ -672,9 +672,8 @@ public function count( $args, $assoc_args ) { */ public function recount( $args ) { foreach ( $args as $id ) { - $post = get_post( $id ); - if ( $post ) { - wp_update_comment_count( $id ); + if ( wp_update_comment_count( $id ) ) { + $post = get_post( $id ); WP_CLI::log( "Updated post {$post->ID} comment count to {$post->comment_count}." ); } else { WP_CLI::warning( "Post {$id} doesn't exist." );