mirror of
https://we.phorge.it/source/phorge.git
synced 2024-12-24 06:20:56 +01:00
Add "phabricator.silent" for stopping all outbound events from an install
Summary: Ref T7522. This is mostly useful in the cluster, but could be useful for external installs too. If you want to import an instance into a test/dry-run state (in the cluster, to test an import; in the general case, to do something like test new hardware or configuration), you currently risk spamming users with a lot of duplicate notifications. In particular, if Phabricator tracks remotes, both instances will continue importing commits and sending email about them. Both instances will try to publish to mirrors, too, which could be bad news, and both instances will try to update linked services. Instead, provide a flag to let an instance run in "silent mode", which disables all outbound messaging and data. We need to remember to support this flag on any new outbound channels, but we add about one of those per year so I think that's reasonable. Test Plan: - Flipped config. - Saw it void email, feed and mirroring. - Didn't test SMS since it's not really in use yet and not convenient to test. - (Can you think of any publishing I missed?) Reviewers: btrahan Reviewed By: btrahan Subscribers: epriestley Maniphest Tasks: T7522 Differential Revision: https://secure.phabricator.com/D12109
This commit is contained in:
parent
b5238dc080
commit
bd2eaad04f
8 changed files with 74 additions and 6 deletions
|
@ -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.')),
|
||||
);
|
||||
|
||||
}
|
||||
|
|
|
@ -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);
|
||||
|
||||
|
|
|
@ -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;
|
||||
|
|
|
@ -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();
|
||||
|
||||
|
|
|
@ -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');
|
||||
|
||||
|
|
|
@ -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()))
|
||||
|
|
|
@ -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);
|
||||
|
|
|
@ -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() {
|
||||
|
|
Loading…
Reference in a new issue