mirror of
https://we.phorge.it/source/phorge.git
synced 2024-11-22 23:02:42 +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:
parent
ff53b7942a
commit
da9315b145
3 changed files with 21 additions and 6 deletions
|
@ -132,7 +132,7 @@ abstract class PhabricatorApplicationConfigOptions extends Phobject {
|
||||||
->setGroup($this);
|
->setGroup($this);
|
||||||
}
|
}
|
||||||
|
|
||||||
final public static function loadAll() {
|
final public static function loadAll($external_only = false) {
|
||||||
$symbols = id(new PhutilSymbolLoader())
|
$symbols = id(new PhutilSymbolLoader())
|
||||||
->setAncestorClass('PhabricatorApplicationConfigOptions')
|
->setAncestorClass('PhabricatorApplicationConfigOptions')
|
||||||
->setConcreteOnly(true)
|
->setConcreteOnly(true)
|
||||||
|
@ -140,6 +140,10 @@ abstract class PhabricatorApplicationConfigOptions extends Phobject {
|
||||||
|
|
||||||
$groups = array();
|
$groups = array();
|
||||||
foreach ($symbols as $symbol) {
|
foreach ($symbols as $symbol) {
|
||||||
|
if ($external_only && $symbol['library'] == 'phabricator') {
|
||||||
|
continue;
|
||||||
|
}
|
||||||
|
|
||||||
$obj = newv($symbol['name'], array());
|
$obj = newv($symbol['name'], array());
|
||||||
$key = $obj->getKey();
|
$key = $obj->getKey();
|
||||||
if (isset($groups[$key])) {
|
if (isset($groups[$key])) {
|
||||||
|
@ -156,8 +160,8 @@ abstract class PhabricatorApplicationConfigOptions extends Phobject {
|
||||||
return $groups;
|
return $groups;
|
||||||
}
|
}
|
||||||
|
|
||||||
final public static function loadAllOptions() {
|
final public static function loadAllOptions($external_only = false) {
|
||||||
$groups = self::loadAll();
|
$groups = self::loadAll($external_only);
|
||||||
|
|
||||||
$options = array();
|
$options = array();
|
||||||
foreach ($groups as $group) {
|
foreach ($groups as $group) {
|
||||||
|
|
|
@ -13,4 +13,10 @@ final class PhabricatorConfigDefaultSource
|
||||||
$this->setSource(new PhabricatorConfigDictionarySource($options));
|
$this->setSource(new PhabricatorConfigDictionarySource($options));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public function loadExternalOptions() {
|
||||||
|
$options = PhabricatorApplicationConfigOptions::loadAllOptions(true);
|
||||||
|
$options = mpull($options, 'getDefault');
|
||||||
|
$this->setKeys($options);
|
||||||
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
11
src/infrastructure/env/PhabricatorEnv.php
vendored
11
src/infrastructure/env/PhabricatorEnv.php
vendored
|
@ -132,9 +132,9 @@ final class PhabricatorEnv {
|
||||||
$stack = new PhabricatorConfigStackSource();
|
$stack = new PhabricatorConfigStackSource();
|
||||||
self::$sourceStack = $stack;
|
self::$sourceStack = $stack;
|
||||||
|
|
||||||
$stack->pushSource(
|
$defaultSource = id(new PhabricatorConfigDefaultSource())
|
||||||
id(new PhabricatorConfigDefaultSource())
|
->setName(pht('Global Default'));
|
||||||
->setName(pht('Global Default')));
|
$stack->pushSource($defaultSource);
|
||||||
|
|
||||||
$env = self::getSelectedEnvironmentName();
|
$env = self::getSelectedEnvironmentName();
|
||||||
$stack->pushSource(
|
$stack->pushSource(
|
||||||
|
@ -152,6 +152,11 @@ final class PhabricatorEnv {
|
||||||
phutil_load_library($library);
|
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 {
|
try {
|
||||||
$stack->pushSource(
|
$stack->pushSource(
|
||||||
id(new PhabricatorConfigDatabaseSource('default'))
|
id(new PhabricatorConfigDatabaseSource('default'))
|
||||||
|
|
Loading…
Reference in a new issue