MediaWiki  master
WatchlistExpiryJob.php
Go to the documentation of this file.
1 <?php
2 
4 
5 class WatchlistExpiryJob extends Job {
6 
7  public function __construct( string $command = 'watchlistExpiry', array $params = [] ) {
8  parent::__construct( $command, $params );
9  }
10 
16  public function run() {
17  $watchedItemStore = MediaWikiServices::getInstance()->getWatchedItemStore();
18  $watchedItemStore->removeExpired( 100 );
19  if ( $watchedItemStore->countExpired() ) {
20  // If there are still items, add a new job.
21  JobQueueGroup::singleton()->push( new static() );
22  }
23  return true;
24  }
25 
26 }
WatchlistExpiryJob\run
run()
Run the job recursively in batches of 100 until there are no more expired items.
Definition: WatchlistExpiryJob.php:16
MediaWiki\MediaWikiServices
MediaWikiServices is the service locator for the application scope of MediaWiki.
Definition: MediaWikiServices.php:163
Job\$params
array $params
Array of job parameters.
Definition: Job.php:37
Job
Class to both describe a background job and handle jobs.
Definition: Job.php:32
Job\$command
string $command
Definition: Job.php:34
WatchlistExpiryJob\__construct
__construct(string $command='watchlistExpiry', array $params=[])
Definition: WatchlistExpiryJob.php:7
WatchlistExpiryJob
Definition: WatchlistExpiryJob.php:5
JobQueueGroup\singleton
static singleton( $domain=false)
Definition: JobQueueGroup.php:70