Edit File by line
/home/zeestwma/richards.../wp-inclu...
File: comment.php
* @since 5.0.0
[4000] Fix | Delete
*/
[4001] Fix | Delete
function wp_cache_set_comments_last_changed() {
[4002] Fix | Delete
wp_cache_set_last_changed( 'comment' );
[4003] Fix | Delete
}
[4004] Fix | Delete
[4005] Fix | Delete
/**
[4006] Fix | Delete
* Updates the comment type for a batch of comments.
[4007] Fix | Delete
*
[4008] Fix | Delete
* @since 5.5.0
[4009] Fix | Delete
*
[4010] Fix | Delete
* @global wpdb $wpdb WordPress database abstraction object.
[4011] Fix | Delete
*/
[4012] Fix | Delete
function _wp_batch_update_comment_type() {
[4013] Fix | Delete
global $wpdb;
[4014] Fix | Delete
[4015] Fix | Delete
$lock_name = 'update_comment_type.lock';
[4016] Fix | Delete
[4017] Fix | Delete
// Try to lock.
[4018] Fix | Delete
$lock_result = $wpdb->query( $wpdb->prepare( "INSERT IGNORE INTO `$wpdb->options` ( `option_name`, `option_value`, `autoload` ) VALUES (%s, %s, 'no') /* LOCK */", $lock_name, time() ) );
[4019] Fix | Delete
[4020] Fix | Delete
if ( ! $lock_result ) {
[4021] Fix | Delete
$lock_result = get_option( $lock_name );
[4022] Fix | Delete
[4023] Fix | Delete
// Bail if we were unable to create a lock, or if the existing lock is still valid.
[4024] Fix | Delete
if ( ! $lock_result || ( $lock_result > ( time() - HOUR_IN_SECONDS ) ) ) {
[4025] Fix | Delete
wp_schedule_single_event( time() + ( 5 * MINUTE_IN_SECONDS ), 'wp_update_comment_type_batch' );
[4026] Fix | Delete
return;
[4027] Fix | Delete
}
[4028] Fix | Delete
}
[4029] Fix | Delete
[4030] Fix | Delete
// Update the lock, as by this point we've definitely got a lock, just need to fire the actions.
[4031] Fix | Delete
update_option( $lock_name, time() );
[4032] Fix | Delete
[4033] Fix | Delete
// Check if there's still an empty comment type.
[4034] Fix | Delete
$empty_comment_type = $wpdb->get_var(
[4035] Fix | Delete
"SELECT comment_ID FROM $wpdb->comments
[4036] Fix | Delete
WHERE comment_type = ''
[4037] Fix | Delete
LIMIT 1"
[4038] Fix | Delete
);
[4039] Fix | Delete
[4040] Fix | Delete
// No empty comment type, we're done here.
[4041] Fix | Delete
if ( ! $empty_comment_type ) {
[4042] Fix | Delete
update_option( 'finished_updating_comment_type', true );
[4043] Fix | Delete
delete_option( $lock_name );
[4044] Fix | Delete
return;
[4045] Fix | Delete
}
[4046] Fix | Delete
[4047] Fix | Delete
// Empty comment type found? We'll need to run this script again.
[4048] Fix | Delete
wp_schedule_single_event( time() + ( 2 * MINUTE_IN_SECONDS ), 'wp_update_comment_type_batch' );
[4049] Fix | Delete
[4050] Fix | Delete
/**
[4051] Fix | Delete
* Filters the comment batch size for updating the comment type.
[4052] Fix | Delete
*
[4053] Fix | Delete
* @since 5.5.0
[4054] Fix | Delete
*
[4055] Fix | Delete
* @param int $comment_batch_size The comment batch size. Default 100.
[4056] Fix | Delete
*/
[4057] Fix | Delete
$comment_batch_size = (int) apply_filters( 'wp_update_comment_type_batch_size', 100 );
[4058] Fix | Delete
[4059] Fix | Delete
// Get the IDs of the comments to update.
[4060] Fix | Delete
$comment_ids = $wpdb->get_col(
[4061] Fix | Delete
$wpdb->prepare(
[4062] Fix | Delete
"SELECT comment_ID
[4063] Fix | Delete
FROM {$wpdb->comments}
[4064] Fix | Delete
WHERE comment_type = ''
[4065] Fix | Delete
ORDER BY comment_ID DESC
[4066] Fix | Delete
LIMIT %d",
[4067] Fix | Delete
$comment_batch_size
[4068] Fix | Delete
)
[4069] Fix | Delete
);
[4070] Fix | Delete
[4071] Fix | Delete
if ( $comment_ids ) {
[4072] Fix | Delete
$comment_id_list = implode( ',', $comment_ids );
[4073] Fix | Delete
[4074] Fix | Delete
// Update the `comment_type` field value to be `comment` for the next batch of comments.
[4075] Fix | Delete
$wpdb->query(
[4076] Fix | Delete
"UPDATE {$wpdb->comments}
[4077] Fix | Delete
SET comment_type = 'comment'
[4078] Fix | Delete
WHERE comment_type = ''
[4079] Fix | Delete
AND comment_ID IN ({$comment_id_list})" // phpcs:ignore WordPress.DB.PreparedSQL.InterpolatedNotPrepared
[4080] Fix | Delete
);
[4081] Fix | Delete
[4082] Fix | Delete
// Make sure to clean the comment cache.
[4083] Fix | Delete
clean_comment_cache( $comment_ids );
[4084] Fix | Delete
}
[4085] Fix | Delete
[4086] Fix | Delete
delete_option( $lock_name );
[4087] Fix | Delete
}
[4088] Fix | Delete
[4089] Fix | Delete
/**
[4090] Fix | Delete
* In order to avoid the _wp_batch_update_comment_type() job being accidentally removed,
[4091] Fix | Delete
* check that it's still scheduled while we haven't finished updating comment types.
[4092] Fix | Delete
*
[4093] Fix | Delete
* @ignore
[4094] Fix | Delete
* @since 5.5.0
[4095] Fix | Delete
*/
[4096] Fix | Delete
function _wp_check_for_scheduled_update_comment_type() {
[4097] Fix | Delete
if ( ! get_option( 'finished_updating_comment_type' ) && ! wp_next_scheduled( 'wp_update_comment_type_batch' ) ) {
[4098] Fix | Delete
wp_schedule_single_event( time() + MINUTE_IN_SECONDS, 'wp_update_comment_type_batch' );
[4099] Fix | Delete
}
[4100] Fix | Delete
}
[4101] Fix | Delete
[4102] Fix | Delete
It is recommended that you Edit text format, this type of Fix handles quite a lot in one request
Function