mediawiki-extensions-Echo/jobs/NotificationJob.php
bsitu ec18d637b9 Adding Echo jobs to deferred update along with master wait
This is in case job queue is picking up the job too fast when the current
transaction is not completed and job queue is trying to access non-committed data

When job is popped, some of the object is re-initialized from the database, this will
handle the replication lag

Change-Id: Ia7debb4db0103f27a3e326beb52db0f63bc7c0bc
2013-09-04 17:32:54 -07:00

21 lines
593 B
PHP

<?php
class EchoNotificationJob extends Job {
function __construct( $title, $params ) {
parent::__construct( 'EchoNotificationJob', $title, $params );
$this->event = $params['event'];
}
function run() {
if ( !empty( $this->params['mainDbMasterPos'] ) ) {
wfGetLB()->waitFor( $this->params['mainDbMasterPos'] );
}
if ( !empty( $this->params['echoDbMasterPos'] ) ) {
global $wgEchoCluster;
wfGetLBFactory()->getExternalLB( $wgEchoCluster )->waitFor( $this->params['echoDbMasterPos'] );
}
EchoNotificationController::notify( $this->event, false );
return true;
}
}