Conditions | 2 |
Paths | 2 |
Total Lines | 24 |
Lines | 0 |
Ratio | 0 % |
Changes | 0 |
1 | <?php |
||
39 | public function run($request): void // phpcs:ignore SlevomatCodingStandard.TypeHints |
||
40 | { |
||
41 | if (QueuedJobService::singleton()->isMaintenanceLockActive()) { |
||
42 | return; |
||
43 | } |
||
44 | |||
45 | $table = QueuedJobDescriptor::config()->get('table_name'); |
||
46 | |||
47 | // determine expiry |
||
48 | $expired = DBDatetime::now()->modify(sprintf('-%s hours', self::EXPIRY_HOURS))->Rfc2822(); |
||
49 | |||
50 | // Format query |
||
51 | $query = sprintf( |
||
52 | "DELETE FROM `%s` WHERE `JobStatus` = '%s' AND (`JobFinished` <= '%s' OR `JobFinished` IS NULL) LIMIT %d", |
||
53 | $table, |
||
54 | QueuedJob::STATUS_COMPLETE, |
||
55 | $expired, |
||
56 | self::EXPIRY_LIMIT |
||
57 | ); |
||
58 | |||
59 | DB::query($query); |
||
60 | |||
61 | echo sprintf('%d job descriptors deleted.', (int) DB::affected_rows()); |
||
62 | } |
||
63 | } |
||
64 |