bans.php: refactor to expose the moratorium on ban deletion from the database.

Also fixes the 'purge_bans' configuration for non-cache deployments.
This commit is contained in:
Zankaria
2024-07-11 22:48:19 +02:00
committed by Zankaria
parent c057c6df29
commit ede7591702
4 changed files with 8 additions and 8 deletions

View File

@@ -341,12 +341,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));