MediaWiki REL1_35
UserOptionsUpdateJob.php
Go to the documentation of this file.
1<?php
34 public function __construct( array $params ) {
35 parent::__construct( 'userOptionsUpdate', $params );
36 $this->removeDuplicates = true;
37 }
38
39 public function run() {
40 if ( !$this->params['options'] ) {
41 return true; // nothing to do
42 }
43
44 $user = User::newFromId( $this->params['userId'] );
45 $user->load( $user::READ_EXCLUSIVE );
46 if ( !$user->getId() ) {
47 return true;
48 }
49
50 foreach ( $this->params['options'] as $name => $value ) {
51 $user->setOption( $name, $value );
52 }
53
54 $user->saveSettings();
55
56 return true;
57 }
58}
Class to both describe a background job and handle jobs.
Definition Job.php:32
array $params
Array of job parameters.
Definition Job.php:37
Job that updates a user's preferences.
static newFromId( $id)
Static factory method for creation from a given user ID.
Definition User.php:565
Interface for generic jobs only uses the parameters field and are JSON serializable.