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