File tree Expand file tree Collapse file tree 2 files changed +9
-4
lines changed Expand file tree Collapse file tree 2 files changed +9
-4
lines changed Original file line number Diff line number Diff line change @@ -23,3 +23,9 @@ Feature: Recount comments on a post
23
23
"""
24
24
Updated post 1 comment count to 3.
25
25
"""
26
+
27
+ When I try `wp comment recount 99999999`
28
+ Then STDERR should be:
29
+ """
30
+ Warning: Post 99999999 doesn't exist.
31
+ """
Original file line number Diff line number Diff line change @@ -672,12 +672,11 @@ public function count( $args, $assoc_args ) {
672
672
*/
673
673
public function recount ( $ args ) {
674
674
foreach ( $ args as $ id ) {
675
- wp_update_comment_count ( $ id );
676
- $ post = get_post ( $ id );
677
- if ( $ post ) {
675
+ if ( wp_update_comment_count ( $ id ) ) {
676
+ $ post = get_post ( $ id );
678
677
WP_CLI ::log ( "Updated post {$ post ->ID } comment count to {$ post ->comment_count }. " );
679
678
} else {
680
- WP_CLI ::warning ( "Post {$ post -> ID } doesn't exist. " );
679
+ WP_CLI ::warning ( "Post {$ id } doesn't exist. " );
681
680
}
682
681
}
683
682
}
You can’t perform that action at this time.
0 commit comments