mirror of
https://we.phorge.it/source/phorge.git
synced 2024-11-10 00:42:41 +01:00
Use DatabaseConfigurationProvider to get DB info
Summary: remove accessing the db config info directly. Use DatabaseConfigurationProvider instead. Also fixed a minor issue where different number of newlines are output in PhabricatorSetup.php's output. Test Plan: executed upgrade_schema.php; executed PhabricatorSetup.php by setting 'phabricator.setup' to true. Reviewed By: epriestley Reviewers: epriestley CC: aran, jungejason, epriestley Differential Revision: 443
This commit is contained in:
parent
bb7e175dc2
commit
f2efdd07a7
5 changed files with 31 additions and 10 deletions
|
@ -59,15 +59,16 @@ if (empty($options['f'])) {
|
||||||
// Use always the version from the commandline if it is defined
|
// Use always the version from the commandline if it is defined
|
||||||
$next_version = isset($options['v']) ? (int)$options['v'] : null;
|
$next_version = isset($options['v']) ? (int)$options['v'] : null;
|
||||||
|
|
||||||
// TODO: Get this stuff from DatabaseConfigurationProvider?
|
$conf = DatabaseConfigurationProvider::getConfiguration();
|
||||||
|
|
||||||
if ($options['u']) {
|
if ($options['u']) {
|
||||||
$conn_user = $options['u'];
|
$conn_user = $options['u'];
|
||||||
$conn_pass = $options['p'];
|
$conn_pass = $options['p'];
|
||||||
} else {
|
} else {
|
||||||
$conn_user = PhabricatorEnv::getEnvConfig('mysql.user');
|
$conn_user = $conf->getUser();
|
||||||
$conn_pass = PhabricatorEnv::getEnvConfig('mysql.pass');
|
$conn_pass = $conf->getPassword();
|
||||||
}
|
}
|
||||||
$conn_host = PhabricatorEnv::getEnvConfig('mysql.host');
|
$conn_host = $conf->getHost();
|
||||||
|
|
||||||
// Split out port information, since the command-line client requires a
|
// Split out port information, since the command-line client requires a
|
||||||
// separate flag for the port.
|
// separate flag for the port.
|
||||||
|
|
|
@ -48,4 +48,15 @@ class DatabaseConfigurationProvider {
|
||||||
final protected function getMode() {
|
final protected function getMode() {
|
||||||
return $this->mode;
|
return $this->mode;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public static function getConfiguration() {
|
||||||
|
// Get DB info. Note that we are using a dummy PhabricatorUser object in
|
||||||
|
// creating the DatabaseConfigurationProvider, which is not used at all.
|
||||||
|
$conf_provider = PhabricatorEnv::getEnvConfig(
|
||||||
|
'mysql.configuration_provider', 'DatabaseConfigurationProvider');
|
||||||
|
PhutilSymbolLoader::loadClass($conf_provider);
|
||||||
|
$conf = newv($conf_provider, array(new PhabricatorUser(), 'r'));
|
||||||
|
return $conf;
|
||||||
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
|
@ -6,7 +6,11 @@
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
phutil_require_module('phabricator', 'applications/people/storage/user');
|
||||||
phutil_require_module('phabricator', 'infrastructure/env');
|
phutil_require_module('phabricator', 'infrastructure/env');
|
||||||
|
|
||||||
|
phutil_require_module('phutil', 'symbols');
|
||||||
|
phutil_require_module('phutil', 'utils');
|
||||||
|
|
||||||
|
|
||||||
phutil_require_source('DatabaseConfigurationProvider.php');
|
phutil_require_source('DatabaseConfigurationProvider.php');
|
||||||
|
|
|
@ -68,7 +68,7 @@ class PhabricatorSetup {
|
||||||
} else {
|
} else {
|
||||||
if (trim($stdout) == 'YES') {
|
if (trim($stdout) == 'YES') {
|
||||||
self::write(" okay pcntl is available from the command line.\n");
|
self::write(" okay pcntl is available from the command line.\n");
|
||||||
self::write("[OKAY] All extensions OKAY\n\n");
|
self::write("[OKAY] All extensions OKAY\n");
|
||||||
} else {
|
} else {
|
||||||
self::write(" warn pcntl is not available!\n");
|
self::write(" warn pcntl is not available!\n");
|
||||||
self::write("[WARN] *** WARNING *** pcntl extension not available. ".
|
self::write("[WARN] *** WARNING *** pcntl extension not available. ".
|
||||||
|
@ -120,7 +120,7 @@ class PhabricatorSetup {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
self::write("[OKAY] All submodules OKAY.");
|
self::write("[OKAY] All submodules OKAY.\n");
|
||||||
|
|
||||||
self::writeHeader("BASIC CONFIGURATION");
|
self::writeHeader("BASIC CONFIGURATION");
|
||||||
|
|
||||||
|
@ -241,9 +241,10 @@ class PhabricatorSetup {
|
||||||
|
|
||||||
self::writeHeader("MySQL DATABASE CONFIGURATION");
|
self::writeHeader("MySQL DATABASE CONFIGURATION");
|
||||||
|
|
||||||
$conn_user = PhabricatorEnv::getEnvConfig('mysql.user');
|
$conf = DatabaseConfigurationProvider::getConfiguration();
|
||||||
$conn_pass = PhabricatorEnv::getEnvConfig('mysql.pass');
|
$conn_user = $conf->getUser();
|
||||||
$conn_host = PhabricatorEnv::getEnvConfig('mysql.host');
|
$conn_pass = $conf->getPassword();
|
||||||
|
$conn_host = $conf->getHost();
|
||||||
|
|
||||||
$timeout = ini_get('mysql.connect_timeout');
|
$timeout = ini_get('mysql.connect_timeout');
|
||||||
if ($timeout > 5) {
|
if ($timeout > 5) {
|
||||||
|
|
|
@ -4,6 +4,9 @@
|
||||||
* @generated
|
* @generated
|
||||||
*/
|
*/
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
phutil_require_module('phabricator', 'applications/base/storage/configuration');
|
||||||
phutil_require_module('phabricator', 'infrastructure/env');
|
phutil_require_module('phabricator', 'infrastructure/env');
|
||||||
phutil_require_module('phabricator', 'infrastructure/setup/sql');
|
phutil_require_module('phabricator', 'infrastructure/setup/sql');
|
||||||
phutil_require_module('phabricator', 'storage/connection/mysql');
|
phutil_require_module('phabricator', 'storage/connection/mysql');
|
||||||
|
@ -15,4 +18,5 @@ phutil_require_module('phutil', 'moduleutils');
|
||||||
phutil_require_module('phutil', 'parser/uri');
|
phutil_require_module('phutil', 'parser/uri');
|
||||||
phutil_require_module('phutil', 'utils');
|
phutil_require_module('phutil', 'utils');
|
||||||
|
|
||||||
|
|
||||||
phutil_require_source('PhabricatorSetup.php');
|
phutil_require_source('PhabricatorSetup.php');
|
Loading…
Reference in a new issue