mirror of
https://we.phorge.it/source/phorge.git
synced 2024-11-21 22:32: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
|
||||
$next_version = isset($options['v']) ? (int)$options['v'] : null;
|
||||
|
||||
// TODO: Get this stuff from DatabaseConfigurationProvider?
|
||||
$conf = DatabaseConfigurationProvider::getConfiguration();
|
||||
|
||||
if ($options['u']) {
|
||||
$conn_user = $options['u'];
|
||||
$conn_pass = $options['p'];
|
||||
} else {
|
||||
$conn_user = PhabricatorEnv::getEnvConfig('mysql.user');
|
||||
$conn_pass = PhabricatorEnv::getEnvConfig('mysql.pass');
|
||||
$conn_user = $conf->getUser();
|
||||
$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
|
||||
// separate flag for the port.
|
||||
|
|
|
@ -48,4 +48,15 @@ class DatabaseConfigurationProvider {
|
|||
final protected function getMode() {
|
||||
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('phutil', 'symbols');
|
||||
phutil_require_module('phutil', 'utils');
|
||||
|
||||
|
||||
phutil_require_source('DatabaseConfigurationProvider.php');
|
||||
|
|
|
@ -68,7 +68,7 @@ class PhabricatorSetup {
|
|||
} else {
|
||||
if (trim($stdout) == 'YES') {
|
||||
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 {
|
||||
self::write(" warn pcntl is not available!\n");
|
||||
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");
|
||||
|
||||
|
@ -241,9 +241,10 @@ class PhabricatorSetup {
|
|||
|
||||
self::writeHeader("MySQL DATABASE CONFIGURATION");
|
||||
|
||||
$conn_user = PhabricatorEnv::getEnvConfig('mysql.user');
|
||||
$conn_pass = PhabricatorEnv::getEnvConfig('mysql.pass');
|
||||
$conn_host = PhabricatorEnv::getEnvConfig('mysql.host');
|
||||
$conf = DatabaseConfigurationProvider::getConfiguration();
|
||||
$conn_user = $conf->getUser();
|
||||
$conn_pass = $conf->getPassword();
|
||||
$conn_host = $conf->getHost();
|
||||
|
||||
$timeout = ini_get('mysql.connect_timeout');
|
||||
if ($timeout > 5) {
|
||||
|
|
|
@ -4,6 +4,9 @@
|
|||
* @generated
|
||||
*/
|
||||
|
||||
|
||||
|
||||
phutil_require_module('phabricator', 'applications/base/storage/configuration');
|
||||
phutil_require_module('phabricator', 'infrastructure/env');
|
||||
phutil_require_module('phabricator', 'infrastructure/setup/sql');
|
||||
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', 'utils');
|
||||
|
||||
phutil_require_source('PhabricatorSetup.php');
|
||||
|
||||
phutil_require_source('PhabricatorSetup.php');
|
||||
|
|
Loading…
Reference in a new issue