Skip to content

Commit

Permalink
Fix condition for comment count check
Browse files Browse the repository at this point in the history
  • Loading branch information
ernilambar committed Feb 14, 2024
1 parent e380ef2 commit 0ddfaaa
Show file tree
Hide file tree
Showing 2 changed files with 4 additions and 5 deletions.
4 changes: 2 additions & 2 deletions features/comment-recount.feature
Original file line number Diff line number Diff line change
Expand Up @@ -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.
"""
5 changes: 2 additions & 3 deletions src/Comment_Command.php
Original file line number Diff line number Diff line change
Expand Up @@ -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." );
Expand Down

0 comments on commit 0ddfaaa

Please sign in to comment.