diff --git a/inc/bans.php b/inc/bans.php index 313b3b50..975bf462 100644 --- a/inc/bans.php +++ b/inc/bans.php @@ -349,12 +349,13 @@ class Bans { rebuildThemes('bans'); } - static public function purge($require_seen) { + static public function purge($require_seen, $moratorium) { if ($require_seen) { - $query = prepare("DELETE FROM ``bans`` WHERE `expires` IS NOT NULL AND `expires` < :curr_time AND `seen` = 1"); + $query = prepare("DELETE FROM ``bans`` WHERE `expires` IS NOT NULL AND `expires` + :moratorium < :curr_time AND `seen` = 1"); } else { - $query = prepare("DELETE FROM ``bans`` WHERE `expires` IS NOT NULL AND `expires` < :curr_time"); + $query = prepare("DELETE FROM ``bans`` WHERE `expires` IS NOT NULL AND `expires` + :moratorium < :curr_time"); } + $query->bindValue(':moratorium', $moratorium); $query->bindValue(':curr_time', time()); $query->execute() or error(db_error($query)); diff --git a/inc/config.php b/inc/config.php index 5e96d097..f2604e70 100644 --- a/inc/config.php +++ b/inc/config.php @@ -1457,8 +1457,7 @@ // Enable the moving of single replies $config['move_replies'] = false; - // How often (minimum) to purge the ban list of expired bans (which have been seen). Only works when - // $config['cache'] is enabled and working. + // How often (minimum) to purge the ban list of expired bans (which have been seen). $config['purge_bans'] = 60 * 60 * 12; // 12 hours // Do DNS lookups on IP addresses to get their hostname for the moderator IP pages (?/IP/x.x.x.x). diff --git a/inc/functions.php b/inc/functions.php index ba17441c..644cefbe 100644 --- a/inc/functions.php +++ b/inc/functions.php @@ -908,12 +908,12 @@ function checkBan($board = false) { if ($config['cache']['enabled']) { $last_time_purged = cache::get('purged_bans_last'); if ($last_time_purged !== false && time() - $last_time_purged > $config['purge_bans']) { - Bans::purge($config['require_ban_view']); + Bans::purge($config['require_ban_view'], $config['purge_bans']); cache::set('purged_bans_last', time()); } } else { // Purge every time. - Bans::purge($config['require_ban_view']); + Bans::purge($config['require_ban_view'], $config['purge_bans']); } } } diff --git a/tools/maintenance.php b/tools/maintenance.php index cdc1089d..3db3ea98 100644 --- a/tools/maintenance.php +++ b/tools/maintenance.php @@ -7,7 +7,7 @@ require dirname(__FILE__) . '/inc/cli.php'; echo "Clearing expired bans..."; $start = microtime(true); -$deleted_count = Bans::purge($config['require_ban_view']); +$deleted_count = Bans::purge($config['require_ban_view'], $config['purge_bans']); $delta = microtime(true) - $start; echo "Deleted $deleted_count expired bans in $delta seconds!"; modLog("Deleted expired bans in {$delta}s with tools/maintenance.php");