Debian Codegraph @

includes/watchlist/WatchlistExpiryJob.php

raw symbols SCIP
1 <?php
2
3 namespace MediaWiki\Watchlist;
4
5 use Job;
6 use MediaWiki\MediaWikiServices;
7
8 /**
9 * @internal For use by WatchedItemStore
10 * @ingroup JobQueue
11 */
12 class 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 */
36 class_alias( WatchlistExpiryJob::class, 'WatchlistExpiryJob' );