MediaWiki master
WatchlistExpiryJob.php
Go to the documentation of this file.
1<?php
2
3namespace MediaWiki\Watchlist;
4
5use Job;
7
12class WatchlistExpiryJob extends Job {
13
14 public function __construct( string $command = 'watchlistExpiry', array $params = [] ) {
15 parent::__construct( $command, $params );
16 }
17
23 public function run() {
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}
36class_alias( WatchlistExpiryJob::class, 'WatchlistExpiryJob' );
Describe and execute a background job.
Definition Job.php:41
string $command
Definition Job.php:43
array $params
Array of job parameters.
Definition Job.php:46
Service locator for MediaWiki core services.
static getInstance()
Returns the global default instance of the top level service locator.
__construct(string $command='watchlistExpiry', array $params=[])
run()
Run the job recursively in batches of 100 until there are no more expired items.