Ticket #3395: 3395.3.diff
File 3395.3.diff, 3.7 KB (added by , 3 years ago) |
---|
-
src/includes/extend/akismet.php
985 985 $delete_limit = (int) apply_filters( '_bbp_akismet_delete_spam_limit', 986 986 defined( 'AKISMET_DELETE_LIMIT' ) 987 987 ? AKISMET_DELETE_LIMIT 988 : 1000 0988 : 1000 989 989 ); 990 990 991 991 // Validate the deletion limit … … 1037 1037 $format_string = implode( ", ", array_fill( 0, count( $spam_ids ), '%s' ) ); 1038 1038 1039 1039 // Run the delete queries 1040 $wpdb->query( $wpdb->prepare( "DELETE FROM {$wpdb->posts} WHERE post_idIN ( " . $format_string . " )", $spam_ids ) );1040 $wpdb->query( $wpdb->prepare( "DELETE FROM {$wpdb->posts} WHERE ID IN ( " . $format_string . " )", $spam_ids ) ); 1041 1041 $wpdb->query( $wpdb->prepare( "DELETE FROM {$wpdb->postmeta} WHERE post_id IN ( " . $format_string . " )", $spam_ids ) ); 1042 1042 1043 1043 // Clean the post cache for these topics & replies … … 1079 1079 global $wpdb; 1080 1080 1081 1081 /** 1082 * Determines how many posts will be deleted in each batch. 1083 * 1084 * @param int The default as defined by AKISMET_DELETE_LIMIT (also used 1085 * in Akismet WordPress plugin). 1086 */ 1087 $delete_limit = (int) apply_filters( '_bbp_akismet_delete_spam_limit', 1088 defined( 'AKISMET_DELETE_LIMIT' ) 1089 ? AKISMET_DELETE_LIMIT 1090 : 1000 1091 ); 1092 1093 // Validate the deletion limit 1094 $delete_limit = max( 1, intval( $delete_limit ) ); 1095 1096 /** 1082 1097 * Determines how many days a piece of spam will be left in the Spam 1083 1098 * queue before being deleted. 1084 1099 * … … 1090 1105 $interval = max( 1, intval( $interval ) ); 1091 1106 1092 1107 // 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. id WHERE m.meta_key = '_bbp_akismet_as_submitted' AND DATE_SUB(NOW(), INTERVAL %d DAY) > p.post_date_gmt LIMIT 10000";1108 $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"; 1094 1109 1095 1110 // Query loop of topic & reply IDs 1096 while ( $spam_ids = $wpdb->get_col( $wpdb->prepare( $sql, $interval ) ) ) {1111 while ( $spam_ids = $wpdb->get_col( $wpdb->prepare( $sql, $interval, $delete_limit ) ) ) { 1097 1112 1098 1113 // Exit loop if no spam IDs 1099 1114 if ( empty( $spam_ids ) ) { … … 1143 1158 public function delete_orphaned_spam_meta() { 1144 1159 global $wpdb; 1145 1160 1161 /** 1162 * Determines how many posts will be deleted in each batch. 1163 * 1164 * @param int The default as defined by AKISMET_DELETE_LIMIT (also used 1165 * in Akismet WordPress plugin). 1166 */ 1167 $delete_limit = (int) apply_filters( '_bbp_akismet_delete_spam_limit', 1168 defined( 'AKISMET_DELETE_LIMIT' ) 1169 ? AKISMET_DELETE_LIMIT 1170 : 1000 1171 ); 1172 1173 // Validate the deletion limit 1174 $delete_limit = max( 1, intval( $delete_limit ) ); 1175 1146 1176 $last_meta_id = 0; 1147 1177 1148 1178 // Start time (float) … … 1154 1184 $max_exec_time = (float) max( ini_get( 'max_execution_time' ) - 5, 3 ); 1155 1185 1156 1186 // 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. id WHERE p.id IS NULL AND m.meta_id > %d ORDER BY m.meta_id LIMIT 1000";1187 $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"; 1158 1188 1159 1189 // Query loop of topic & reply IDs 1160 while ( $spam_meta_results = $wpdb->get_results( $wpdb->prepare( $sql, $last_meta_id ) ) ) {1190 while ( $spam_meta_results = $wpdb->get_results( $wpdb->prepare( $sql, $last_meta_id, $delete_limit ) ) ) { 1161 1191 1162 1192 // Exit loop if no spam IDs 1163 1193 if ( empty( $spam_meta_results ) ) {