diff --git a/tools/maintenance.php b/tools/maintenance.php index a869e2fa..7f3c248b 100644 --- a/tools/maintenance.php +++ b/tools/maintenance.php @@ -3,8 +3,12 @@ * Performs maintenance tasks. Invoke this periodically if the auto_maintenance configuration option is turned off. */ +use Vichan\Data\ReportQueries; + require dirname(__FILE__) . '/inc/cli.php'; +$ctx = Vichan\build_context($config); + echo "Clearing expired bans...\n"; $start = microtime(true); $deleted_count = Bans::purge($config['require_ban_view'], $config['purge_bans']); @@ -19,7 +23,16 @@ $deleted_count = purge_old_antispam(); $delta = microtime(true) - $start; echo "Deleted $deleted_count expired antispam in $delta seconds!\n"; $time_tot = $delta; -$deleted_tot = $deleted_count; +$deleted_tot += $deleted_count; + +echo "Clearing invalid reports...\n"; +$report_queries = $ctx->get(ReportQueries::class); +$start = microtime(true); +$deleted_count = $report_queries->purge(); +$delta = microtime(true) - $start; +echo "Deleted $deleted_count invalid reports in $delta seconds!\n"; +$time_tot += $delta; +$deleted_tot += $deleted_count; if ($config['cache']['enabled'] === 'fs') { $fs_cache = new Vichan\Data\Driver\FsCacheDriver(