Code Coverage |
||||||||||
Lines |
Functions and Methods |
Classes and Traits |
||||||||
| Total | |
0.00% |
0 / 22 |
|
0.00% |
0 / 2 |
CRAP | |
0.00% |
0 / 1 |
| RecentChangeNotifyJob | |
0.00% |
0 / 21 |
|
0.00% |
0 / 2 |
42 | |
0.00% |
0 / 1 |
| __construct | |
0.00% |
0 / 2 |
|
0.00% |
0 / 1 |
2 | |||
| run | |
0.00% |
0 / 19 |
|
0.00% |
0 / 1 |
30 | |||
| 1 | <?php |
| 2 | /** |
| 3 | * @license GPL-2.0-or-later |
| 4 | * @file |
| 5 | */ |
| 6 | |
| 7 | namespace MediaWiki\RecentChanges; |
| 8 | |
| 9 | use MediaWiki\JobQueue\Job; |
| 10 | use MediaWiki\Title\Title; |
| 11 | use MediaWiki\User\User; |
| 12 | |
| 13 | /** |
| 14 | * Send an email notification. |
| 15 | * |
| 16 | * @ingroup JobQueue |
| 17 | * @ingroup Mail |
| 18 | */ |
| 19 | class RecentChangeNotifyJob extends Job { |
| 20 | private RecentChangeLookup $recentChangeLookup; |
| 21 | |
| 22 | public function __construct( |
| 23 | Title $title, |
| 24 | array $params, |
| 25 | RecentChangeLookup $recentChangeLookup |
| 26 | ) { |
| 27 | parent::__construct( 'enotifNotify', $title, $params ); |
| 28 | |
| 29 | $this->recentChangeLookup = $recentChangeLookup; |
| 30 | } |
| 31 | |
| 32 | /** @inheritDoc */ |
| 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 | |
| 63 | /** @deprecated class alias since 1.45 */ |
| 64 | class_alias( RecentChangeNotifyJob::class, 'EnotifNotifyJob' ); |