X-Git-Url: https://scripts.mit.edu/gitweb/autoinstalls/wordpress.git/blobdiff_plain/48ab98cb1779cf2088c1351ac3dd3d0da6fb31d3..refs/tags/wordpress-4.1-scripts:/wp-content/plugins/akismet/class.akismet.php diff --git a/wp-content/plugins/akismet/class.akismet.php b/wp-content/plugins/akismet/class.akismet.php index a9ab0eaa..bcc5163e 100644 --- a/wp-content/plugins/akismet/class.akismet.php +++ b/wp-content/plugins/akismet/class.akismet.php @@ -256,13 +256,31 @@ class Akismet { public static function delete_old_comments() { global $wpdb; - while( $comment_ids = $wpdb->get_col( $wpdb->prepare( "SELECT comment_id FROM {$wpdb->comments} WHERE DATE_SUB(NOW(), INTERVAL 15 DAY) > comment_date_gmt AND comment_approved = 'spam' LIMIT %d", defined( 'AKISMET_DELETE_LIMIT' ) ? AKISMET_DELETE_LIMIT : 10000 ) ) ) { + /** + * Determines how many comments will be deleted in each batch. + * + * @param int The default, as defined by AKISMET_DELETE_LIMIT. + */ + $delete_limit = apply_filters( 'akismet_delete_comment_limit', defined( 'AKISMET_DELETE_LIMIT' ) ? AKISMET_DELETE_LIMIT : 10000 ); + $delete_limit = max( 1, intval( $delete_limit ) ); + + /** + * Determines how many days a comment will be left in the Spam queue before being deleted. + * + * @param int The default number of days. + */ + $delete_interval = apply_filters( 'akismet_delete_comment_interval', 15 ); + $delete_interval = max( 1, intval( $delete_interval ) ); + + while ( $comment_ids = $wpdb->get_col( $wpdb->prepare( "SELECT comment_id FROM {$wpdb->comments} WHERE DATE_SUB(NOW(), INTERVAL %d DAY) > comment_date_gmt AND comment_approved = 'spam' LIMIT %d", $delete_interval, $delete_limit ) ) ) { if ( empty( $comment_ids ) ) return; $wpdb->queries = array(); - do_action( 'delete_comment', $comment_ids ); + foreach ( $comment_ids as $comment_id ) { + do_action( 'delete_comment', $comment_id ); + } $comma_comment_ids = implode( ', ', array_map('intval', $comment_ids) ); @@ -926,8 +944,16 @@ p { return _http_build_query( $args, '', '&' ); } + /** + * Log debugging info to the error log. + * + * Enabled when WP_DEBUG_LOG is enabled, but can be disabled via the akismet_debug_log filter. + * + * @param mixed $akismet_debug The data to log. + */ public static function log( $akismet_debug ) { - if ( defined( 'WP_DEBUG_LOG' ) && WP_DEBUG_LOG ) - error_log( print_r( compact( 'akismet_debug' ), 1 ) ); //send message to debug.log when in debug mode + if ( apply_filters( 'akismet_debug_log', defined( 'WP_DEBUG_LOG' ) && WP_DEBUG_LOG ) ) { + error_log( print_r( compact( 'akismet_debug' ), true ) ); + } } } \ No newline at end of file