diff options
author | Theo Chatzimichos <tampakrap@gentoo.org> | 2011-01-01 17:55:35 +0200 |
---|---|---|
committer | Theo Chatzimichos <tampakrap@gentoo.org> | 2011-01-01 17:55:35 +0200 |
commit | 08c08d251a0e2a71ebe8073c782e226e17b07012 (patch) | |
tree | 10c65598c02105770dc71f3b9f1dcc05de9616f2 /plugins/akismet/akismet.php | |
parent | Fixor akismet to include the file with the api key (diff) | |
download | blogs-gentoo-08c08d251a0e2a71ebe8073c782e226e17b07012.tar.gz blogs-gentoo-08c08d251a0e2a71ebe8073c782e226e17b07012.tar.bz2 blogs-gentoo-08c08d251a0e2a71ebe8073c782e226e17b07012.zip |
Update akismet to 2.5.1 and smart-youtube to 3.8.3
Diffstat (limited to 'plugins/akismet/akismet.php')
-rw-r--r-- | plugins/akismet/akismet.php | 39 |
1 files changed, 29 insertions, 10 deletions
diff --git a/plugins/akismet/akismet.php b/plugins/akismet/akismet.php index f5a76421..e5428382 100644 --- a/plugins/akismet/akismet.php +++ b/plugins/akismet/akismet.php @@ -5,8 +5,8 @@ /* Plugin Name: Akismet Plugin URI: http://akismet.com/ -Description: Used by millions, Akismet is quite possibly the best way in the world to <strong>protect your blog from comment and track-back spam</strong>. It keeps your site protected from spam even while you sleep. To get started: 1) Click the "Activate" link to the left of this description, 2) <a href="https:akismet.com/signup/?return=true">Sign up for an Akismet API key</a>, and 3) Go to your <a href="plugins.php?page=akismet-key-config">Akismet configuration</a> page, and save your API key. -Version: 2.5.0 +Description: Used by millions, Akismet is quite possibly the best way in the world to <strong>protect your blog from comment and track-back spam</strong>. It keeps your site protected from spam even while you sleep. To get started: 1) Click the "Activate" link to the left of this description, 2) <a href="http://akismet.com/get/?return=true">Sign up for an Akismet API key</a>, and 3) Go to your <a href="plugins.php?page=akismet-key-config">Akismet configuration</a> page, and save your API key. +Version: 2.5.1 Author: Automattic Author URI: http://automattic.com/wordpress-plugins/ License: GPLv2 @@ -84,8 +84,6 @@ function akismet_verify_key( $key, $ip = null ) { // if we're in debug or test modes, use a reduced service level so as not to polute training or stats data function akismet_test_mode() { - if ( defined('WP_DEBUG') && WP_DEBUG ) - return true; if ( defined('AKISMET_TEST_MODE') && AKISMET_TEST_MODE ) return true; return false; @@ -208,7 +206,7 @@ function akismet_update_comment_history( $comment_id, $message, $event=null ) { return false; $user = ''; - if ( is_object($current_user) ) + if ( is_object($current_user) && isset($current_user->user_login) ) $user = $current_user->user_login; $event = array( @@ -298,7 +296,7 @@ function akismet_auto_check_comment( $commentdata ) { $comment['user_role'] = akismet_get_user_roles($comment['user_ID']); - $akismet_nonce_option = get_option( 'akismet_comment_nonce' ); + $akismet_nonce_option = apply_filters( 'akismet_comment_nonce', get_option( 'akismet_comment_nonce' ) ); $comment['akismet_comment_nonce'] = 'inactive'; if ( $akismet_nonce_option == 'true' || $akismet_nonce_option == '' ) { $comment['akismet_comment_nonce'] = 'failed'; @@ -352,6 +350,7 @@ function akismet_auto_check_comment( $commentdata ) { if ( $incr = apply_filters('akismet_spam_count_incr', 1) ) update_option( 'akismet_spam_count', get_option('akismet_spam_count') + $incr ); wp_redirect( $_SERVER['HTTP_REFERER'] ); + die(); } } @@ -381,9 +380,13 @@ function akismet_delete_old() { $comment_ids = $wpdb->get_col("SELECT comment_id FROM $wpdb->comments WHERE DATE_SUB('$now_gmt', INTERVAL 15 DAY) > comment_date_gmt AND comment_approved = 'spam'"); if ( empty( $comment_ids ) ) return; + + $comma_comment_ids = implode( ', ', array_map('intval', $comment_ids) ); do_action( 'delete_comment', $comment_ids ); - $wpdb->query("DELETE FROM $wpdb->comments WHERE comment_id IN ( " . implode( ', ', $comment_ids ) . " )"); + $wpdb->query("DELETE FROM $wpdb->comments WHERE comment_id IN ( $comma_comment_ids )"); + $wpdb->query("DELETE FROM $wpdb->commentmeta WHERE comment_id IN ( $comma_comment_ids )"); + clean_comment_cache( $comment_ids ); $n = mt_rand(1, 5000); if ( apply_filters('akismet_optimize_table', ($n == 11)) ) // lucky number $wpdb->query("OPTIMIZE TABLE $wpdb->comments"); @@ -420,7 +423,7 @@ function akismet_check_db_comment( $id, $recheck_reason = 'recheck_queue' ) { return $response[1]; } -function akismet_cron_recheck( $data ) { +function akismet_cron_recheck() { global $wpdb; delete_option('akismet_available_servers'); @@ -429,9 +432,16 @@ function akismet_cron_recheck( $data ) { SELECT comment_id FROM {$wpdb->prefix}commentmeta WHERE meta_key = 'akismet_error' + LIMIT 100 " ); - + foreach ( (array) $comment_errors as $comment_id ) { + // if the comment no longer exists, remove the meta entry from the queue to avoid getting stuck + if ( !get_comment( $comment_id ) ) { + delete_comment_meta( $comment_id, 'akismet_error' ); + continue; + } + add_comment_meta( $comment_id, 'akismet_rechecking', true ); $status = akismet_check_db_comment( $comment_id, 'retry' ); @@ -467,12 +477,21 @@ function akismet_cron_recheck( $data ) { return; } } + + $remaining = $wpdb->get_var( $wpdb->prepare( "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' ); + } } add_action( 'akismet_schedule_cron_recheck', 'akismet_cron_recheck' ); function akismet_add_comment_nonce( $post_id ) { + echo '<p style="display: none;">'; wp_nonce_field( 'akismet_comment_nonce_' . $post_id, 'akismet_comment_nonce', FALSE ); + echo '</p>'; } -if ( get_option( 'akismet_comment_nonce' ) == 'true' || get_option( 'akismet_comment_nonce' ) == '' ) +$akismet_comment_nonce_option = apply_filters( 'akismet_comment_nonce', get_option( 'akismet_comment_nonce' ) ); + +if ( $akismet_comment_nonce_option == 'true' || $akismet_comment_nonce_option == '' ) add_action( 'comment_form', 'akismet_add_comment_nonce' ); |