mirror of
https://gerrit.wikimedia.org/r/mediawiki/extensions/Echo
synced 2024-11-30 18:45:07 +00:00
33126b69aa
In preparation of Code Sniffer based updates. Change-Id: Id5d43332b44a37665d57dc24ef8c432bc65b2f6a
40 lines
1 KiB
PHP
40 lines
1 KiB
PHP
<?php
|
|
|
|
class EchoNotificationJob extends Job {
|
|
function __construct( $title, $params ) {
|
|
parent::__construct( 'EchoNotificationJob', $title, $params );
|
|
$this->event = $params['event'];
|
|
}
|
|
|
|
function run() {
|
|
// back compat for jobs still in queue, new jobs
|
|
// masterPos is always set. remove after deploy.
|
|
if ( isset( $this->params['masterPos'] ) ) {
|
|
$masterPos = $this->params['masterPos'];
|
|
} else {
|
|
$masterPos = $this->getMasterPosition();
|
|
}
|
|
|
|
MWEchoDbFactory::newFromDefault()->waitFor( $masterPos );
|
|
EchoNotificationController::notify( $this->event, false );
|
|
|
|
return true;
|
|
}
|
|
|
|
// back compat detects masterPos from prior job params
|
|
function getMasterPosition() {
|
|
$masterPos = array(
|
|
'wikiDb' => false,
|
|
'echoDb' => false,
|
|
);
|
|
if ( !empty( $this->params['mainDbMasterPos'] ) ) {
|
|
$masterPos['wikiDb'] = $this->params['mainDbMasterPos'];
|
|
}
|
|
if ( !empty( $this->params['echoDbMasterPos'] ) ) {
|
|
$masterPos['echoDb'] = $this->params['echoDbMasterPos'];
|
|
}
|
|
|
|
return $masterPos;
|
|
}
|
|
}
|