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
parent 4b03672f77
commit d69eebb1d3
4 changed files with 8 additions and 8 deletions

View file

@ -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));