Version Description
Release Date - 19 February 2018
- Added a scheduled task to remove entries in wp_commentmeta that no longer have corresponding comments in wp_comments.
- Added a new
akismet_batch_delete_countaction to the batch delete methods for people who'd like to keep track of the numbers of records being processed by those methods.
Download this release
Release Info
| Developer | procifer |
| Plugin | |
| Version | 4.0.3 |
| Comparing to | |
| See all releases | |
Code changes from version 4.0.2 to 4.0.3
- akismet.php +3 -3
- class.akismet.php +41 -1
- readme.txt +8 -2
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.
|
| 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.
|
| 41 |
define( 'AKISMET__MINIMUM_WP_VERSION', '4.0' );
|
| 42 |
define( 'AKISMET__PLUGIN_DIR', plugin_dir_path( __FILE__ ) );
|
| 43 |
define( 'AKISMET_DELETE_LIMIT', 100000 );
|
|
@@ -63,4 +63,4 @@ require_once( AKISMET__PLUGIN_DIR . 'wrapper.php' );
|
|
| 63 |
|
| 64 |
if ( defined( 'WP_CLI' ) && WP_CLI ) {
|
| 65 |
require_once( AKISMET__PLUGIN_DIR . 'class.akismet-cli.php' );
|
| 66 |
-
}
|
| 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.3
|
| 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.3' );
|
| 41 |
define( 'AKISMET__MINIMUM_WP_VERSION', '4.0' );
|
| 42 |
define( 'AKISMET__PLUGIN_DIR', plugin_dir_path( __FILE__ ) );
|
| 43 |
define( 'AKISMET_DELETE_LIMIT', 100000 );
|
| 63 |
|
| 64 |
if ( defined( 'WP_CLI' ) && WP_CLI ) {
|
| 65 |
require_once( AKISMET__PLUGIN_DIR . 'class.akismet-cli.php' );
|
| 66 |
+
}
|
class.akismet.php
CHANGED
|
@@ -30,6 +30,7 @@ class Akismet {
|
|
| 30 |
|
| 31 |
add_action( 'akismet_scheduled_delete', array( 'Akismet', 'delete_old_comments' ) );
|
| 32 |
add_action( 'akismet_scheduled_delete', array( 'Akismet', 'delete_old_comments_meta' ) );
|
|
|
|
| 33 |
add_action( 'akismet_schedule_cron_recheck', array( 'Akismet', 'cron_recheck' ) );
|
| 34 |
|
| 35 |
add_action( 'comment_form', array( 'Akismet', 'add_comment_nonce' ), 1 );
|
|
@@ -348,6 +349,7 @@ class Akismet {
|
|
| 348 |
|
| 349 |
foreach ( $comment_ids as $comment_id ) {
|
| 350 |
do_action( 'delete_comment', $comment_id );
|
|
|
|
| 351 |
}
|
| 352 |
|
| 353 |
// Prepared as strings since comment_id is an unsigned BIGINT, and using %d will constrain the value to the maximum signed BIGINT.
|
|
@@ -369,7 +371,7 @@ class Akismet {
|
|
| 369 |
|
| 370 |
$interval = apply_filters( 'akismet_delete_commentmeta_interval', 15 );
|
| 371 |
|
| 372 |
-
#
|
| 373 |
$interval = absint( $interval );
|
| 374 |
if ( $interval < 1 )
|
| 375 |
$interval = 1;
|
|
@@ -384,6 +386,7 @@ class Akismet {
|
|
| 384 |
|
| 385 |
foreach ( $comment_ids as $comment_id ) {
|
| 386 |
delete_comment_meta( $comment_id, 'akismet_as_submitted' );
|
|
|
|
| 387 |
}
|
| 388 |
|
| 389 |
do_action( 'akismet_delete_commentmeta_batch', count( $comment_ids ) );
|
|
@@ -393,6 +396,43 @@ class Akismet {
|
|
| 393 |
$wpdb->query("OPTIMIZE TABLE {$wpdb->commentmeta}");
|
| 394 |
}
|
| 395 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 396 |
// how many approved comments does this author have?
|
| 397 |
public static function get_user_comments_approved( $user_id, $comment_author_email, $comment_author, $comment_author_url ) {
|
| 398 |
global $wpdb;
|
| 30 |
|
| 31 |
add_action( 'akismet_scheduled_delete', array( 'Akismet', 'delete_old_comments' ) );
|
| 32 |
add_action( 'akismet_scheduled_delete', array( 'Akismet', 'delete_old_comments_meta' ) );
|
| 33 |
+
add_action( 'akismet_scheduled_delete', array( 'Akismet', 'delete_orphaned_commentmeta' ) );
|
| 34 |
add_action( 'akismet_schedule_cron_recheck', array( 'Akismet', 'cron_recheck' ) );
|
| 35 |
|
| 36 |
add_action( 'comment_form', array( 'Akismet', 'add_comment_nonce' ), 1 );
|
| 349 |
|
| 350 |
foreach ( $comment_ids as $comment_id ) {
|
| 351 |
do_action( 'delete_comment', $comment_id );
|
| 352 |
+
do_action( 'akismet_batch_delete_count', __FUNCTION__ );
|
| 353 |
}
|
| 354 |
|
| 355 |
// Prepared as strings since comment_id is an unsigned BIGINT, and using %d will constrain the value to the maximum signed BIGINT.
|
| 371 |
|
| 372 |
$interval = apply_filters( 'akismet_delete_commentmeta_interval', 15 );
|
| 373 |
|
| 374 |
+
# enforce a minimum of 1 day
|
| 375 |
$interval = absint( $interval );
|
| 376 |
if ( $interval < 1 )
|
| 377 |
$interval = 1;
|
| 386 |
|
| 387 |
foreach ( $comment_ids as $comment_id ) {
|
| 388 |
delete_comment_meta( $comment_id, 'akismet_as_submitted' );
|
| 389 |
+
do_action( 'akismet_batch_delete_count', __FUNCTION__ );
|
| 390 |
}
|
| 391 |
|
| 392 |
do_action( 'akismet_delete_commentmeta_batch', count( $comment_ids ) );
|
| 396 |
$wpdb->query("OPTIMIZE TABLE {$wpdb->commentmeta}");
|
| 397 |
}
|
| 398 |
|
| 399 |
+
// Clear out comments meta that no longer have corresponding comments in the database
|
| 400 |
+
public static function delete_orphaned_commentmeta() {
|
| 401 |
+
global $wpdb;
|
| 402 |
+
|
| 403 |
+
$last_meta_id = 0;
|
| 404 |
+
$start_time = isset( $_SERVER['REQUEST_TIME_FLOAT'] ) ? $_SERVER['REQUEST_TIME_FLOAT'] : microtime( true );
|
| 405 |
+
$max_exec_time = max( ini_get('max_execution_time') - 5, 3 );
|
| 406 |
+
|
| 407 |
+
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 ) ) ) {
|
| 408 |
+
if ( empty( $commentmeta_results ) )
|
| 409 |
+
return;
|
| 410 |
+
|
| 411 |
+
$wpdb->queries = array();
|
| 412 |
+
|
| 413 |
+
$commentmeta_deleted = 0;
|
| 414 |
+
|
| 415 |
+
foreach ( $commentmeta_results as $commentmeta ) {
|
| 416 |
+
if ( 'akismet_' == substr( $commentmeta->meta_key, 0, 8 ) ) {
|
| 417 |
+
delete_comment_meta( $commentmeta->comment_id, $commentmeta->meta_key );
|
| 418 |
+
do_action( 'akismet_batch_delete_count', __FUNCTION__ );
|
| 419 |
+
$commentmeta_deleted++;
|
| 420 |
+
}
|
| 421 |
+
|
| 422 |
+
$last_meta_id = $commentmeta->meta_id;
|
| 423 |
+
}
|
| 424 |
+
|
| 425 |
+
do_action( 'akismet_delete_commentmeta_batch', $commentmeta_deleted );
|
| 426 |
+
|
| 427 |
+
// If we're getting close to max_execution_time, quit for this round.
|
| 428 |
+
if ( microtime(true) - $start_time > $max_exec_time )
|
| 429 |
+
return;
|
| 430 |
+
}
|
| 431 |
+
|
| 432 |
+
if ( apply_filters( 'akismet_optimize_table', ( mt_rand(1, 5000) == 11), $wpdb->commentmeta ) ) // lucky number
|
| 433 |
+
$wpdb->query("OPTIMIZE TABLE {$wpdb->commentmeta}");
|
| 434 |
+
}
|
| 435 |
+
|
| 436 |
// how many approved comments does this author have?
|
| 437 |
public static function get_user_comments_approved( $user_id, $comment_author_email, $comment_author, $comment_author_url ) {
|
| 438 |
global $wpdb;
|
readme.txt
CHANGED
|
@@ -1,9 +1,9 @@
|
|
| 1 |
=== Akismet Anti-Spam ===
|
| 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.
|
| 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.2 =
|
| 34 |
*Release Date - 18 December 2017*
|
| 35 |
|
| 1 |
=== Akismet Anti-Spam ===
|
| 2 |
+
Contributors: matt, ryan, andy, mdawaffe, tellyworth, josephscott, lessbloat, eoigal, cfinke, automattic, jgs, procifer, stephdau
|
| 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.3
|
| 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.3 =
|
| 34 |
+
*Release Date - 19 February 2018*
|
| 35 |
+
|
| 36 |
+
* Added a scheduled task to remove entries in wp_commentmeta that no longer have corresponding comments in wp_comments.
|
| 37 |
+
* Added a new `akismet_batch_delete_count` action to the batch delete methods for people who'd like to keep track of the numbers of records being processed by those methods.
|
| 38 |
+
|
| 39 |
= 4.0.2 =
|
| 40 |
*Release Date - 18 December 2017*
|
| 41 |
|
