Page MenuHomePhabricator

Fatal error in mail migration from a very old version
Closed, ResolvedPublic

Description

This fatal error happened on a specific mail record during a migration on a very old (October 2014) instance of Phabricator. The first 20k or so mail migrated just fine. Not sure what was different or how many were actually affected.

Applying patch 'phabricator:20150622.metamta.5.actor-phid-mig.php'...

[2015-08-23 10:38:12] EXCEPTION: (InvalidArgumentException) Argument 1 passed to idx() must be of the type array, null given, called in /src/applications/metamta/storage/PhabricatorMetaMTAMail.php on line 72 and defined at [<phutil>/src/error/PhutilErrorHandler.php:200]
arcanist(head=master, ref.master=957fbd76bbb9), phabricator(head=master, ref.master=d13bcddb6029), phutil(head=master, ref.master=e276f31b7117)
  #0 PhutilErrorHandler::handleError(integer, string, string, integer, array) called at [<phutil>/src/utils/utils.php:36]
  #1 idx(NULL, string, NULL) called at [<phabricator>/src/applications/metamta/storage/PhabricatorMetaMTAMail.php:72]
  #2 PhabricatorMetaMTAMail::getParam(string) called at [<phabricator>/src/applications/metamta/storage/PhabricatorMetaMTAMail.php:228]
  #3 PhabricatorMetaMTAMail::getFrom() called at [<phabricator>/resources/sql/autopatches/20150622.metamta.5.actor-phid-mig.php:15]
  #4 require_once(string) called at [<phabricator>/src/infrastructure/storage/management/PhabricatorStorageManagementAPI.php:226]
  #5 PhabricatorStorageManagementAPI::applyPatchPHP(string) called at [<phabricator>/src/infrastructure/storage/management/PhabricatorStorageManagementAPI.php:191]
  #6 PhabricatorStorageManagementAPI::applyPatch(PhabricatorStoragePatch) called at [<phabricator>/src/infrastructure/storage/management/workflow/PhabricatorStorageManagementUpgr
adeWorkflow.php:190]
  #7 PhabricatorStorageManagementUpgradeWorkflow::execute(PhutilArgumentParser) called at [<phutil>/src/parser/argument/PhutilArgumentParser.php:406]
  #8 PhutilArgumentParser::parseWorkflowsFull(array) called at [<phutil>/src/parser/argument/PhutilArgumentParser.php:301]
  #9 PhutilArgumentParser::parseWorkflows(array) called at [<phabricator>/scripts/sql/manage_storage.php:176]

My temp fix was to check if $this->parameters is an array, and if not return the default:

protected function getParam($param, $default = null) {
-  return idx($this->parameters, $param, $default);
+  if (is_array($this->parameters)) {
+    return idx($this->parameters, $param, $default);
+  }
+  return $default;
}