MediaWiki  master
UserEditCountInitJob.php
Go to the documentation of this file.
1 <?php
22 
35 class UserEditCountInitJob extends Job implements GenericParameterJob {
36 
37  public function __construct( array $params ) {
38  parent::__construct( 'userEditCountInit', $params );
39  $this->removeDuplicates = true;
40  }
41 
42  public function run() {
43  $dbw = MediaWikiServices::getInstance()->getDBLoadBalancerFactory()->getPrimaryDatabase();
44 
45  $dbw->newUpdateQueryBuilder()
46  ->update( 'user' )
47  ->set( [ 'user_editcount' => $this->params['editCount'] ] )
48  ->where( [
49  'user_id' => $this->params['userId'],
50  'user_editcount IS NULL OR user_editcount < ' . $dbw->addQuotes( $this->params['editCount'] )
51  ] )
52  ->caller( __METHOD__ )->execute();
53 
54  return true;
55  }
56 }
Class to both describe a background job and handle jobs.
Definition: Job.php:40
array $params
Array of job parameters.
Definition: Job.php:45
Service locator for MediaWiki core services.
Job that initializes an user's edit count.
Interface for generic jobs only uses the parameters field and are JSON serializable.