Skip to content

Commit 0ddfaaa

Browse files
committed
Fix condition for comment count check
1 parent e380ef2 commit 0ddfaaa

File tree

2 files changed

+4
-5
lines changed

2 files changed

+4
-5
lines changed

features/comment-recount.feature

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -24,8 +24,8 @@ Feature: Recount comments on a post
2424
Updated post 1 comment count to 3.
2525
"""
2626

27-
When I run `wp comment recount 99999999`
28-
Then STDOUT should be:
27+
When I try `wp comment recount 99999999`
28+
Then STDERR should be:
2929
"""
3030
Warning: Post 99999999 doesn't exist.
3131
"""

src/Comment_Command.php

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -672,9 +672,8 @@ public function count( $args, $assoc_args ) {
672672
*/
673673
public function recount( $args ) {
674674
foreach ( $args as $id ) {
675-
$post = get_post( $id );
676-
if ( $post ) {
677-
wp_update_comment_count( $id );
675+
if ( wp_update_comment_count( $id ) ) {
676+
$post = get_post( $id );
678677
WP_CLI::log( "Updated post {$post->ID} comment count to {$post->comment_count}." );
679678
} else {
680679
WP_CLI::warning( "Post {$id} doesn't exist." );

0 commit comments

Comments
 (0)