You appear to be a bot. Output may be restricted
Description
Usage
Akismet::cron_recheck();
Parameters
Returns
void
Source
File name: akismet/class.akismet.php
Lines:
1 to 88 of 88
public static function cron_recheck() { global $wpdb; $api_key = self::get_api_key(); $status = self::verify_key( $api_key ); if ( get_option( 'akismet_alert_code' ) || $status == 'invalid' ) { // since there is currently a problem with the key, reschedule a check for 6 hours hence wp_schedule_single_event( time() + 21600, 'akismet_schedule_cron_recheck' ); do_action( 'akismet_scheduled_recheck', 'key-problem-' . get_option( 'akismet_alert_code' ) . '-' . $status ); return false; } delete_option('akismet_available_servers'); $comment_errors = $wpdb->get_col( "SELECT comment_id FROM {$wpdb->commentmeta} WHERE meta_key = 'akismet_error' LIMIT 100" ); load_plugin_textdomain( 'akismet' ); foreach ( (array) $comment_errors as $comment_id ) { // if the comment no longer exists, or is too old, remove the meta entry from the queue to avoid getting stuck $comment = get_comment( $comment_id ); if ( ! $comment // Comment has been deleted || strtotime( $comment->comment_date_gmt ) < strtotime( "-15 days" ) // Comment is too old. || $comment->comment_approved !== "0" // Comment is no longer in the Pending queue ) { delete_comment_meta( $comment_id, 'akismet_error' ); delete_comment_meta( $comment_id, 'akismet_delayed_moderation_email' ); continue; } add_comment_meta( $comment_id, 'akismet_rechecking', true ); $status = self::check_db_comment( $comment_id, 'retry' ); $event = ''; if ( $status == 'true' ) { $event = 'cron-retry-spam'; } elseif ( $status == 'false' ) { $event = 'cron-retry-ham'; } // If we got back a legit response then update the comment history // other wise just bail now and try again later. No point in // re-trying all the comments once we hit one failure. if ( !empty( $event ) ) { delete_comment_meta( $comment_id, 'akismet_error' ); self::update_comment_history( $comment_id, '', $event ); update_comment_meta( $comment_id, 'akismet_result', $status ); // make sure the comment status is still pending. if it isn't, that means the user has already moved it elsewhere. $comment = get_comment( $comment_id ); if ( $comment && 'unapproved' == wp_get_comment_status( $comment_id ) ) { if ( $status == 'true' ) { wp_spam_comment( $comment_id ); } elseif ( $status == 'false' ) { // comment is good, but it's still in the pending queue. depending on the moderation settings // we may need to change it to approved. if ( check_comment($comment->comment_author, $comment->comment_author_email, $comment->comment_author_url, $comment->comment_content, $comment->comment_author_IP, $comment->comment_agent, $comment->comment_type) ) wp_set_comment_status( $comment_id, 1 ); else if ( get_comment_meta( $comment_id, 'akismet_delayed_moderation_email', true ) ) wp_notify_moderator( $comment_id ); } } delete_comment_meta( $comment_id, 'akismet_delayed_moderation_email' ); } else { // If this comment has been pending moderation for longer than MAX_DELAY_BEFORE_MODERATION_EMAIL, // send a moderation email now. if ( ( intval( gmdate( 'U' ) ) - strtotime( $comment->comment_date_gmt ) ) < self::MAX_DELAY_BEFORE_MODERATION_EMAIL ) { delete_comment_meta( $comment_id, 'akismet_delayed_moderation_email' ); wp_notify_moderator( $comment_id ); } delete_comment_meta( $comment_id, 'akismet_rechecking' ); wp_schedule_single_event( time() + 1200, 'akismet_schedule_cron_recheck' ); do_action( 'akismet_scheduled_recheck', 'check-db-comment-' . $status ); return; } delete_comment_meta( $comment_id, 'akismet_rechecking' ); } $remaining = $wpdb->get_var( "SELECT COUNT(*) FROM {$wpdb->commentmeta} WHERE meta_key = 'akismet_error'" ); if ( $remaining && !wp_next_scheduled('akismet_schedule_cron_recheck') ) { wp_schedule_single_event( time() + 1200, 'akismet_schedule_cron_recheck' ); do_action( 'akismet_scheduled_recheck', 'remaining' ); } }