1
0
Fork 0
mirror of https://we.phorge.it/source/phorge.git synced 2024-11-10 08:52:39 +01:00

Read default values of custom config options

Summary: Because the Default configuration provider is loaded before custom libraries, any config options specified in them don't get a default values.

Test Plan: Looked at /config/

Reviewers: epriestley, codeblock, btrahan

Reviewed By: epriestley

CC: aran, Korvin

Differential Revision: https://secure.phabricator.com/D4532
This commit is contained in:
Asher Baker 2013-01-19 08:34:54 -08:00 committed by epriestley
parent ff53b7942a
commit da9315b145
3 changed files with 21 additions and 6 deletions

View file

@ -132,7 +132,7 @@ abstract class PhabricatorApplicationConfigOptions extends Phobject {
->setGroup($this);
}
final public static function loadAll() {
final public static function loadAll($external_only = false) {
$symbols = id(new PhutilSymbolLoader())
->setAncestorClass('PhabricatorApplicationConfigOptions')
->setConcreteOnly(true)
@ -140,6 +140,10 @@ abstract class PhabricatorApplicationConfigOptions extends Phobject {
$groups = array();
foreach ($symbols as $symbol) {
if ($external_only && $symbol['library'] == 'phabricator') {
continue;
}
$obj = newv($symbol['name'], array());
$key = $obj->getKey();
if (isset($groups[$key])) {
@ -156,8 +160,8 @@ abstract class PhabricatorApplicationConfigOptions extends Phobject {
return $groups;
}
final public static function loadAllOptions() {
$groups = self::loadAll();
final public static function loadAllOptions($external_only = false) {
$groups = self::loadAll($external_only);
$options = array();
foreach ($groups as $group) {

View file

@ -13,4 +13,10 @@ final class PhabricatorConfigDefaultSource
$this->setSource(new PhabricatorConfigDictionarySource($options));
}
public function loadExternalOptions() {
$options = PhabricatorApplicationConfigOptions::loadAllOptions(true);
$options = mpull($options, 'getDefault');
$this->setKeys($options);
}
}

View file

@ -132,9 +132,9 @@ final class PhabricatorEnv {
$stack = new PhabricatorConfigStackSource();
self::$sourceStack = $stack;
$stack->pushSource(
id(new PhabricatorConfigDefaultSource())
->setName(pht('Global Default')));
$defaultSource = id(new PhabricatorConfigDefaultSource())
->setName(pht('Global Default'));
$stack->pushSource($defaultSource);
$env = self::getSelectedEnvironmentName();
$stack->pushSource(
@ -152,6 +152,11 @@ final class PhabricatorEnv {
phutil_load_library($library);
}
// If custom libraries specify config options, they won't get default
// values as the Default source has already been loaded, so we get it to
// pull in all options from non-phabricator libraries now they are loaded.
$defaultSource->loadExternalOptions();
try {
$stack->pushSource(
id(new PhabricatorConfigDatabaseSource('default'))