mirror of
https://we.phorge.it/source/phorge.git
synced 2024-11-25 16:22:43 +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:
parent
07dc943215
commit
3844be3f83
1 changed files with 16 additions and 7 deletions
|
@ -22,20 +22,17 @@ final class PhabricatorMetaMTAWorker
|
||||||
private $message;
|
private $message;
|
||||||
|
|
||||||
public function getWaitBeforeRetry(PhabricatorWorkerTask $task) {
|
public function getWaitBeforeRetry(PhabricatorWorkerTask $task) {
|
||||||
$message_id = $this->getTaskData();
|
$message = $this->loadMessage();
|
||||||
|
if (!$message) {
|
||||||
$this->message = id(new PhabricatorMetaMTAMail())->loadOneWhere(
|
|
||||||
'id = %d', $this->getTaskData());
|
|
||||||
if (!$this->message) {
|
|
||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
|
|
||||||
$wait = max($this->message->getNextRetry() - time(), 0) + 15;
|
$wait = max($message->getNextRetry() - time(), 0) + 15;
|
||||||
return $wait;
|
return $wait;
|
||||||
}
|
}
|
||||||
|
|
||||||
public function doWork() {
|
public function doWork() {
|
||||||
$message = $this->message;
|
$message = $this->loadMessage();
|
||||||
if (!$message
|
if (!$message
|
||||||
|| $message->getStatus() != PhabricatorMetaMTAMail::STATUS_QUEUE) {
|
|| $message->getStatus() != PhabricatorMetaMTAMail::STATUS_QUEUE) {
|
||||||
return;
|
return;
|
||||||
|
@ -48,4 +45,16 @@ final class PhabricatorMetaMTAWorker
|
||||||
throw new Exception('Failed to send message');
|
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;
|
||||||
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in a new issue