@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.

getConfigEnv fails fast when key is not found and no default value is given.

Summary:
T2345
getConfig throws an Exception when the key does not exist.
Also removes dead code that throws an Exception.

Test Plan:
Reloaded the Phabricator home page. In the process, found
2 Exceptions thrown due to nonexistent keys. After addressing these problems,
the home page loads without Exceptions.

Reviewers: epriestley

Reviewed By: epriestley

CC: aran, Korvin

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

authored by

Nick Pellegrino and committed by
epriestley
3e6fa436 06bca93b

+29 -53
+3 -3
src/applications/config/option/PhabricatorConfigOption.php
··· 41 41 } 42 42 43 43 return idx( 44 - PhabricatorEnv::getEnvConfig('config.mask', array()), 44 + PhabricatorEnv::getEnvConfig('config.mask'), 45 45 $this->getKey(), 46 46 false); 47 47 } ··· 57 57 } 58 58 59 59 return idx( 60 - PhabricatorEnv::getEnvConfig('config.hide', array()), 60 + PhabricatorEnv::getEnvConfig('config.hide'), 61 61 $this->getKey(), 62 62 false); 63 63 } ··· 77 77 } 78 78 79 79 return idx( 80 - PhabricatorEnv::getEnvConfig('config.lock', array()), 80 + PhabricatorEnv::getEnvConfig('config.lock'), 81 81 $this->getKey(), 82 82 false); 83 83 }
+3
src/applications/config/option/PhabricatorCoreConfigOptions.php
··· 127 127 $this->newOption('phabricator.setup', 'bool', false) 128 128 ->setLocked(true) 129 129 ->setDescription(pht('Internal / deprecated.')), 130 + $this->newOption('test.value', 'wild', null) 131 + ->setLocked(true) 132 + ->setDescription(pht('Unit test value.')), 130 133 ); 131 134 } 132 135
+3 -3
src/applications/differential/controller/DifferentialRevisionViewController.php
··· 562 562 $status = $revision->getStatus(); 563 563 564 564 $allow_self_accept = PhabricatorEnv::getEnvConfig( 565 - 'differential.allow-self-accept', false); 565 + 'differential.allow-self-accept'); 566 566 $always_allow_close = PhabricatorEnv::getEnvConfig( 567 - 'differential.always-allow-close', false); 567 + 'differential.always-allow-close'); 568 568 $allow_reopen = PhabricatorEnv::getEnvConfig( 569 - 'differential.allow-reopen', false); 569 + 'differential.allow-reopen'); 570 570 571 571 if ($viewer_is_owner) { 572 572 switch ($status) {
+4 -4
src/applications/differential/editor/DifferentialCommentEditor.php
··· 99 99 $actor_phid = $actor->getPHID(); 100 100 $actor_is_author = ($actor_phid == $revision->getAuthorPHID()); 101 101 $allow_self_accept = PhabricatorEnv::getEnvConfig( 102 - 'differential.allow-self-accept', false); 102 + 'differential.allow-self-accept'); 103 103 $always_allow_close = PhabricatorEnv::getEnvConfig( 104 - 'differential.always-allow-close', false); 104 + 'differential.always-allow-close'); 105 105 $allow_reopen = PhabricatorEnv::getEnvConfig( 106 - 'differential.allow-reopen', false); 106 + 'differential.allow-reopen'); 107 107 $revision_status = $revision->getStatus(); 108 108 109 109 $revision->loadRelationships(); ··· 652 652 $removed_reviewers = $this->getRemovedReviewers(); 653 653 $reviewer_phids = $revision->getReviewers(); 654 654 $allow_self_accept = PhabricatorEnv::getEnvConfig( 655 - 'differential.allow-self-accept', false); 655 + 'differential.allow-self-accept'); 656 656 657 657 $reviewer_phids_map = array_fill_keys($reviewer_phids, true); 658 658 foreach ($added_reviewers as $k => $user_phid) {
+2 -2
src/applications/differential/mail/DifferentialCommentMail.php
··· 154 154 $hunk_parser = new DifferentialHunkParser(); 155 155 156 156 if (PhabricatorEnv::getEnvConfig( 157 - 'metamta.differential.unified-comment-context', false)) { 157 + 'metamta.differential.unified-comment-context')) { 158 158 foreach ($changesets as $changeset) { 159 159 $changeset->attachHunks($changeset->loadHunks()); 160 160 } ··· 176 176 $inline_content = $inline->getContent(); 177 177 178 178 if (!PhabricatorEnv::getEnvConfig( 179 - 'metamta.differential.unified-comment-context', false)) { 179 + 'metamta.differential.unified-comment-context')) { 180 180 $body[] = $this->formatText("{$file}:{$range} {$inline_content}"); 181 181 } else { 182 182 $body[] = "================";
+1 -2
src/applications/differential/parser/DifferentialChangesetParser.php
··· 370 370 371 371 if (!$generated_guess) { 372 372 $generated_path_regexps = PhabricatorEnv::getEnvConfig( 373 - 'differential.generated-paths', 374 - array()); 373 + 'differential.generated-paths'); 375 374 foreach ($generated_path_regexps as $regexp) { 376 375 if (preg_match($regexp, $this->changeset->getFilename())) { 377 376 $generated_guess = true;
+1 -2
src/applications/differential/storage/DifferentialDiff.php
··· 258 258 ->loadOneWhere('phid = %s', $this->getAuthorPHID()); 259 259 260 260 $use_emails = 261 - PhabricatorEnv::getEnvConfig('differential.expose-emails-prudently', 262 - false); 261 + PhabricatorEnv::getEnvConfig('differential.expose-emails-prudently'); 263 262 264 263 switch ($this->getSourceControlSystem()) { 265 264 case PhabricatorRepositoryType::REPOSITORY_TYPE_GIT:
+1 -1
src/applications/feed/PhabricatorFeedStoryPublisher.php
··· 104 104 $this->sendNotification($chrono_key); 105 105 } 106 106 107 - $uris = PhabricatorEnv::getEnvConfig('feed.http-hooks', array()); 107 + $uris = PhabricatorEnv::getEnvConfig('feed.http-hooks'); 108 108 foreach ($uris as $uri) { 109 109 $task = PhabricatorWorker::scheduleTask( 110 110 'FeedPublisherWorker',
+1 -3
src/applications/maniphest/constants/ManiphestTaskPriority.php
··· 84 84 */ 85 85 public static function getDefaultPriority() { 86 86 return PhabricatorEnv::getEnvConfig( 87 - 'maniphest.default-priority', 88 - self::PRIORITY_TRIAGE 89 - ); 87 + 'maniphest.default-priority'); 90 88 } 91 89 92 90 /**
+1 -4
src/applications/metamta/storage/PhabricatorMetaMTAMail.php
··· 738 738 * specified by the `metamta.user-address-format` configuration value. 739 739 */ 740 740 private function getUserName($user) { 741 - $format = PhabricatorEnv::getEnvConfig( 742 - 'metamta.user-address-format', 743 - 'full' 744 - ); 741 + $format = PhabricatorEnv::getEnvConfig('metamta.user-address-format'); 745 742 746 743 switch ($format) { 747 744 case 'short':
+1 -2
src/applications/search/index/PhabricatorSearchAbstractDocument.php
··· 14 14 private $relationships = array(); 15 15 16 16 public static function getSupportedTypes() { 17 - $more = PhabricatorEnv::getEnvConfig('search.more-document-types', array()); 18 17 return array( 19 18 PhabricatorPHIDConstants::PHID_TYPE_DREV => 'Differential Revisions', 20 19 PhabricatorPHIDConstants::PHID_TYPE_CMIT => 'Repository Commits', ··· 22 21 PhabricatorPHIDConstants::PHID_TYPE_WIKI => 'Phriction Documents', 23 22 PhabricatorPHIDConstants::PHID_TYPE_USER => 'Phabricator Users', 24 23 PhabricatorPHIDConstants::PHID_TYPE_QUES => 'Ponder Questions', 25 - ) + $more; 24 + ); 26 25 } 27 26 28 27 public function setPHID($phid) {
+8 -2
src/infrastructure/env/PhabricatorEnv.php
··· 227 227 /** 228 228 * Get the current configuration setting for a given key. 229 229 * 230 + * If the key is not found, then throw an Exception. 231 + * 230 232 * @task read 231 233 */ 232 - public static function getEnvConfig($key, $default = null) { 234 + public static function getEnvConfig($key) { 233 235 $result = self::$sourceStack->getKeys(array($key)); 234 - return idx($result, $key, $default); 236 + if (array_key_exists($key, $result)) { 237 + return $result[$key]; 238 + } else { 239 + throw new Exception("No config value specified for key '{$key}'."); 240 + } 235 241 } 236 242 237 243
-25
src/infrastructure/storage/lisk/LiskDAO.php
··· 187 187 private $__missingFields = array(); 188 188 private static $processIsolationLevel = 0; 189 189 private static $transactionIsolationLevel = 0; 190 - private static $__checkedClasses = array(); 191 190 192 191 private $__ephemeral = false; 193 192 ··· 213 212 214 213 if ($this->getConfigOption(self::CONFIG_PARTIAL_OBJECTS)) { 215 214 $this->resetDirtyFields(); 216 - 217 - $this_class = get_class($this); 218 - if (empty(self::$__checkedClasses[$this_class])) { 219 - self::$__checkedClasses = true; 220 - 221 - if (PhabricatorEnv::getEnvConfig('lisk.check_property_methods')) { 222 - $class = new ReflectionClass(get_class($this)); 223 - $methods = $class->getMethods(); 224 - $properties = $this->getProperties(); 225 - foreach ($methods as $method) { 226 - $name = strtolower($method->getName()); 227 - if (!(strncmp($name, 'get', 3) && strncmp($name, 'set', 3))) { 228 - $name = substr($name, 3); 229 - $declaring_class_name = $method->getDeclaringClass()->getName(); 230 - if (isset($properties[$name]) && 231 - $declaring_class_name !== 'LiskDAO') { 232 - throw new Exception( 233 - "Cannot implement method {$method->getName()} in ". 234 - "{$declaring_class_name}."); 235 - } 236 - } 237 - } 238 - } 239 - } 240 215 } 241 216 } 242 217