Akismet Anti-Spam - Version 4.0.2

Version Description

Release Date - 18 December 2017

  • Fixed a bug that could cause Akismet to recheck a comment that has already been manually approved or marked as spam.
  • Fixed a bug that could cause Akismet to claim that some comments are still waiting to be checked when no comments are waiting to be checked.
Download this release

Release Info

Developer stephdau
Plugin Icon 128x128 Akismet Anti-Spam
Version 4.0.2
Comparing to
See all releases

Code changes from version 4.0.1 to 4.0.2

Files changed (5) hide show
  1. akismet.php +2 -2
  2. class.akismet-admin.php +18 -4
  3. class.akismet.php +7 -1
  4. readme.txt +8 -2
  5. views/notice.php +1 -1
akismet.php CHANGED
@@ -6,7 +6,7 @@
6
  Plugin Name: Akismet Anti-Spam
7
  Plugin URI: https://akismet.com/
8
  Description: Used by millions, Akismet is quite possibly the best way in the world to <strong>protect your blog from spam</strong>. It keeps your site protected even while you sleep. To get started: activate the Akismet plugin and then go to your Akismet Settings page to set up your API key.
9
- Version: 4.0.1
10
  Author: Automattic
11
  Author URI: https://automattic.com/wordpress-plugins/
12
  License: GPLv2 or later
@@ -37,7 +37,7 @@ if ( !function_exists( 'add_action' ) ) {
37
  exit;
38
  }
39
 
40
- define( 'AKISMET_VERSION', '4.0.1' );
41
  define( 'AKISMET__MINIMUM_WP_VERSION', '4.0' );
42
  define( 'AKISMET__PLUGIN_DIR', plugin_dir_path( __FILE__ ) );
43
  define( 'AKISMET_DELETE_LIMIT', 100000 );
6
  Plugin Name: Akismet Anti-Spam
7
  Plugin URI: https://akismet.com/
8
  Description: Used by millions, Akismet is quite possibly the best way in the world to <strong>protect your blog from spam</strong>. It keeps your site protected even while you sleep. To get started: activate the Akismet plugin and then go to your Akismet Settings page to set up your API key.
9
+ Version: 4.0.2
10
  Author: Automattic
11
  Author URI: https://automattic.com/wordpress-plugins/
12
  License: GPLv2 or later
37
  exit;
38
  }
39
 
40
+ define( 'AKISMET_VERSION', '4.0.2' );
41
  define( 'AKISMET__MINIMUM_WP_VERSION', '4.0' );
42
  define( 'AKISMET__PLUGIN_DIR', plugin_dir_path( __FILE__ ) );
43
  define( 'AKISMET_DELETE_LIMIT', 100000 );
class.akismet-admin.php CHANGED
@@ -725,9 +725,23 @@ class Akismet_Admin {
725
  return self::check_server_connectivity( $cache_timeout );
726
  }
727
 
728
- public static function get_number_spam_waiting() {
729
- global $wpdb;
730
- return (int) $wpdb->get_var( "SELECT COUNT(*) FROM {$wpdb->commentmeta} WHERE meta_key = 'akismet_error'" );
 
 
 
 
 
 
 
 
 
 
 
 
 
 
731
  }
732
 
