diff options
author | Anthony G. Basile <blueness@gentoo.org> | 2018-03-10 19:15:38 -0500 |
---|---|---|
committer | Anthony G. Basile <blueness@gentoo.org> | 2018-03-10 19:15:38 -0500 |
commit | 5791bc736123840f8ec75884a52da772897f909d (patch) | |
tree | cf4e3a3ba91c5fb90ae72e5d2a0d4dab57318105 /plugins | |
parent | Update mantra 3.0.4 (diff) | |
download | blogs-gentoo-5791bc736123840f8ec75884a52da772897f909d.tar.gz blogs-gentoo-5791bc736123840f8ec75884a52da772897f909d.tar.bz2 blogs-gentoo-5791bc736123840f8ec75884a52da772897f909d.zip |
Update akismet 4.0.3
Signed-off-by: Anthony G. Basile <blueness@gentoo.org>
Diffstat (limited to 'plugins')
-rw-r--r-- | plugins/akismet/akismet.php | 6 | ||||
-rw-r--r-- | plugins/akismet/class.akismet.php | 42 | ||||
-rw-r--r-- | plugins/akismet/readme.txt | 10 |
3 files changed, 52 insertions, 6 deletions
diff --git a/plugins/akismet/akismet.php b/plugins/akismet/akismet.php index 9e249017..a8ea4a15 100644 --- a/plugins/akismet/akismet.php +++ b/plugins/akismet/akismet.php @@ -6,7 +6,7 @@ Plugin Name: Akismet Anti-Spam Plugin URI: https://akismet.com/ 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. -Version: 4.0.2 +Version: 4.0.3 Author: Automattic Author URI: https://automattic.com/wordpress-plugins/ License: GPLv2 or later @@ -37,7 +37,7 @@ if ( !function_exists( 'add_action' ) ) { exit; } -define( 'AKISMET_VERSION', '4.0.2' ); +define( 'AKISMET_VERSION', '4.0.3' ); define( 'AKISMET__MINIMUM_WP_VERSION', '4.0' ); define( 'AKISMET__PLUGIN_DIR', plugin_dir_path( __FILE__ ) ); define( 'AKISMET_DELETE_LIMIT', 100000 ); @@ -63,4 +63,4 @@ require_once( AKISMET__PLUGIN_DIR . 'wrapper.php' ); if ( defined( 'WP_CLI' ) && WP_CLI ) { require_once( AKISMET__PLUGIN_DIR . 'class.akismet-cli.php' ); -}
\ No newline at end of file +} diff --git a/plugins/akismet/class.akismet.php b/plugins/akismet/class.akismet.php index 867430fc..0ed53fce 100644 --- a/plugins/akismet/class.akismet.php +++ b/plugins/akismet/class.akismet.php @@ -30,6 +30,7 @@ class Akismet { add_action( 'akismet_scheduled_delete', array( 'Akismet', 'delete_old_comments' ) ); add_action( 'akismet_scheduled_delete', array( 'Akismet', 'delete_old_comments_meta' ) ); + add_action( 'akismet_scheduled_delete', array( 'Akismet', 'delete_orphaned_commentmeta' ) ); add_action( 'akismet_schedule_cron_recheck', array( 'Akismet', 'cron_recheck' ) ); add_action( 'comment_form', array( 'Akismet', 'add_comment_nonce' ), 1 ); @@ -348,6 +349,7 @@ class Akismet { foreach ( $comment_ids as $comment_id ) { do_action( 'delete_comment', $comment_id ); + do_action( 'akismet_batch_delete_count', __FUNCTION__ ); } // 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 { $interval = apply_filters( 'akismet_delete_commentmeta_interval', 15 ); - # enfore a minimum of 1 day + # enforce a minimum of 1 day $interval = absint( $interval ); if ( $interval < 1 ) $interval = 1; @@ -384,6 +386,7 @@ class Akismet { foreach ( $comment_ids as $comment_id ) { delete_comment_meta( $comment_id, 'akismet_as_submitted' ); + do_action( 'akismet_batch_delete_count', __FUNCTION__ ); } do_action( 'akismet_delete_commentmeta_batch', count( $comment_ids ) ); @@ -393,6 +396,43 @@ class Akismet { $wpdb->query("OPTIMIZE TABLE {$wpdb->commentmeta}"); } + // Clear out comments meta that no longer have corresponding comments in the database + 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}"); + } + // how many approved comments does this author have? public static function get_user_comments_approved( $user_id, $comment_author_email, $comment_author, $comment_author_url ) { global $wpdb; diff --git a/plugins/akismet/readme.txt b/plugins/akismet/readme.txt index 40ca6aef..c892430d 100644 --- a/plugins/akismet/readme.txt +++ b/plugins/akismet/readme.txt @@ -1,9 +1,9 @@ === Akismet Anti-Spam === -Contributors: matt, ryan, andy, mdawaffe, tellyworth, josephscott, lessbloat, eoigal, cfinke, automattic, jgs, procifer +Contributors: matt, ryan, andy, mdawaffe, tellyworth, josephscott, lessbloat, eoigal, cfinke, automattic, jgs, procifer, stephdau Tags: akismet, comments, spam, antispam, anti-spam, anti spam, comment moderation, comment spam, contact form spam, spam comments Requires at least: 4.0 Tested up to: 4.9.1 -Stable tag: 4.0.2 +Stable tag: 4.0.3 License: GPLv2 or later 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 == Changelog == += 4.0.3 = +*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_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. + = 4.0.2 = *Release Date - 18 December 2017* |