@recaptime-dev's working patches + fork for Phorge, a community fork of Phabricator. (Upstream dev and stable branches are at upstream/main and upstream/stable respectively.) hq.recaptime.dev/wiki/Phorge
phorge phabricator
1
fork

Configure Feed

Select the types of activity you want to include in your feed.

Make "phabricator.silent" disable build steps which rely on external services

Summary:
Depends on D19084. Fixes T13078. When `phabricator.silent` is enabled, immediately fail the "HTTP Request", "CircleCI" and "Buildkite" build steps.

This doesn't feel quite as clean as most of the other behavior of `phabricator.silent`, since these calls are not exactly notifications in the same way that email is, and failing to make these calls means that builds run differently (whereas failing to deliver email doesn't really do anything).

However, I suspect that this behavior is almost always reasonable/correct, and that we can probably get away with it until this grey area between "notifications" and "external service calls" is more clearly defined.

Test Plan:
- Created a build with HTTP, CircleCI, and Buildkite steps.
- Put install in `phabricator.silent` mode: all three steps failed with "declining, because silent" messages.
- Put install back in normal mode: all three steps made HTTP requests.
- Read updated documentation.

Subscribers: PHID-OPKG-gm6ozazyms6q6i22gyam

Maniphest Tasks: T13078

Differential Revision: https://secure.phabricator.com/D19085

+47 -15
+19 -15
src/applications/config/option/PhabricatorCoreConfigOptions.php
··· 37 37 $proto_doc_name = pht('User Guide: Prototype Applications'); 38 38 $applications_app_href = '/applications/'; 39 39 40 + $silent_description = $this->deformat(pht(<<<EOREMARKUP 41 + This option allows you to stop Phabricator from sending data to most external 42 + services: it will disable email, SMS, repository mirroring, remote builds, 43 + Doorkeeper writes, and webhooks. 44 + 45 + This option is intended to allow a Phabricator instance to be exported, copied, 46 + imported, and run in a test environment without impacting users. For example, 47 + if you are migrating to new hardware, you could perform a test migration first 48 + with this flag set, make sure things work, and then do a production cutover 49 + later with higher confidence and less disruption. 50 + 51 + Without making use of this flag to silence the temporary test environment, 52 + users would receive duplicate email during the time the test instance and old 53 + production instance were both in operation. 54 + EOREMARKUP 55 + )); 56 + 57 + 40 58 return array( 41 59 $this->newOption('phabricator.base-uri', 'string', null) 42 60 ->setLocked(true) ··· 232 250 pht('Run Normally'), 233 251 )) 234 252 ->setSummary(pht('Stop Phabricator from sending any email, etc.')) 235 - ->setDescription( 236 - pht( 237 - 'This option allows you to stop Phabricator from sending '. 238 - 'any data to external services. Among other things, it will '. 239 - 'disable email, SMS, repository mirroring, and HTTP hooks.'. 240 - "\n\n". 241 - 'This option is intended to allow a Phabricator instance to '. 242 - 'be exported, copied, imported, and run in a test environment '. 243 - 'without impacting users. For example, if you are migrating '. 244 - 'to new hardware, you could perform a test migration first, '. 245 - 'make sure things work, and then do a production cutover '. 246 - 'later with higher confidence and less disruption. Without '. 247 - 'this flag, users would receive duplicate email during the '. 248 - 'time the test instance and old production instance were '. 249 - 'both in operation.')), 253 + ->setDescription($silent_description), 250 254 ); 251 255 252 256 }
+12
src/applications/harbormaster/step/HarbormasterBuildStepImplementation.php
··· 295 295 ->append($body); 296 296 } 297 297 298 + protected function logSilencedCall( 299 + HarbormasterBuild $build, 300 + HarbormasterBuildTarget $build_target, 301 + $label) { 302 + 303 + $build_target 304 + ->newLog($label, 'silenced') 305 + ->append( 306 + pht( 307 + 'Declining to make service call because `phabricator.silent` is '. 308 + 'enabled in configuration.')); 309 + } 298 310 299 311 300 312 /* -( Automatic Targets )-------------------------------------------------- */
+5
src/applications/harbormaster/step/HarbormasterBuildkiteBuildStepImplementation.php
··· 72 72 HarbormasterBuildTarget $build_target) { 73 73 $viewer = PhabricatorUser::getOmnipotentUser(); 74 74 75 + if (PhabricatorEnv::getEnvConfig('phabricator.silent')) { 76 + $this->logSilencedCall($build, $build_target, pht('Buildkite')); 77 + throw new HarbormasterBuildFailureException(); 78 + } 79 + 75 80 $buildable = $build->getBuildable(); 76 81 77 82 $object = $buildable->getBuildableObject();
+5
src/applications/harbormaster/step/HarbormasterCircleCIBuildStepImplementation.php
··· 84 84 HarbormasterBuildTarget $build_target) { 85 85 $viewer = PhabricatorUser::getOmnipotentUser(); 86 86 87 + if (PhabricatorEnv::getEnvConfig('phabricator.silent')) { 88 + $this->logSilencedCall($build, $build_target, pht('CircleCI')); 89 + throw new HarbormasterBuildFailureException(); 90 + } 91 + 87 92 $buildable = $build->getBuildable(); 88 93 89 94 $object = $buildable->getBuildableObject();
+6
src/applications/harbormaster/step/HarbormasterHTTPRequestBuildStepImplementation.php
··· 43 43 HarbormasterBuildTarget $build_target) { 44 44 45 45 $viewer = PhabricatorUser::getOmnipotentUser(); 46 + 47 + if (PhabricatorEnv::getEnvConfig('phabricator.silent')) { 48 + $this->logSilencedCall($build, $build_target, pht('HTTP Request')); 49 + throw new HarbormasterBuildFailureException(); 50 + } 51 + 46 52 $settings = $this->getSettings(); 47 53 $variables = $build_target->getVariables(); 48 54