diff --git a/src/applications/config/option/PhabricatorCoreConfigOptions.php b/src/applications/config/option/PhabricatorCoreConfigOptions.php index 8d6e4b30f9..2521e58f9c 100644 --- a/src/applications/config/option/PhabricatorCoreConfigOptions.php +++ b/src/applications/config/option/PhabricatorCoreConfigOptions.php @@ -214,12 +214,35 @@ final class PhabricatorCoreConfigOptions ->setDescription(pht('Cache namespace.')), $this->newOption('phabricator.allow-email-users', 'bool', false) ->setBoolOptions( - array( - pht('Allow'), - pht('Disallow'), - ))->setDescription( - pht( - 'Allow non-members to interact with tasks over email.')), + array( + pht('Allow'), + pht('Disallow'), + )) + ->setDescription( + pht('Allow non-members to interact with tasks over email.')), + $this->newOption('phabricator.silent', 'bool', false) + ->setLocked(true) + ->setBoolOptions( + array( + pht('Run Silently'), + pht('Run Normally'), + )) + ->setSummary(pht('Stop Phabricator from sending any email, etc.')) + ->setDescription( + pht( + 'This option allows you to stop Phabricator from sending '. + 'any data to external services. Among other things, it will '. + 'disable email, SMS, repository mirroring, and HTTP hooks.'. + "\n\n". + 'This option is intended to allow a Phabricator instance to '. + 'be exported, copied, imported, and run in a test environment '. + 'without impacting users. For example, if you are migrating '. + 'to new hardware, you could perform a test migration first, '. + 'make sure things work, and then do a production cutover '. + 'later with higher confidence and less disruption. Without '. + 'this flag, users would receive duplicate email during the '. + 'time the test instance and old production instance were '. + 'both in operation.')), ); } diff --git a/src/applications/diffusion/controller/DiffusionRepositoryEditMainController.php b/src/applications/diffusion/controller/DiffusionRepositoryEditMainController.php index de72ce394b..0b270998f0 100644 --- a/src/applications/diffusion/controller/DiffusionRepositoryEditMainController.php +++ b/src/applications/diffusion/controller/DiffusionRepositoryEditMainController.php @@ -126,7 +126,15 @@ final class DiffusionRepositoryEditMainController $boxes[] = id(new PhabricatorAnchorView())->setAnchorName('mirrors'); + $mirror_info = array(); + if (PhabricatorEnv::getEnvConfig('phabricator.silent')) { + $mirror_info[] = pht( + 'Phabricator is running in silent mode, so changes will not '. + 'be pushed to mirrors.'); + } + $boxes[] = id(new PHUIObjectBoxView()) + ->setFormErrors($mirror_info) ->setHeaderText(pht('Mirrors')) ->addPropertyList($mirror_properties); diff --git a/src/applications/doorkeeper/worker/DoorkeeperFeedWorker.php b/src/applications/doorkeeper/worker/DoorkeeperFeedWorker.php index f73451ee87..a280e85fbb 100644 --- a/src/applications/doorkeeper/worker/DoorkeeperFeedWorker.php +++ b/src/applications/doorkeeper/worker/DoorkeeperFeedWorker.php @@ -157,6 +157,11 @@ abstract class DoorkeeperFeedWorker extends FeedPushWorker { * @{method:publishFeedStory}. */ final protected function doWork() { + if (PhabricatorEnv::getEnvConfig('phabricator.silent')) { + $this->log(pht('Phabricator is running in silent mode.')); + return; + } + if (!$this->isEnabled()) { $this->log("Doorkeeper worker '%s' is not enabled.\n", get_class($this)); return; diff --git a/src/applications/feed/worker/FeedPublisherHTTPWorker.php b/src/applications/feed/worker/FeedPublisherHTTPWorker.php index e4e0600cb1..4742e52a29 100644 --- a/src/applications/feed/worker/FeedPublisherHTTPWorker.php +++ b/src/applications/feed/worker/FeedPublisherHTTPWorker.php @@ -3,6 +3,11 @@ final class FeedPublisherHTTPWorker extends FeedPushWorker { protected function doWork() { + if (PhabricatorEnv::getEnvConfig('phabricator.silent')) { + // Don't invoke hooks in silent mode. + return; + } + $story = $this->loadFeedStory(); $data = $story->getStoryData(); diff --git a/src/applications/metamta/storage/PhabricatorMetaMTAMail.php b/src/applications/metamta/storage/PhabricatorMetaMTAMail.php index e6d8e52c45..0fb118252a 100644 --- a/src/applications/metamta/storage/PhabricatorMetaMTAMail.php +++ b/src/applications/metamta/storage/PhabricatorMetaMTAMail.php @@ -633,6 +633,15 @@ final class PhabricatorMetaMTAMail extends PhabricatorMetaMTADAO { } } + if (PhabricatorEnv::getEnvConfig('phabricator.silent')) { + $this->setStatus(self::STATUS_VOID); + $this->setMessage( + pht( + 'Phabricator is running in silent mode. See `phabricator.silent` '. + 'in the configuration to change this setting.')); + return $this->save(); + } + $mailer->addHeader('X-Phabricator-Sent-This-Message', 'Yes'); $mailer->addHeader('X-Mail-Transport-Agent', 'MetaMTA'); diff --git a/src/applications/repository/engine/PhabricatorRepositoryMirrorEngine.php b/src/applications/repository/engine/PhabricatorRepositoryMirrorEngine.php index d73b2bed0f..8d3dd9f8f9 100644 --- a/src/applications/repository/engine/PhabricatorRepositoryMirrorEngine.php +++ b/src/applications/repository/engine/PhabricatorRepositoryMirrorEngine.php @@ -13,6 +13,12 @@ final class PhabricatorRepositoryMirrorEngine return; } + if (PhabricatorEnv::getEnvConfig('phabricator.silent')) { + $this->log( + pht('Phabricator is running in silent mode; declining to mirror.')); + return; + } + $mirrors = id(new PhabricatorRepositoryMirrorQuery()) ->setViewer($this->getViewer()) ->withRepositoryPHIDs(array($repository->getPHID())) diff --git a/src/infrastructure/sms/worker/PhabricatorSMSSendWorker.php b/src/infrastructure/sms/worker/PhabricatorSMSSendWorker.php index fa56336809..0ee9aebb77 100644 --- a/src/infrastructure/sms/worker/PhabricatorSMSSendWorker.php +++ b/src/infrastructure/sms/worker/PhabricatorSMSSendWorker.php @@ -55,6 +55,15 @@ final class PhabricatorSMSSendWorker // give the provider name the same treatment as phone number $sms->setProviderShortName($adapter->getProviderShortName()); + if (PhabricatorEnv::getEnvConfig('phabricator.silent')) { + $sms->setSendStatus(PhabricatorSMS::STATUS_FAILED_PERMANENTLY); + $sms->save(); + throw new PhabricatorWorkerPermanentFailureException( + pht( + 'Phabricator is running in silent mode. See `phabricator.silent` '. + 'in the configuration to change this setting.')); + } + try { $result = $adapter->send(); list($sms_id, $sent_status) = $adapter->getSMSDataFromResult($result); diff --git a/src/infrastructure/testing/PhabricatorTestCase.php b/src/infrastructure/testing/PhabricatorTestCase.php index 53950ddf73..2a2834c93f 100644 --- a/src/infrastructure/testing/PhabricatorTestCase.php +++ b/src/infrastructure/testing/PhabricatorTestCase.php @@ -119,6 +119,9 @@ abstract class PhabricatorTestCase extends ArcanistPhutilTestCase { $this->env->overrideEnvConfig( 'phabricator.base-uri', 'http://phabricator.example.com'); + + // Tests do their own stubbing/voiding for events. + $this->env->overrideEnvConfig('phabricator.silent', false); } protected function didRunTests() {