From 5148741ab29f2879a8ecb8043e6c8b205354eaf8 Mon Sep 17 00:00:00 2001 From: Marek Sapota Date: Wed, 19 Oct 2011 12:54:49 -0700 Subject: [PATCH] Prevent duplicated emails with send-immedialtely = true and MTA daemon running Test Plan: Set 'metamta.send-immediately' to true. Start up several MTA daemons, without the patch you'll probably get multiple emails, with the patch you should get only one. Reviewers: epriestley Reviewed By: epriestley CC: aran, mareksapota, epriestley Differential Revision: 1021 --- .../metamta/storage/mail/PhabricatorMetaMTAMail.php | 11 ++++++----- 1 file changed, 6 insertions(+), 5 deletions(-) diff --git a/src/applications/metamta/storage/mail/PhabricatorMetaMTAMail.php b/src/applications/metamta/storage/mail/PhabricatorMetaMTAMail.php index eabaf0d587..c8f59a91b3 100644 --- a/src/applications/metamta/storage/mail/PhabricatorMetaMTAMail.php +++ b/src/applications/metamta/storage/mail/PhabricatorMetaMTAMail.php @@ -178,10 +178,12 @@ class PhabricatorMetaMTAMail extends PhabricatorMetaMTADAO { * @return this */ public function saveAndSend() { - $ret = $this->save(); + $ret = null; if (PhabricatorEnv::getEnvConfig('metamta.send-immediately')) { - $this->sendNow(); + $ret = $this->sendNow(); + } else { + $ret = $this->save(); } return $ret; @@ -343,8 +345,7 @@ class PhabricatorMetaMTAMail extends PhabricatorMetaMTADAO { } catch (Exception $ex) { $this->setStatus(self::STATUS_FAIL); $this->setMessage($ex->getMessage()); - $this->save(); - return; + return $this->save(); } if ($this->getRetryCount() < $this->getSimulatedFailureCount()) { @@ -373,7 +374,7 @@ class PhabricatorMetaMTAMail extends PhabricatorMetaMTADAO { $this->setStatus(self::STATUS_SENT); } - $this->save(); + return $this->save(); } public static function getReadableStatus($status_code) {