mediawiki-extensions-Echo/includes/jobs/NotificationJob.php
James D. Forrester 8c810dff48 build: Update mediawiki/mediawiki-codesniffer to 0.7.1
Also added "composer fix" command.

Change-Id: I25cb61b3b92798f1259d1575a336e2b056d5764f
2016-12-05 15:54:30 -08:00

40 lines
1,023 B
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 = [
'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;
}
}