Code Coverage |
||||||||||
Lines |
Functions and Methods |
Classes and Traits |
||||||||
Total | |
0.00% |
0 / 7 |
|
0.00% |
0 / 2 |
CRAP | |
0.00% |
0 / 1 |
WatchlistExpiryJob | |
0.00% |
0 / 7 |
|
0.00% |
0 / 2 |
12 | |
0.00% |
0 / 1 |
__construct | |
0.00% |
0 / 1 |
|
0.00% |
0 / 1 |
2 | |||
run | |
0.00% |
0 / 6 |
|
0.00% |
0 / 1 |
6 |
1 | <?php |
2 | |
3 | use MediaWiki\MediaWikiServices; |
4 | |
5 | /** |
6 | * @internal For use by WatchedItemStore |
7 | * @ingroup JobQueue |
8 | */ |
9 | class WatchlistExpiryJob extends Job { |
10 | |
11 | public function __construct( string $command = 'watchlistExpiry', array $params = [] ) { |
12 | parent::__construct( $command, $params ); |
13 | } |
14 | |
15 | /** |
16 | * Run the job recursively in batches of 100 until there are no more expired items. |
17 | * |
18 | * @return bool Always true, to indicate success. |
19 | */ |
20 | public function run() { |
21 | $services = MediaWikiServices::getInstance(); |
22 | $watchedItemStore = $services->getWatchedItemStore(); |
23 | $watchedItemStore->removeExpired( 100 ); |
24 | if ( $watchedItemStore->countExpired() ) { |
25 | // If there are still items, add a new job. |
26 | $services->getJobQueueGroup()->push( new static() ); |
27 | } |
28 | return true; |
29 | } |
30 | |
31 | } |