MediaWiki
master
Toggle main menu visibility
RecentChangeNotifyJob.php
Go to the documentation of this file.
1
<?php
6
7
namespace
MediaWiki\RecentChanges;
8
9
use MediaWiki\JobQueue\Job;
10
use MediaWiki\Title\Title;
11
use MediaWiki\User\User;
12
21
class
RecentChangeNotifyJob
extends
Job
{
22
private
RecentChangeLookup
$recentChangeLookup;
23
24
public
function
__construct
(
25
Title
$title
,
26
array
$params
,
27
RecentChangeLookup
$recentChangeLookup
28
) {
29
parent::__construct(
'enotifNotify'
,
$title
,
$params
);
30
31
$this->recentChangeLookup = $recentChangeLookup;
32
}
33
35
public
function
run
() {
36
$notifier =
new
RecentChangeNotifier
();
37
// Get the user from ID (rename safe). Anons are 0, so defer to name.
38
if
( isset( $this->params[
'editorID'
] ) && $this->params[
'editorID'
] ) {
39
$editor = User::newFromId( $this->params[
'editorID'
] );
40
// B/C, only the name might be given.
41
}
else
{
42
# @todo FIXME: newFromName could return false on a badly configured wiki.
43
$editor = User::newFromName( $this->params[
'editor'
],
false
);
44
}
45
if
( !array_key_exists(
'rc_id'
, $this->params ) ) {
46
$this->
setLastError
(
47
'Cannot execute RecentChangeNotifyJob without `rc_id`. This has to be an old job'
48
);
49
return
true
;
50
}
51
$recentChange = $this->recentChangeLookup->getRecentChangeById( $this->params[
'rc_id'
] );
52
if
( $recentChange ) {
53
$notifier->actuallyNotifyOnPageChange(
54
$editor,
55
$this->title,
56
$recentChange,
57
$this->params[
'watchers'
],
58
$this->params[
'pageStatus'
]
59
);
60
}
61
return
true
;
62
}
63
}
64
66
class_alias( RecentChangeNotifyJob::class,
'EnotifNotifyJob'
);
MediaWiki\JobQueue\Job
Describe and execute a background job.
Definition
Job.php:28
MediaWiki\JobQueue\Job\$params
array $params
Array of job parameters.
Definition
Job.php:33
MediaWiki\JobQueue\Job\setLastError
setLastError( $error)
Definition
Job.php:424
MediaWiki\JobQueue\Job\$title
Title $title
Definition
Job.php:39
MediaWiki\RecentChanges\RecentChangeNotifier
Find watchers and create notifications after a page is changed.
Definition
RecentChangeNotifier.php:42
MediaWiki\RecentChanges\RecentChangeNotifyJob
Send an email notification.
Definition
RecentChangeNotifyJob.php:21
MediaWiki\RecentChanges\RecentChangeNotifyJob\__construct
__construct(Title $title, array $params, RecentChangeLookup $recentChangeLookup)
Definition
RecentChangeNotifyJob.php:24
MediaWiki\RecentChanges\RecentChangeNotifyJob\run
run()
Run the job.If this method returns false or completes exceptionally, the job runner will retry execut...
Definition
RecentChangeNotifyJob.php:35
MediaWiki\Title\Title
Represents a title within MediaWiki.
Definition
Title.php:69
MediaWiki\RecentChanges\RecentChangeLookup
Definition
RecentChangeLookup.php:16
includes
RecentChanges
RecentChangeNotifyJob.php
Generated on
for MediaWiki by
1.18.0