MediaWiki
REL1_35
UserOptionsUpdateJob.php
Go to the documentation of this file.
1
<?php
33
class
UserOptionsUpdateJob
extends
Job
implements
GenericParameterJob
{
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
}
Job
Class to both describe a background job and handle jobs.
Definition
Job.php:32
Job\$params
array $params
Array of job parameters.
Definition
Job.php:37
UserOptionsUpdateJob
Job that updates a user's preferences.
Definition
UserOptionsUpdateJob.php:33
UserOptionsUpdateJob\__construct
__construct(array $params)
Definition
UserOptionsUpdateJob.php:34
UserOptionsUpdateJob\run
run()
Run the job.
Definition
UserOptionsUpdateJob.php:39
User\newFromId
static newFromId( $id)
Static factory method for creation from a given user ID.
Definition
User.php:565
GenericParameterJob
Interface for generic jobs only uses the parameters field and are JSON serializable.
Definition
GenericParameterJob.php:31
includes
jobqueue
jobs
UserOptionsUpdateJob.php
Generated on Sat Apr 6 2024 00:07:20 for MediaWiki by
1.9.8