mirror of
https://we.phorge.it/source/phorge.git
synced 2024-11-28 17:52:43 +01:00
Standardize mysql.configuration-provider
Summary: NOTE: BC break! Test Plan: / Reviewers: epriestley Reviewed By: epriestley CC: aran, nh Differential Revision: https://secure.phabricator.com/D2130
This commit is contained in:
parent
6c1e2cd8b2
commit
2c8e6f99bd
13 changed files with 73 additions and 44 deletions
|
@ -106,6 +106,10 @@ return array(
|
||||||
|
|
||||||
// -- MySQL --------------------------------------------------------------- //
|
// -- MySQL --------------------------------------------------------------- //
|
||||||
|
|
||||||
|
// Class providing database configuration. It must implement
|
||||||
|
// DatabaseConfigurationProvider.
|
||||||
|
'mysql.configuration-provider' => 'DefaultDatabaseConfigurationProvider',
|
||||||
|
|
||||||
// The username to use when connecting to MySQL.
|
// The username to use when connecting to MySQL.
|
||||||
'mysql.user' => 'root',
|
'mysql.user' => 'root',
|
||||||
|
|
||||||
|
|
|
@ -61,7 +61,7 @@ if (empty($options['f']) && empty($options['d'])) {
|
||||||
$next_version = isset($options['v']) ? (int)$options['v'] : null;
|
$next_version = isset($options['v']) ? (int)$options['v'] : null;
|
||||||
$max_version = isset($options['m']) ? (int)$options['m'] : null;
|
$max_version = isset($options['m']) ? (int)$options['m'] : null;
|
||||||
|
|
||||||
$conf = DatabaseConfigurationProvider::getConfiguration();
|
$conf = PhabricatorEnv::newObjectFromConfig('mysql.configuration-provider');
|
||||||
|
|
||||||
if ($options['u']) {
|
if ($options['u']) {
|
||||||
$conn_user = $options['u'];
|
$conn_user = $options['u'];
|
||||||
|
|
|
@ -190,7 +190,8 @@ phutil_register_library_map(array(
|
||||||
'DarkConsoleServicesPlugin' => 'aphront/console/plugin/services',
|
'DarkConsoleServicesPlugin' => 'aphront/console/plugin/services',
|
||||||
'DarkConsoleXHProfPlugin' => 'aphront/console/plugin/xhprof',
|
'DarkConsoleXHProfPlugin' => 'aphront/console/plugin/xhprof',
|
||||||
'DarkConsoleXHProfPluginAPI' => 'aphront/console/plugin/xhprof/api',
|
'DarkConsoleXHProfPluginAPI' => 'aphront/console/plugin/xhprof/api',
|
||||||
'DatabaseConfigurationProvider' => 'applications/base/storage/configuration',
|
'DatabaseConfigurationProvider' => 'applications/base/storage/configuration/base',
|
||||||
|
'DefaultDatabaseConfigurationProvider' => 'applications/base/storage/configuration/default',
|
||||||
'DifferentialAction' => 'applications/differential/constants/action',
|
'DifferentialAction' => 'applications/differential/constants/action',
|
||||||
'DifferentialActionHasNoEffectException' => 'applications/differential/exception/noeffect',
|
'DifferentialActionHasNoEffectException' => 'applications/differential/exception/noeffect',
|
||||||
'DifferentialAddCommentView' => 'applications/differential/view/addcomment',
|
'DifferentialAddCommentView' => 'applications/differential/view/addcomment',
|
||||||
|
@ -1134,6 +1135,7 @@ phutil_register_library_map(array(
|
||||||
'DarkConsoleRequestPlugin' => 'DarkConsolePlugin',
|
'DarkConsoleRequestPlugin' => 'DarkConsolePlugin',
|
||||||
'DarkConsoleServicesPlugin' => 'DarkConsolePlugin',
|
'DarkConsoleServicesPlugin' => 'DarkConsolePlugin',
|
||||||
'DarkConsoleXHProfPlugin' => 'DarkConsolePlugin',
|
'DarkConsoleXHProfPlugin' => 'DarkConsolePlugin',
|
||||||
|
'DefaultDatabaseConfigurationProvider' => 'DatabaseConfigurationProvider',
|
||||||
'DifferentialActionHasNoEffectException' => 'DifferentialException',
|
'DifferentialActionHasNoEffectException' => 'DifferentialException',
|
||||||
'DifferentialAddCommentView' => 'AphrontView',
|
'DifferentialAddCommentView' => 'AphrontView',
|
||||||
'DifferentialAffectedPath' => 'DifferentialDAO',
|
'DifferentialAffectedPath' => 'DifferentialDAO',
|
||||||
|
|
|
@ -1,16 +0,0 @@
|
||||||
<?php
|
|
||||||
/**
|
|
||||||
* This file is automatically generated. Lint this module to rebuild it.
|
|
||||||
* @generated
|
|
||||||
*/
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
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');
|
|
|
@ -0,0 +1,30 @@
|
||||||
|
<?php
|
||||||
|
|
||||||
|
/*
|
||||||
|
* Copyright 2012 Facebook, Inc.
|
||||||
|
*
|
||||||
|
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||||
|
* you may not use this file except in compliance with the License.
|
||||||
|
* You may obtain a copy of the License at
|
||||||
|
*
|
||||||
|
* http://www.apache.org/licenses/LICENSE-2.0
|
||||||
|
*
|
||||||
|
* Unless required by applicable law or agreed to in writing, software
|
||||||
|
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||||
|
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||||
|
* See the License for the specific language governing permissions and
|
||||||
|
* limitations under the License.
|
||||||
|
*/
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @stable
|
||||||
|
*/
|
||||||
|
interface DatabaseConfigurationProvider {
|
||||||
|
|
||||||
|
public function __construct(LiskDAO $dao = null, $mode = 'r');
|
||||||
|
public function getUser();
|
||||||
|
public function getPassword();
|
||||||
|
public function getHost();
|
||||||
|
public function getDatabase();
|
||||||
|
|
||||||
|
}
|
|
@ -0,0 +1,10 @@
|
||||||
|
<?php
|
||||||
|
/**
|
||||||
|
* This file is automatically generated. Lint this module to rebuild it.
|
||||||
|
* @generated
|
||||||
|
*/
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
phutil_require_source('DatabaseConfigurationProvider.php');
|
|
@ -16,14 +16,13 @@
|
||||||
* limitations under the License.
|
* limitations under the License.
|
||||||
*/
|
*/
|
||||||
|
|
||||||
/**
|
final class DefaultDatabaseConfigurationProvider
|
||||||
* TODO: Can we final this?
|
implements DatabaseConfigurationProvider {
|
||||||
*/
|
|
||||||
class DatabaseConfigurationProvider {
|
|
||||||
private $dao;
|
private $dao;
|
||||||
private $mode;
|
private $mode;
|
||||||
|
|
||||||
public function __construct(LiskDAO $dao, $mode) {
|
public function __construct(LiskDAO $dao = null, $mode = 'r') {
|
||||||
$this->dao = $dao;
|
$this->dao = $dao;
|
||||||
$this->mode = $mode;
|
$this->mode = $mode;
|
||||||
}
|
}
|
||||||
|
@ -41,6 +40,9 @@ class DatabaseConfigurationProvider {
|
||||||
}
|
}
|
||||||
|
|
||||||
public function getDatabase() {
|
public function getDatabase() {
|
||||||
|
if (!$this->getDao()) {
|
||||||
|
return null;
|
||||||
|
}
|
||||||
return 'phabricator_'.$this->getDao()->getApplicationName();
|
return 'phabricator_'.$this->getDao()->getApplicationName();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -48,18 +50,4 @@ class DatabaseConfigurationProvider {
|
||||||
return $this->dao;
|
return $this->dao;
|
||||||
}
|
}
|
||||||
|
|
||||||
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;
|
|
||||||
}
|
|
||||||
|
|
||||||
}
|
}
|
|
@ -0,0 +1,13 @@
|
||||||
|
<?php
|
||||||
|
/**
|
||||||
|
* This file is automatically generated. Lint this module to rebuild it.
|
||||||
|
* @generated
|
||||||
|
*/
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
phutil_require_module('phabricator', 'applications/base/storage/configuration/base');
|
||||||
|
phutil_require_module('phabricator', 'infrastructure/env');
|
||||||
|
|
||||||
|
|
||||||
|
phutil_require_source('DefaultDatabaseConfigurationProvider.php');
|
|
@ -66,10 +66,9 @@ abstract class PhabricatorLiskDAO extends LiskDAO {
|
||||||
* @task config
|
* @task config
|
||||||
*/
|
*/
|
||||||
public function establishLiveConnection($mode) {
|
public function establishLiveConnection($mode) {
|
||||||
$conf_provider = PhabricatorEnv::getEnvConfig(
|
$conf = PhabricatorEnv::newObjectFromConfig(
|
||||||
'mysql.configuration_provider', 'DatabaseConfigurationProvider');
|
'mysql.configuration-provider',
|
||||||
PhutilSymbolLoader::loadClass($conf_provider);
|
array($this, $mode));
|
||||||
$conf = newv($conf_provider, array($this, $mode));
|
|
||||||
|
|
||||||
return PhabricatorEnv::newObjectFromConfig(
|
return PhabricatorEnv::newObjectFromConfig(
|
||||||
'mysql.implementation',
|
'mysql.implementation',
|
||||||
|
|
|
@ -9,7 +9,6 @@
|
||||||
phutil_require_module('phabricator', 'infrastructure/env');
|
phutil_require_module('phabricator', 'infrastructure/env');
|
||||||
phutil_require_module('phabricator', 'storage/lisk/dao');
|
phutil_require_module('phabricator', 'storage/lisk/dao');
|
||||||
|
|
||||||
phutil_require_module('phutil', 'symbols');
|
|
||||||
phutil_require_module('phutil', 'utils');
|
phutil_require_module('phutil', 'utils');
|
||||||
|
|
||||||
|
|
||||||
|
|
1
src/infrastructure/env/PhabricatorEnv.php
vendored
1
src/infrastructure/env/PhabricatorEnv.php
vendored
|
@ -57,6 +57,7 @@ final class PhabricatorEnv {
|
||||||
'PhabricatorOAuthRegistrationController',
|
'PhabricatorOAuthRegistrationController',
|
||||||
'mysql.implementation' => 'AphrontMySQLDatabaseConnectionBase',
|
'mysql.implementation' => 'AphrontMySQLDatabaseConnectionBase',
|
||||||
'differential.attach-task-class' => 'DifferentialTasksAttacher',
|
'differential.attach-task-class' => 'DifferentialTasksAttacher',
|
||||||
|
'mysql.configuration-provider' => 'DatabaseConfigurationProvider',
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -455,7 +455,7 @@ final class PhabricatorSetup {
|
||||||
|
|
||||||
self::writeHeader("MySQL DATABASE & STORAGE CONFIGURATION");
|
self::writeHeader("MySQL DATABASE & STORAGE CONFIGURATION");
|
||||||
|
|
||||||
$conf = DatabaseConfigurationProvider::getConfiguration();
|
$conf = PhabricatorEnv::newObjectFromConfig('mysql.configuration-provider');
|
||||||
$conn_user = $conf->getUser();
|
$conn_user = $conf->getUser();
|
||||||
$conn_pass = $conf->getPassword();
|
$conn_pass = $conf->getPassword();
|
||||||
$conn_host = $conf->getHost();
|
$conn_host = $conf->getHost();
|
||||||
|
|
|
@ -6,7 +6,6 @@
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
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/queryfx');
|
phutil_require_module('phabricator', 'storage/queryfx');
|
||||||
|
|
Loading…
Reference in a new issue