From 4a495dfc99967e52271d901518e8381e13a9b358 Mon Sep 17 00:00:00 2001 From: Sergey Biryukov Date: Tue, 30 Jun 2020 11:03:57 +0000 Subject: [PATCH] Comments: Introduce `wp_update_comment_type_batch_size` filter for the comment batch size in `_wp_batch_update_comment_type()`. Follow-up to [47597]. Props dchymko. Fixes #50513. See #49236. git-svn-id: https://develop.svn.wordpress.org/trunk@48225 602fd350-edb4-49c9-b593-d223f7449a82 --- src/wp-includes/comment.php | 24 ++++++++++++++++++------ 1 file changed, 18 insertions(+), 6 deletions(-) diff --git a/src/wp-includes/comment.php b/src/wp-includes/comment.php index 6cc20e18c1..0f0ec67082 100644 --- a/src/wp-includes/comment.php +++ b/src/wp-includes/comment.php @@ -3831,13 +3831,25 @@ function _wp_batch_update_comment_type() { // Empty comment type found? We'll need to run this script again. wp_schedule_single_event( time() + ( 2 * MINUTE_IN_SECONDS ), 'wp_update_comment_type_batch' ); - // Update the `comment_type` field value to be `comment` for the next 100 rows of comments. + /** + * Filters the comment batch size for updating the comment type. + * + * @since 5.5.0 + * + * @param int $comment_batch_size The comment batch size. Default 100. + */ + $comment_batch_size = (int) apply_filters( 'wp_update_comment_type_batch_size', 100 ); + + // Update the `comment_type` field value to be `comment` for the next batch of comments. $wpdb->query( - "UPDATE {$wpdb->comments} - SET comment_type = 'comment' - WHERE comment_type = '' - ORDER BY comment_ID DESC - LIMIT 100" + $wpdb->prepare( + "UPDATE {$wpdb->comments} + SET comment_type = 'comment' + WHERE comment_type = '' + ORDER BY comment_ID DESC + LIMIT %d" + ), + $comment_batch_size ); delete_option( $lock_name );