Changes between Version 1 and Version 2 of Ticket #49236, comment 26
- Timestamp:
- 08/04/2020 08:39:39 PM (4 years ago)
Legend:
- Unmodified
- Added
- Removed
- Modified
-
Ticket #49236, comment 26
v1 v2 18 18 So I think I prefer the second alternative you proposed, where `UPDATE` is done followed by `clean_comment_cache()`, although with one adjustment: add a safeguard in the `WHERE` to double-confirm that the `comment_type` is indeed empty. Like so: 19 19 20 21 20 {{{#!diff 22 21 --- a/src/wp-includes/comment.php … … 36 35 ORDER BY comment_ID DESC 37 36 LIMIT %d", 38 @@ -3851,6 +3851, 18@@ function _wp_batch_update_comment_type() {37 @@ -3851,6 +3851,20 @@ function _wp_batch_update_comment_type() { 39 38 ) 40 39 ); 41 40 42 + $in_comment_ids = implode( ',', wp_parse_id_list( $comment_ids ) ); 41 + if ( count( $comment_ids ) > 0 ) { 42 + $in_comment_ids = implode( ',', wp_parse_id_list( $comment_ids ) ); 43 43 + 44 + $wpdb->query(45 + $wpdb->prepare(46 + "UPDATE {$wpdb->comments}47 + SET comment_type = 'comment'48 + WHERE comment_type = '' AND comment_ID IN ({$in_comment_ids})"49 + )50 + );44 + $wpdb->query( 45 + $wpdb->prepare( 46 + "UPDATE {$wpdb->comments} 47 + SET comment_type = 'comment' 48 + WHERE comment_type = '' AND comment_ID IN ({$in_comment_ids})" 49 + ) 50 + ); 51 51 + 52 + clean_comment_cache( $comment_ids ); 52 + clean_comment_cache( $comment_ids ); 53 + } 53 54 + 54 55 delete_option( $lock_name );