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