Code Coverage |
||||||||||
Lines |
Functions and Methods |
Classes and Traits |
||||||||
Total | |
0.00% |
0 / 8 |
|
0.00% |
0 / 4 |
CRAP | |
0.00% |
0 / 1 |
tidy_warnings | |
0.00% |
0 / 8 |
|
0.00% |
0 / 4 |
30 | |
0.00% |
0 / 1 |
__construct | |
0.00% |
0 / 3 |
|
0.00% |
0 / 1 |
2 | |||
run | |
0.00% |
0 / 3 |
|
0.00% |
0 / 1 |
6 | |||
is_runnable | |
0.00% |
0 / 1 |
|
0.00% |
0 / 1 |
2 | |||
should_run | |
0.00% |
0 / 1 |
|
0.00% |
0 / 1 |
2 |
1 | <?php |
2 | /** |
3 | * |
4 | * This file is part of the phpBB Forum Software package. |
5 | * |
6 | * @copyright (c) phpBB Limited <https://www.phpbb.com> |
7 | * @license GNU General Public License, version 2 (GPL-2.0) |
8 | * |
9 | * For full copyright and license information, please see |
10 | * the docs/CREDITS.txt file. |
11 | * |
12 | */ |
13 | |
14 | namespace phpbb\cron\task\core; |
15 | |
16 | /** |
17 | * Tidy warnings cron task. |
18 | * |
19 | * Will only run when warnings are configured to expire. |
20 | */ |
21 | class tidy_warnings extends \phpbb\cron\task\base |
22 | { |
23 | protected $phpbb_root_path; |
24 | protected $php_ext; |
25 | protected $config; |
26 | |
27 | /** |
28 | * Constructor. |
29 | * |
30 | * @param string $phpbb_root_path The root path |
31 | * @param string $php_ext PHP file extension |
32 | * @param \phpbb\config\config $config The config |
33 | */ |
34 | public function __construct($phpbb_root_path, $php_ext, \phpbb\config\config $config) |
35 | { |
36 | $this->phpbb_root_path = $phpbb_root_path; |
37 | $this->php_ext = $php_ext; |
38 | $this->config = $config; |
39 | } |
40 | |
41 | /** |
42 | * Runs this cron task. |
43 | * |
44 | * @return void |
45 | */ |
46 | public function run() |
47 | { |
48 | if (!function_exists('tidy_warnings')) |
49 | { |
50 | include($this->phpbb_root_path . 'includes/functions_admin.' . $this->php_ext); |
51 | } |
52 | tidy_warnings(); |
53 | } |
54 | |
55 | /** |
56 | * Returns whether this cron task can run, given current board configuration. |
57 | * |
58 | * If warnings are set to never expire, this cron task will not run. |
59 | * |
60 | * @return bool |
61 | */ |
62 | public function is_runnable() |
63 | { |
64 | return (bool) $this->config['warnings_expire_days']; |
65 | } |
66 | |
67 | /** |
68 | * Returns whether this cron task should run now, because enough time |
69 | * has passed since it was last run. |
70 | * |
71 | * The interval between warnings tidying is specified in board |
72 | * configuration. |
73 | * |
74 | * @return bool |
75 | */ |
76 | public function should_run() |
77 | { |
78 | return $this->config['warnings_last_gc'] < time() - $this->config['warnings_gc']; |
79 | } |
80 | } |