mediawiki-extensions-Echo/includes/jobs/NotificationJob.php
Kunal Mehta 9d08c96fad Move all PHP code into includes/
Mainly because I was annoyed at m<tab>o<tab>d<tab>u<tab> to reach
modules/.

Change-Id: Ib149cb2e2612ccddd0503f9d0c5d05b554860a00
2015-06-07 18:54:14 -07:00

38 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;
}
}