From 779a612e417261686be63f65d099a42f5bfcc0c3 Mon Sep 17 00:00:00 2001 From: epriestley Date: Mon, 24 Aug 2015 09:37:48 -0700 Subject: [PATCH] Fix mail parameter error with old migrations Summary: Fixes T9251. Old mail could get saved with bad parameters for two reasons that I can come up with: - Nothing ever set a parameter on it -- not sure this could ever actually happen; or - some field contained non-UTF8 data prior to D13939 and we silently failed to encode it. My guess is that the second case is probably the culprit here. In any case, recover from this so `20150622.metamta.5.actor-phid-mig.php` can proceed. Test Plan: Same effective patch as user patch in T9251; looked at some mail to make sure it was still pulling parameters properly. Reviewers: chad Reviewed By: chad Maniphest Tasks: T9251 Differential Revision: https://secure.phabricator.com/D13990 --- .../metamta/storage/PhabricatorMetaMTAMail.php | 9 ++++++++- 1 file changed, 8 insertions(+), 1 deletion(-) diff --git a/src/applications/metamta/storage/PhabricatorMetaMTAMail.php b/src/applications/metamta/storage/PhabricatorMetaMTAMail.php index abcbb7a082..c4793ed918 100644 --- a/src/applications/metamta/storage/PhabricatorMetaMTAMail.php +++ b/src/applications/metamta/storage/PhabricatorMetaMTAMail.php @@ -10,7 +10,7 @@ final class PhabricatorMetaMTAMail const RETRY_DELAY = 5; protected $actorPHID; - protected $parameters; + protected $parameters = array(); protected $status; protected $message; protected $relatedPHID; @@ -69,6 +69,13 @@ final class PhabricatorMetaMTAMail } protected function getParam($param, $default = null) { + // Some old mail was saved without parameters because no parameters were + // set or encoding failed. Recover in these cases so we can perform + // mail migrations, see T9251. + if (!is_array($this->parameters)) { + $this->parameters = array(); + } + return idx($this->parameters, $param, $default); }