NotificationJob: make sure we retry to load the event from master

EventMapper->fetchById() has retry on master built-in but it doesn't
kick in in a Job because the load balancer is a new instance and doesn't
know about previous writes.

This change makes the job always read from master to make
sure the event is found. It is going to write to master
right after anyway.

Bug: T204894
Change-Id: I9a2873234f1dd5416e6c2bedeb904880d1f79562
This commit is contained in:
Stephane Bisson 2019-04-12 13:02:50 -04:00
parent 2256c03253
commit f361425a34

View file

@ -1,17 +1,14 @@
<?php
class EchoNotificationJob extends Job {
/** @var int */
private $eventId;
public function __construct( $title, $params ) {
parent::__construct( 'EchoNotificationJob', $title, $params );
$this->eventId = $params['eventId'];
}
public function run() {
MWEchoDbFactory::newFromDefault()->waitForSlaves();
$event = EchoEvent::newFromID( $this->eventId );
$eventMapper = new EchoEventMapper();
$event = $eventMapper->fetchById( $this->params['eventId'], true );
EchoNotificationController::notify( $event, false );
return true;