Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

adding support for port parameter for the database #356

Closed
wants to merge 6 commits into from
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
7 changes: 4 additions & 3 deletions conf/default.conf.php
Original file line number Diff line number Diff line change
Expand Up @@ -170,11 +170,12 @@
// The password to use when connecting to MySQL.
'mysql.pass' => '',

// The MySQL server to connect to. If you want to connect to a different
// port than the default (which is 3306), specify it in the hostname
// (e.g., db.example.com:1234).
// The MySQL server to connect to.
'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
// implement also other access mechanism (e.g. PDO_MySQL). The class must
// extend AphrontMySQLDatabaseConnectionBase.
Expand Down
2 changes: 2 additions & 0 deletions scripts/sql/manage_storage.php
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,7 @@

$default_user = $conf->getUser();
$default_host = $conf->getHost();
$default_port = $conf->getPort();
$default_namespace = PhabricatorLiskDAO::getDefaultStorageNamespace();

try {
Expand Down Expand Up @@ -82,6 +83,7 @@
$api->setUser($args->getArg('user'));
PhabricatorEnv::overrideConfig('mysql.user', $args->getArg('user'));
$api->setHost($default_host);
$api->setPort($default_port);
$api->setPassword($password);
$api->setNamespace($args->getArg('namespace'));

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -12,13 +12,15 @@ protected function executeChecks() {
$conn_user = $conf->getUser();
$conn_pass = $conf->getPassword();
$conn_host = $conf->getHost();
$conn_port = $conf->getPort();

ini_set('mysql.connect_timeout', 2);

$config = array(
'user' => $conn_user,
'pass' => $conn_pass,
'host' => $conn_host,
'port' => $conn_port,
'database' => null,
);

Expand All @@ -40,6 +42,7 @@ protected function executeChecks() {
->setMessage($message)
->setIsFatal(true)
->addRelatedPhabricatorConfig('mysql.host')
->addRelatedPhabricatorConfig('mysql.port')
->addRelatedPhabricatorConfig('mysql.user')
->addRelatedPhabricatorConfig('mysql.pass');
return;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -69,6 +69,10 @@ public function getOptions() {
"this namespace if you want. Normally, you should not do this ".
"unless you are developing Phabricator and using namespaces to ".
"separate multiple sandbox datasets.")),
$this->newOption('mysql.port', 'string', null)
->setLocked(true)
->setDescription(
pht("MySQL port to use when connecting to the database.")),
);
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,10 @@ public function getHost() {
return PhabricatorEnv::getEnvConfig('mysql.host');
}

public function getPort() {
return PhabricatorEnv::getEnvConfig('mysql.port');
}

public function getDatabase() {
if (!$this->getDao()) {
return null;
Expand Down
1 change: 1 addition & 0 deletions src/infrastructure/storage/lisk/PhabricatorLiskDAO.php
Original file line number Diff line number Diff line change
Expand Up @@ -110,6 +110,7 @@ public function establishLiveConnection($mode) {
'user' => $conf->getUser(),
'pass' => $conf->getPassword(),
'host' => $conf->getHost(),
'port' => $conf->getPort(),
'database' => $conf->getDatabase(),
'retries' => 3,
),
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -45,6 +45,15 @@ public function getHost() {
return $this->host;
}

public function setPort($port) {
$this->port = $port;
return $this;
}

public function getPort() {
return $this->port;
}

public function getDatabaseName($fragment) {
return $this->namespace.'_'.$fragment;
}
Expand Down Expand Up @@ -74,6 +83,7 @@ public function getConn($fragment) {
'user' => $this->user,
'pass' => $this->password,
'host' => $this->host,
'port' => $this->port,
'database' => $fragment
? $database
: null,
Expand Down