1
0
Fork 0
mirror of https://we.phorge.it/source/phorge.git synced 2024-11-29 10:12:41 +01:00

Minor, fix an MTA issue introduced in D3859.

Prior to D3859, getRequiredLeaseTime() was called before doWork(), which had the critical but subtle side effect of populating `$this->message`. Instead, make the population explicit. This restores email functionality.

Test Plan: ran `phd debug taskmaster` and verified email was delivered

Auditors: btrahan
This commit is contained in:
epriestley 2012-11-01 16:38:47 -07:00
parent 07dc943215
commit 3844be3f83

View file

@ -22,20 +22,17 @@ final class PhabricatorMetaMTAWorker
private $message;
public function getWaitBeforeRetry(PhabricatorWorkerTask $task) {
$message_id = $this->getTaskData();
$this->message = id(new PhabricatorMetaMTAMail())->loadOneWhere(
'id = %d', $this->getTaskData());
if (!$this->message) {
$message = $this->loadMessage();
if (!$message) {
return null;
}
$wait = max($this->message->getNextRetry() - time(), 0) + 15;
$wait = max($message->getNextRetry() - time(), 0) + 15;
return $wait;
}
public function doWork() {
$message = $this->message;
$message = $this->loadMessage();
if (!$message
|| $message->getStatus() != PhabricatorMetaMTAMail::STATUS_QUEUE) {
return;
@ -48,4 +45,16 @@ final class PhabricatorMetaMTAWorker
throw new Exception('Failed to send message');
}
}
private function loadMessage() {
if (!$this->message) {
$message_id = $this->getTaskData();
$this->message = id(new PhabricatorMetaMTAMail())->load($message_id);
if (!$this->message) {
return null;
}
}
return $this->message;
}
}