Changeset View
Changeset View
Standalone View
Standalone View
resources/sql/autopatches/20150129.pastefileapplicationemails.php
| <?php | <?php | ||||
| $key_files = 'metamta.files.public-create-email'; | $key_files = 'metamta.files.public-create-email'; | ||||
| $key_paste = 'metamta.paste.public-create-email'; | $key_paste = 'metamta.paste.public-create-email'; | ||||
| echo "Migrating `$key_files` and `$key_paste` to new application email ". | echo pht( | ||||
| "infrastructure...\n"; | "Migrating `%s` and `%s` to new application email infrastructure...\n", | ||||
| $key_files, | |||||
| $key_paste); | |||||
| $value_files = PhabricatorEnv::getEnvConfigIfExists($key_files); | $value_files = PhabricatorEnv::getEnvConfigIfExists($key_files); | ||||
| $files_app = new PhabricatorFilesApplication(); | $files_app = new PhabricatorFilesApplication(); | ||||
| if ($value_files) { | if ($value_files) { | ||||
| try { | try { | ||||
| PhabricatorMetaMTAApplicationEmail::initializeNewAppEmail( | PhabricatorMetaMTAApplicationEmail::initializeNewAppEmail( | ||||
| PhabricatorUser::getOmnipotentUser()) | PhabricatorUser::getOmnipotentUser()) | ||||
| ->setAddress($value_files) | ->setAddress($value_files) | ||||
| ->setApplicationPHID($files_app->getPHID()) | ->setApplicationPHID($files_app->getPHID()) | ||||
| ->save(); | ->save(); | ||||
| } catch (AphrontDuplicateKeyQueryException $ex) { | } catch (AphrontDuplicateKeyQueryException $ex) { | ||||
| // already migrated? | // Already migrated? | ||||
| } | } | ||||
| } | } | ||||
| $value_paste = PhabricatorEnv::getEnvConfigIfExists($key_paste); | $value_paste = PhabricatorEnv::getEnvConfigIfExists($key_paste); | ||||
| $paste_app = new PhabricatorPasteApplication(); | $paste_app = new PhabricatorPasteApplication(); | ||||
| if ($value_paste) { | if ($value_paste) { | ||||
| try { | try { | ||||
| PhabricatorMetaMTAApplicationEmail::initializeNewAppEmail( | PhabricatorMetaMTAApplicationEmail::initializeNewAppEmail( | ||||
| PhabricatorUser::getOmnipotentUser()) | PhabricatorUser::getOmnipotentUser()) | ||||
| ->setAddress($value_paste) | ->setAddress($value_paste) | ||||
| ->setApplicationPHID($paste_app->getPHID()) | ->setApplicationPHID($paste_app->getPHID()) | ||||
| ->save(); | ->save(); | ||||
| } catch (AphrontDuplicateKeyQueryException $ex) { | } catch (AphrontDuplicateKeyQueryException $ex) { | ||||
| // already migrated? | // Already migrated? | ||||
| } | } | ||||
| } | } | ||||
| echo "Done.\n"; | echo pht('Done.')."\n"; | ||||