Code Coverage |
||||||||||
Lines |
Functions and Methods |
Classes and Traits |
||||||||
Total | |
0.00% |
0 / 6 |
|
0.00% |
0 / 4 |
CRAP | |
0.00% |
0 / 1 |
queue | |
0.00% |
0 / 6 |
|
0.00% |
0 / 4 |
20 | |
0.00% |
0 / 1 |
__construct | |
0.00% |
0 / 3 |
|
0.00% |
0 / 1 |
2 | |||
run | |
0.00% |
0 / 1 |
|
0.00% |
0 / 1 |
2 | |||
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 | use phpbb\config\config; |
17 | |
18 | /** |
19 | * Queue cron task. Sends email and jabber messages queued by other scripts. |
20 | */ |
21 | class queue extends \phpbb\cron\task\base |
22 | { |
23 | /** var config */ |
24 | protected $config; |
25 | |
26 | /** var \phpbb\messenger\queue */ |
27 | protected $queue; |
28 | |
29 | /** var string */ |
30 | protected $queue_cache_file; |
31 | |
32 | /** |
33 | * Constructor. |
34 | * |
35 | * @param config $config The config |
36 | * @param string $queue_cache_file The messenger file queue cache filename |
37 | * @param \phpbb\messenger\queue $queue The messenger file queue object |
38 | */ |
39 | public function __construct(config $config, \phpbb\messenger\queue $queue, $queue_cache_file) |
40 | { |
41 | $this->config = $config; |
42 | $this->queue = $queue; |
43 | $this->queue_cache_file = $queue_cache_file; |
44 | } |
45 | |
46 | /** |
47 | * Runs this cron task. |
48 | * |
49 | * @return void |
50 | */ |
51 | public function run() |
52 | { |
53 | $this->queue->process(); |
54 | } |
55 | |
56 | /** |
57 | * Returns whether this cron task can run, given current board configuration. |
58 | * |
59 | * Queue task is only run if the email queue (file) exists. |
60 | * |
61 | * @return bool |
62 | */ |
63 | public function is_runnable() |
64 | { |
65 | return file_exists($this->queue_cache_file); |
66 | } |
67 | |
68 | /** |
69 | * Returns whether this cron task should run now, because enough time |
70 | * has passed since it was last run. |
71 | * |
72 | * The interval between queue runs is specified in board configuration. |
73 | * |
74 | * @return bool |
75 | */ |
76 | public function should_run() |
77 | { |
78 | return $this->config['last_queue_run'] < time() - $this->config['queue_interval']; |
79 | } |
80 | } |