MediaWiki  master
UserEditCountInitJob.php
Go to the documentation of this file.
1 <?php
25 
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  $lb = MediaWikiServices::getInstance()->getDBLoadBalancer();
44  $dbw = $lb->getConnectionRef( DB_MASTER );
45 
46  $dbw->update(
47  'user',
48  // SET
49  [ 'user_editcount' => $this->params['editCount'] ],
50  // WHERE
51  [
52  'user_id' => $this->params['userId'],
53  'user_editcount IS NULL OR user_editcount < ' . $dbw->addQuotes( $this->params['editCount'] )
54  ],
55  __METHOD__
56  );
57 
58  return true;
59  }
60 }
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
UserEditCountInitJob
Job that initializes an user's edit count if it's not yet set or the current value is outdated.
Definition: UserEditCountInitJob.php:35
Job
Class to both describe a background job and handle jobs.
Definition: Job.php:32
DB_MASTER
const DB_MASTER
Definition: defines.php:26
UserEditCountInitJob\__construct
__construct(array $params)
Definition: UserEditCountInitJob.php:37
GenericParameterJob
Interface for generic jobs only uses the parameters field and are JSON serializable.
Definition: GenericParameterJob.php:31
UserEditCountInitJob\run
run()
Run the job.
Definition: UserEditCountInitJob.php:42