You appear to be a bot. Output may be restricted
Description
Usage
Akismet::delete_orphaned_commentmeta();
Parameters
Returns
void
Source
File name: akismet/class.akismet.php
Lines:
1 to 35 of 35
public static function delete_orphaned_commentmeta() { global $wpdb; $last_meta_id = 0; $start_time = isset( $_SERVER['REQUEST_TIME_FLOAT'] ) ? $_SERVER['REQUEST_TIME_FLOAT'] : microtime( true ); $max_exec_time = max( ini_get('max_execution_time') - 5, 3 ); while ( $commentmeta_results = $wpdb->get_results( $wpdb->prepare( "SELECT m.meta_id, m.comment_id, m.meta_key FROM {$wpdb->commentmeta} as m LEFT JOIN {$wpdb->comments} as c USING(comment_id) WHERE c.comment_id IS NULL AND m.meta_id > %d ORDER BY m.meta_id LIMIT 1000", $last_meta_id ) ) ) { if ( empty( $commentmeta_results ) ) return; $wpdb->queries = array(); $commentmeta_deleted = 0; foreach ( $commentmeta_results as $commentmeta ) { if ( 'akismet_' == substr( $commentmeta->meta_key, 0, 8 ) ) { delete_comment_meta( $commentmeta->comment_id, $commentmeta->meta_key ); do_action( 'akismet_batch_delete_count', __FUNCTION__ ); $commentmeta_deleted++; } $last_meta_id = $commentmeta->meta_id; } do_action( 'akismet_delete_commentmeta_batch', $commentmeta_deleted ); // If we're getting close to max_execution_time, quit for this round. if ( microtime(true) - $start_time > $max_exec_time ) return; } if ( apply_filters( 'akismet_optimize_table', ( mt_rand(1, 5000) == 11), $wpdb->commentmeta ) ) // lucky number $wpdb->query("OPTIMIZE TABLE {$wpdb->commentmeta}"); }