Version Description
Download this release
Release Info
Developer | johnjamesjacoby |
Plugin | bbPress |
Version | 2.6.9 |
Comparing to | |
See all releases |
Code changes from version 2.6.8 to 2.6.9
- bbpress.php +3 -3
- includes/extend/akismet.php +72 -40
- readme.txt +1 -1
bbpress.php
CHANGED
@@ -5,7 +5,7 @@
|
|
5 |
*
|
6 |
* bbPress is forum software with a twist from the creators of WordPress.
|
7 |
*
|
8 |
-
* $Id: bbpress.php
|
9 |
*
|
10 |
* @package bbPress
|
11 |
* @subpackage Main
|
@@ -17,7 +17,7 @@
|
|
17 |
* Description: bbPress is forum software with a twist from the creators of WordPress.
|
18 |
* Author: The bbPress Contributors
|
19 |
* Author URI: https://bbpress.org
|
20 |
-
* Version: 2.6.
|
21 |
* Text Domain: bbpress
|
22 |
* Domain Path: /languages/
|
23 |
* License: GPLv2 or later (license.txt)
|
@@ -205,7 +205,7 @@ final class bbPress {
|
|
205 |
|
206 |
/** Versions **********************************************************/
|
207 |
|
208 |
-
$this->version = '2.6.
|
209 |
$this->db_version = '263';
|
210 |
|
211 |
/** Paths *************************************************************/
|
5 |
*
|
6 |
* bbPress is forum software with a twist from the creators of WordPress.
|
7 |
*
|
8 |
+
* $Id: bbpress.php 7228 2021-11-29 15:22:27Z johnjamesjacoby $
|
9 |
*
|
10 |
* @package bbPress
|
11 |
* @subpackage Main
|
17 |
* Description: bbPress is forum software with a twist from the creators of WordPress.
|
18 |
* Author: The bbPress Contributors
|
19 |
* Author URI: https://bbpress.org
|
20 |
+
* Version: 2.6.9
|
21 |
* Text Domain: bbpress
|
22 |
* Domain Path: /languages/
|
23 |
* License: GPLv2 or later (license.txt)
|
205 |
|
206 |
/** Versions **********************************************************/
|
207 |
|
208 |
+
$this->version = '2.6.9';
|
209 |
$this->db_version = '263';
|
210 |
|
211 |
/** Paths *************************************************************/
|
includes/extend/akismet.php
CHANGED
@@ -966,41 +966,73 @@ class BBP_Akismet {
|
|
966 |
}
|
967 |
|
968 |
/**
|
969 |
-
*
|
970 |
-
* (determined by `_bbp_akismet_delete_spam_interval` filter).
|
971 |
*
|
972 |
-
* @since 2.6.
|
973 |
*
|
974 |
-
* @
|
|
|
975 |
*/
|
976 |
-
public function
|
977 |
-
|
|
|
|
|
|
|
|
|
978 |
|
979 |
/**
|
980 |
-
* Determines how many
|
981 |
*
|
982 |
-
* @param int The
|
983 |
-
* in Akismet WordPress plugin).
|
984 |
*/
|
985 |
-
$delete_limit = (int) apply_filters(
|
986 |
-
|
987 |
-
|
988 |
-
|
989 |
-
|
990 |
|
991 |
-
|
992 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
993 |
|
994 |
/**
|
995 |
* Determines how many days a piece of spam will be left in the Spam
|
996 |
* queue before being deleted.
|
997 |
*
|
998 |
-
* @param int The
|
999 |
*/
|
1000 |
-
$delete_interval = (int) apply_filters(
|
|
|
|
|
|
|
|
|
1001 |
|
1002 |
-
|
1003 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1004 |
|
1005 |
// Setup the query
|
1006 |
$sql = "SELECT id FROM {$wpdb->posts} WHERE post_type IN ('topic', 'reply') AND post_status = 'spam' AND DATE_SUB(NOW(), INTERVAL %d DAY) > post_date_gmt LIMIT %d";
|
@@ -1034,11 +1066,11 @@ class BBP_Akismet {
|
|
1034 |
|
1035 |
// Prepared as strings since id is an unsigned BIGINT, and using %
|
1036 |
// will constrain the value to the maximum signed BIGINT.
|
1037 |
-
$format_string = implode(
|
1038 |
|
1039 |
// Run the delete queries
|
1040 |
-
$wpdb->query( $wpdb->prepare( "DELETE FROM {$wpdb->posts} WHERE
|
1041 |
-
$wpdb->query( $wpdb->prepare( "DELETE FROM {$wpdb->postmeta} WHERE post_id IN (
|
1042 |
|
1043 |
// Clean the post cache for these topics & replies
|
1044 |
clean_post_cache( $spam_ids );
|
@@ -1068,8 +1100,9 @@ class BBP_Akismet {
|
|
1068 |
}
|
1069 |
|
1070 |
/**
|
1071 |
-
* Deletes `_bbp_akismet_as_submitted` meta keys after 15 days
|
1072 |
-
*
|
|
|
1073 |
*
|
1074 |
* @since 2.6.7 bbPress (r7203)
|
1075 |
*
|
@@ -1078,22 +1111,15 @@ class BBP_Akismet {
|
|
1078 |
public function delete_old_spam_meta() {
|
1079 |
global $wpdb;
|
1080 |
|
1081 |
-
|
1082 |
-
|
1083 |
-
|
1084 |
-
*
|
1085 |
-
* @param int The default number of days.
|
1086 |
-
*/
|
1087 |
-
$interval = (int) apply_filters( '_bbp_akismet_delete_spam_meta_interval', 15 );
|
1088 |
-
|
1089 |
-
// Validate the deletion interval
|
1090 |
-
$interval = max( 1, intval( $interval ) );
|
1091 |
|
1092 |
// Setup the query
|
1093 |
-
$sql = "SELECT m.post_id FROM {$wpdb->postmeta} as m INNER JOIN {$wpdb->posts} as p ON m.post_id = p.
|
1094 |
|
1095 |
// Query loop of topic & reply IDs
|
1096 |
-
while ( $spam_ids = $wpdb->get_col( $wpdb->prepare( $sql, $
|
1097 |
|
1098 |
// Exit loop if no spam IDs
|
1099 |
if ( empty( $spam_ids ) ) {
|
@@ -1134,7 +1160,9 @@ class BBP_Akismet {
|
|
1134 |
}
|
1135 |
|
1136 |
/**
|
1137 |
-
* Clears post meta that no longer has corresponding posts in the database
|
|
|
|
|
1138 |
*
|
1139 |
* @since 2.6.7 bbPress (r7203)
|
1140 |
*
|
@@ -1143,6 +1171,10 @@ class BBP_Akismet {
|
|
1143 |
public function delete_orphaned_spam_meta() {
|
1144 |
global $wpdb;
|
1145 |
|
|
|
|
|
|
|
|
|
1146 |
$last_meta_id = 0;
|
1147 |
|
1148 |
// Start time (float)
|
@@ -1154,10 +1186,10 @@ class BBP_Akismet {
|
|
1154 |
$max_exec_time = (float) max( ini_get( 'max_execution_time' ) - 5, 3 );
|
1155 |
|
1156 |
// Setup the query
|
1157 |
-
$sql = "SELECT m.meta_id, m.post_id, m.meta_key FROM {$wpdb->postmeta} as m LEFT JOIN {$wpdb->posts} as p ON m.post_id = p.
|
1158 |
|
1159 |
// Query loop of topic & reply IDs
|
1160 |
-
while ( $spam_meta_results = $wpdb->get_results( $wpdb->prepare( $sql, $last_meta_id ) ) ) {
|
1161 |
|
1162 |
// Exit loop if no spam IDs
|
1163 |
if ( empty( $spam_meta_results ) ) {
|
966 |
}
|
967 |
|
968 |
/**
|
969 |
+
* Get the number of rows to delete in a single clean-up query.
|
|
|
970 |
*
|
971 |
+
* @since 2.6.9 bbPress (r7225)
|
972 |
*
|
973 |
+
* @param string $filter The name of the filter to run.
|
974 |
+
* @return int
|
975 |
*/
|
976 |
+
public function get_delete_limit( $filter = '' ) {
|
977 |
+
|
978 |
+
// Default filter
|
979 |
+
if ( empty( $filter ) ) {
|
980 |
+
$filter = '_bbp_akismet_delete_spam_limit';
|
981 |
+
}
|
982 |
|
983 |
/**
|
984 |
+
* Determines how many rows will be deleted in each batch.
|
985 |
*
|
986 |
+
* @param int The number of rows. Default 1000.
|
|
|
987 |
*/
|
988 |
+
$delete_limit = (int) apply_filters( $filter, 1000 );
|
989 |
+
|
990 |
+
// Validate and return the deletion limit
|
991 |
+
return max( 1, $delete_limit );
|
992 |
+
}
|
993 |
|
994 |
+
/**
|
995 |
+
* Get the interval (in days) for spam to remain in the queue.
|
996 |
+
*
|
997 |
+
* @since 2.6.9 bbPress (r7225)
|
998 |
+
*
|
999 |
+
* @param string $filter The name of the filter to run.
|
1000 |
+
* @return int
|
1001 |
+
*/
|
1002 |
+
public function get_delete_interval( $filter = '' ) {
|
1003 |
+
|
1004 |
+
// Default filter
|
1005 |
+
if ( empty( $filter ) ) {
|
1006 |
+
$filter = '_bbp_akismet_delete_spam_interval';
|
1007 |
+
}
|
1008 |
|
1009 |
/**
|
1010 |
* Determines how many days a piece of spam will be left in the Spam
|
1011 |
* queue before being deleted.
|
1012 |
*
|
1013 |
+
* @param int The number of days. Default 15.
|
1014 |
*/
|
1015 |
+
$delete_interval = (int) apply_filters( $filter, 15 );
|
1016 |
+
|
1017 |
+
// Validate and return the deletion interval
|
1018 |
+
return max( 1, $delete_interval );
|
1019 |
+
}
|
1020 |
|
1021 |
+
/**
|
1022 |
+
* Deletes old spam topics & replies from the queue after 15 days
|
1023 |
+
* (determined by `_bbp_akismet_delete_spam_interval` filter)
|
1024 |
+
* since they are not useful in the long term.
|
1025 |
+
*
|
1026 |
+
* @since 2.6.7 bbPress (r7203)
|
1027 |
+
*
|
1028 |
+
* @global wpdb $wpdb
|
1029 |
+
*/
|
1030 |
+
public function delete_old_spam() {
|
1031 |
+
global $wpdb;
|
1032 |
+
|
1033 |
+
// Get the deletion limit & interval
|
1034 |
+
$delete_limit = $this->get_delete_limit( '_bbp_akismet_delete_spam_limit' );
|
1035 |
+
$delete_interval = $this->get_delete_interval( '_bbp_akismet_delete_spam_interval' );
|
1036 |
|
1037 |
// Setup the query
|
1038 |
$sql = "SELECT id FROM {$wpdb->posts} WHERE post_type IN ('topic', 'reply') AND post_status = 'spam' AND DATE_SUB(NOW(), INTERVAL %d DAY) > post_date_gmt LIMIT %d";
|
1066 |
|
1067 |
// Prepared as strings since id is an unsigned BIGINT, and using %
|
1068 |
// will constrain the value to the maximum signed BIGINT.
|
1069 |
+
$format_string = implode( ', ', array_fill( 0, count( $spam_ids ), '%s' ) );
|
1070 |
|
1071 |
// Run the delete queries
|
1072 |
+
$wpdb->query( $wpdb->prepare( "DELETE FROM {$wpdb->posts} WHERE ID IN ( {$format_string} )", $spam_ids ) );
|
1073 |
+
$wpdb->query( $wpdb->prepare( "DELETE FROM {$wpdb->postmeta} WHERE post_id IN ( {$format_string} )", $spam_ids ) );
|
1074 |
|
1075 |
// Clean the post cache for these topics & replies
|
1076 |
clean_post_cache( $spam_ids );
|
1100 |
}
|
1101 |
|
1102 |
/**
|
1103 |
+
* Deletes `_bbp_akismet_as_submitted` meta keys after 15 days
|
1104 |
+
* (determined by `_bbp_akismet_delete_spam_meta_interval` filter)
|
1105 |
+
* since they are large and not useful in the long term.
|
1106 |
*
|
1107 |
* @since 2.6.7 bbPress (r7203)
|
1108 |
*
|
1111 |
public function delete_old_spam_meta() {
|
1112 |
global $wpdb;
|
1113 |
|
1114 |
+
// Get the deletion limit & interval
|
1115 |
+
$delete_limit = $this->get_delete_limit( '_bbp_akismet_delete_spam_meta_limit' );
|
1116 |
+
$delete_interval = $this->get_delete_interval( '_bbp_akismet_delete_spam_meta_interval' );
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1117 |
|
1118 |
// Setup the query
|
1119 |
+
$sql = "SELECT m.post_id FROM {$wpdb->postmeta} as m INNER JOIN {$wpdb->posts} as p ON m.post_id = p.ID WHERE m.meta_key = '_bbp_akismet_as_submitted' AND DATE_SUB(NOW(), INTERVAL %d DAY) > p.post_date_gmt LIMIT %d";
|
1120 |
|
1121 |
// Query loop of topic & reply IDs
|
1122 |
+
while ( $spam_ids = $wpdb->get_col( $wpdb->prepare( $sql, $delete_interval, $delete_limit ) ) ) {
|
1123 |
|
1124 |
// Exit loop if no spam IDs
|
1125 |
if ( empty( $spam_ids ) ) {
|
1160 |
}
|
1161 |
|
1162 |
/**
|
1163 |
+
* Clears post meta that no longer has corresponding posts in the database
|
1164 |
+
* (determined by `_bbp_akismet_delete_spam_orphaned_limit` filter)
|
1165 |
+
* since it is not useful in the long term.
|
1166 |
*
|
1167 |
* @since 2.6.7 bbPress (r7203)
|
1168 |
*
|
1171 |
public function delete_orphaned_spam_meta() {
|
1172 |
global $wpdb;
|
1173 |
|
1174 |
+
// Get the deletion limit
|
1175 |
+
$delete_limit = $this->get_delete_limit( '_bbp_akismet_delete_spam_orphaned_limit' );
|
1176 |
+
|
1177 |
+
// Default last meta ID
|
1178 |
$last_meta_id = 0;
|
1179 |
|
1180 |
// Start time (float)
|
1186 |
$max_exec_time = (float) max( ini_get( 'max_execution_time' ) - 5, 3 );
|
1187 |
|
1188 |
// Setup the query
|
1189 |
+
$sql = "SELECT m.meta_id, m.post_id, m.meta_key FROM {$wpdb->postmeta} as m LEFT JOIN {$wpdb->posts} as p ON m.post_id = p.ID WHERE p.ID IS NULL AND m.meta_id > %d ORDER BY m.meta_id LIMIT %d";
|
1190 |
|
1191 |
// Query loop of topic & reply IDs
|
1192 |
+
while ( $spam_meta_results = $wpdb->get_results( $wpdb->prepare( $sql, $last_meta_id, $delete_limit ) ) ) {
|
1193 |
|
1194 |
// Exit loop if no spam IDs
|
1195 |
if ( empty( $spam_meta_results ) ) {
|
readme.txt
CHANGED
@@ -2,7 +2,7 @@
|
|
2 |
Contributors: matt, johnjamesjacoby, jmdodd, netweb, sergeybiryukov
|
3 |
Tags: forum, forums, discussion, support
|
4 |
Tested up to: 5.9
|
5 |
-
Stable tag: 2.6.
|
6 |
License: GPLv2 or later
|
7 |
License URI: https://www.gnu.org/licenses/gpl-2.0.html
|
8 |
Requires PHP: 5.6.20
|
2 |
Contributors: matt, johnjamesjacoby, jmdodd, netweb, sergeybiryukov
|
3 |
Tags: forum, forums, discussion, support
|
4 |
Tested up to: 5.9
|
5 |
+
Stable tag: 2.6.9
|
6 |
License: GPLv2 or later
|
7 |
License URI: https://www.gnu.org/licenses/gpl-2.0.html
|
8 |
Requires PHP: 5.6.20
|