1
0
Fork 0
mirror of https://we.phorge.it/source/phorge.git synced 2024-11-22 14:52:41 +01:00

Add explicit mysql.port configuration

See: https://github.com/facebook/phabricator/pull/356

Reviewed by: epriestley
This commit is contained in:
Levi Jackson 2013-07-14 16:02:12 -07:00 committed by epriestley
parent a0084bbb0d
commit d27e7c52b2
7 changed files with 28 additions and 3 deletions

View file

@ -170,11 +170,12 @@ return array(
// The password to use when connecting to MySQL. // The password to use when connecting to MySQL.
'mysql.pass' => '', 'mysql.pass' => '',
// The MySQL server to connect to. If you want to connect to a different // The MySQL server to connect to.
// port than the default (which is 3306), specify it in the hostname
// (e.g., db.example.com:1234).
'mysql.host' => 'localhost', 'mysql.host' => 'localhost',
// If you want to connect to a different port than the default (which is 3306)
'mysql.port' => '3306',
// Phabricator supports PHP extensions MySQL and MySQLi. It is possible to // Phabricator supports PHP extensions MySQL and MySQLi. It is possible to
// implement also other access mechanism (e.g. PDO_MySQL). The class must // implement also other access mechanism (e.g. PDO_MySQL). The class must
// extend AphrontMySQLDatabaseConnectionBase. // extend AphrontMySQLDatabaseConnectionBase.

View file

@ -25,6 +25,7 @@ $conf = PhabricatorEnv::newObjectFromConfig(
$default_user = $conf->getUser(); $default_user = $conf->getUser();
$default_host = $conf->getHost(); $default_host = $conf->getHost();
$default_port = $conf->getPort();
$default_namespace = PhabricatorLiskDAO::getDefaultStorageNamespace(); $default_namespace = PhabricatorLiskDAO::getDefaultStorageNamespace();
try { try {
@ -82,6 +83,7 @@ $api = new PhabricatorStorageManagementAPI();
$api->setUser($args->getArg('user')); $api->setUser($args->getArg('user'));
PhabricatorEnv::overrideConfig('mysql.user', $args->getArg('user')); PhabricatorEnv::overrideConfig('mysql.user', $args->getArg('user'));
$api->setHost($default_host); $api->setHost($default_host);
$api->setPort($default_port);
$api->setPassword($password); $api->setPassword($password);
$api->setNamespace($args->getArg('namespace')); $api->setNamespace($args->getArg('namespace'));

View file

@ -12,6 +12,7 @@ final class PhabricatorSetupCheckDatabase extends PhabricatorSetupCheck {
$conn_user = $conf->getUser(); $conn_user = $conf->getUser();
$conn_pass = $conf->getPassword(); $conn_pass = $conf->getPassword();
$conn_host = $conf->getHost(); $conn_host = $conf->getHost();
$conn_port = $conf->getPort();
ini_set('mysql.connect_timeout', 2); ini_set('mysql.connect_timeout', 2);
@ -19,6 +20,7 @@ final class PhabricatorSetupCheckDatabase extends PhabricatorSetupCheck {
'user' => $conn_user, 'user' => $conn_user,
'pass' => $conn_pass, 'pass' => $conn_pass,
'host' => $conn_host, 'host' => $conn_host,
'port' => $conn_port,
'database' => null, 'database' => null,
); );
@ -40,6 +42,7 @@ final class PhabricatorSetupCheckDatabase extends PhabricatorSetupCheck {
->setMessage($message) ->setMessage($message)
->setIsFatal(true) ->setIsFatal(true)
->addRelatedPhabricatorConfig('mysql.host') ->addRelatedPhabricatorConfig('mysql.host')
->addRelatedPhabricatorConfig('mysql.port')
->addRelatedPhabricatorConfig('mysql.user') ->addRelatedPhabricatorConfig('mysql.user')
->addRelatedPhabricatorConfig('mysql.pass'); ->addRelatedPhabricatorConfig('mysql.pass');
return; return;

View file

@ -69,6 +69,10 @@ final class PhabricatorMySQLConfigOptions
"this namespace if you want. Normally, you should not do this ". "this namespace if you want. Normally, you should not do this ".
"unless you are developing Phabricator and using namespaces to ". "unless you are developing Phabricator and using namespaces to ".
"separate multiple sandbox datasets.")), "separate multiple sandbox datasets.")),
$this->newOption('mysql.port', 'string', null)
->setLocked(true)
->setDescription(
pht("MySQL port to use when connecting to the database.")),
); );
} }

View file

@ -29,6 +29,10 @@ final class DefaultDatabaseConfigurationProvider
return PhabricatorEnv::getEnvConfig('mysql.host'); return PhabricatorEnv::getEnvConfig('mysql.host');
} }
public function getPort() {
return PhabricatorEnv::getEnvConfig('mysql.port');
}
public function getDatabase() { public function getDatabase() {
if (!$this->getDao()) { if (!$this->getDao()) {
return null; return null;

View file

@ -110,6 +110,7 @@ abstract class PhabricatorLiskDAO extends LiskDAO {
'user' => $conf->getUser(), 'user' => $conf->getUser(),
'pass' => $conf->getPassword(), 'pass' => $conf->getPassword(),
'host' => $conf->getHost(), 'host' => $conf->getHost(),
'port' => $conf->getPort(),
'database' => $conf->getDatabase(), 'database' => $conf->getDatabase(),
'retries' => 3, 'retries' => 3,
), ),

View file

@ -45,6 +45,15 @@ final class PhabricatorStorageManagementAPI {
return $this->host; return $this->host;
} }
public function setPort($port) {
$this->port = $port;
return $this;
}
public function getPort() {
return $this->port;
}
public function getDatabaseName($fragment) { public function getDatabaseName($fragment) {
return $this->namespace.'_'.$fragment; return $this->namespace.'_'.$fragment;
} }
@ -74,6 +83,7 @@ final class PhabricatorStorageManagementAPI {
'user' => $this->user, 'user' => $this->user,
'pass' => $this->password, 'pass' => $this->password,
'host' => $this->host, 'host' => $this->host,
'port' => $this->port,
'database' => $fragment 'database' => $fragment
? $database ? $database
: null, : null,