diff --git a/src/wp-includes/comment.php b/src/wp-includes/comment.php
index 7dafa1e..f0b28bc 100644
--- a/src/wp-includes/comment.php
+++ b/src/wp-includes/comment.php
@@ -2055,7 +2055,25 @@ function wp_update_comment_count_now($post_id) {
 		return false;
 
 	$old = (int) $post->comment_count;
-	$new = (int) $wpdb->get_var( $wpdb->prepare("SELECT COUNT(*) FROM $wpdb->comments WHERE comment_post_ID = %d AND comment_approved = '1'", $post_id) );
+
+	/**
+	* Filters a post's comment count before it is updated in the database.
+	*
+	* @since 4.5.0
+	*
+	* @param null $new     The new comment count.
+	* @param int  $old     The old comment count.
+	* @param int  $post_id Post ID.
+	*/
+	$new = apply_filters( 'wp_update_comment_count_new', null, $old, $post_id );
+
+	if ( ( $new !== null ) && is_numeric( $new ) && ( 0 <= $new ) ) {
+		$new = (int) $new;
+	}
+	else {
+		$new = (int) $wpdb->get_var( $wpdb->prepare("SELECT COUNT(*) FROM $wpdb->comments WHERE comment_post_ID = %d AND comment_approved = '1'", $post_id) );
+	}
+
 	$wpdb->update( $wpdb->posts, array('comment_count' => $new), array('ID' => $post_id) );
 
 	clean_post_cache( $post );