733
  public static function get_page_url( $page = 'config' ) {
@@ -814,7 +828,7 @@ class Akismet_Admin {
814
  public static function display_spam_check_warning() {
815
  Akismet::fix_scheduled_recheck();
816
 
817
- if ( wp_next_scheduled('akismet_schedule_cron_recheck') > time() && self::get_number_spam_waiting() > 0 ) {
818
  $link_text = apply_filters( 'akismet_spam_check_warning_link_text', sprintf( __( 'Please check your <a href="%s">Akismet configuration</a> and contact your web host if problems persist.', 'akismet'), esc_url( self::get_page_url() ) ) );
819
  Akismet::view( 'notice', array( 'type' => 'spam-check', 'link_text' => $link_text ) );
820
  }
725
  return self::check_server_connectivity( $cache_timeout );
726
  }
727
 
728
+ /**
729
+ * Find out whether any comments in the Pending queue have not yet been checked by Akismet.
730
+ *
731
+ * @return bool
732
+ */
733
+ public static function are_any_comments_waiting_to_be_checked() {
734
+ return !! get_comments( array(
735
+ // Exclude comments that are not pending. This would happen if someone manually approved or spammed a comment
736
+ // that was waiting to be checked. The akismet_error meta entry will eventually be removed by the cron recheck job.
737
+ 'status' => 'hold',
738
+
739
+ // This is the commentmeta that is saved when a comment couldn't be checked.
740
+ 'meta_key' => 'akismet_error',
741
+
742
+ // We only need to know whether at least one comment is waiting for a check.
743
+ 'number' => 1,
744
+ ) );
745
  }
746
 
747
  public static function get_page_url( $page = 'config' ) {
828
  public static function display_spam_check_warning() {
829
  Akismet::fix_scheduled_recheck();
830
 
831
+ if ( wp_next_scheduled('akismet_schedule_cron_recheck') > time() && self::are_any_comments_waiting_to_be_checked() ) {
832
  $link_text = apply_filters( 'akismet_spam_check_warning_link_text', sprintf( __( 'Please check your <a href="%s">Akismet configuration</a> and contact your web host if problems persist.', 'akismet'), esc_url( self::get_page_url() ) ) );
833
  Akismet::view( 'notice', array( 'type' => 'spam-check', 'link_text' => $link_text ) );
834
  }
class.akismet.php CHANGED
@@ -701,7 +701,13 @@ class Akismet {
701
  foreach ( (array) $comment_errors as $comment_id ) {
702
  // if the comment no longer exists, or is too old, remove the meta entry from the queue to avoid getting stuck
703
  $comment = get_comment( $comment_id );
704
- if ( !$comment || strtotime( $comment->comment_date_gmt ) < strtotime( "-15 days" ) ) {
 
 
 
 
 
 
705
  delete_comment_meta( $comment_id, 'akismet_error' );
706
  delete_comment_meta( $comment_id, 'akismet_delayed_moderation_email' );
707
  continue;
701
  foreach ( (array) $comment_errors as $comment_id ) {
702
  // if the comment no longer exists, or is too old, remove the meta entry from the queue to avoid getting stuck
703
  $comment = get_comment( $comment_id );
704
+
705
+ if (
706
+ ! $comment // Comment has been deleted
707
+ || strtotime( $comment->comment_date_gmt ) < strtotime( "-15 days" ) // Comment is too old.
708
+ || $comment->comment_approved !== "0" // Comment is no longer in the Pending queue
709
+ ) {
710
+ echo "Deleting";
711
  delete_comment_meta( $comment_id, 'akismet_error' );
712
  delete_comment_meta( $comment_id, 'akismet_delayed_moderation_email' );
713
  continue;
readme.txt CHANGED
@@ -2,8 +2,8 @@
2
  Contributors: matt, ryan, andy, mdawaffe, tellyworth, josephscott, lessbloat, eoigal, cfinke, automattic, jgs, procifer
3
  Tags: akismet, comments, spam, antispam, anti-spam, anti spam, comment moderation, comment spam, contact form spam, spam comments
4
  Requires at least: 4.0
5
- Tested up to: 4.9
6
- Stable tag: 4.0.1
7
  License: GPLv2 or later
8
 
9
  Akismet checks your comments and contact form submissions against our global database of spam to protect you and your site from malicious content.
@@ -30,6 +30,12 @@ Upload the Akismet plugin to your blog, Activate it, then enter your [Akismet.co
30
 
31
  == Changelog ==
32
 
 
 
 
 
 
 
33
  = 4.0.1 =
34
  *Release Date - 6 November 2017*
35
 
2
  Contributors: matt, ryan, andy, mdawaffe, tellyworth, josephscott, lessbloat, eoigal, cfinke, automattic, jgs, procifer
3
  Tags: akismet, comments, spam, antispam, anti-spam, anti spam, comment moderation, comment spam, contact form spam, spam comments
4
  Requires at least: 4.0
5
+ Tested up to: 4.9.1
6
+ Stable tag: 4.0.2
7
  License: GPLv2 or later
8
 
9
  Akismet checks your comments and contact form submissions against our global database of spam to protect you and your site from malicious content.
30
 
31
  == Changelog ==
32
 
33
+ = 4.0.2 =
34
+ *Release Date - 18 December 2017*
35
+
36
+ * Fixed a bug that could cause Akismet to recheck a comment that has already been manually approved or marked as spam.
37
+ * Fixed a bug that could cause Akismet to claim that some comments are still waiting to be checked when no comments are waiting to be checked.
38
+
39
  = 4.0.1 =
40
  *Release Date - 6 November 2017*
41
 
views/notice.php CHANGED
@@ -13,7 +13,7 @@
13
  </form>
14
  </div>
15
  <?php elseif ( $type == 'spam-check' ) :?>
16
- <div id="akismet-warning" class="updated fade">
17
  <p><strong><?php esc_html_e( 'Akismet has detected a problem.', 'akismet' );?></strong></p>
18
  <p><?php printf( __( 'Some comments have not yet been checked for spam by Akismet. They have been temporarily held for moderation and will automatically be rechecked later.', 'akismet' ) ); ?></p>
19
  <?php if ( $link_text ) { ?>
13
  </form>
14
  </div>
15
  <?php elseif ( $type == 'spam-check' ) :?>
16
+ <div class="notice notice-warning">
17
  <p><strong><?php esc_html_e( 'Akismet has detected a problem.', 'akismet' );?></strong></p>
18
  <p><?php printf( __( 'Some comments have not yet been checked for spam by Akismet. They have been temporarily held for moderation and will automatically be rechecked later.', 'akismet' ) ); ?></p>
19
  <?php if ( $link_text ) { ?>