Skip to content

Commit d27e7c5

Browse files
Levi Jacksonepriestley
Levi Jackson
authored and
epriestley
committedJul 14, 2013
Add explicit mysql.port configuration
See: phacility#356 Reviewed by: epriestley
1 parent a0084bb commit d27e7c5

File tree

7 files changed

+28
-3
lines changed

7 files changed

+28
-3
lines changed
 

‎conf/default.conf.php

+4-3
Original file line numberDiff line numberDiff line change
@@ -170,11 +170,12 @@
170170
// The password to use when connecting to MySQL.
171171
'mysql.pass' => '',
172172

173-
// The MySQL server to connect to. If you want to connect to a different
174-
// port than the default (which is 3306), specify it in the hostname
175-
// (e.g., db.example.com:1234).
173+
// The MySQL server to connect to.
176174
'mysql.host' => 'localhost',
177175

176+
// If you want to connect to a different port than the default (which is 3306)
177+
'mysql.port' => '3306',
178+
178179
// Phabricator supports PHP extensions MySQL and MySQLi. It is possible to
179180
// implement also other access mechanism (e.g. PDO_MySQL). The class must
180181
// extend AphrontMySQLDatabaseConnectionBase.

‎scripts/sql/manage_storage.php

+2
Original file line numberDiff line numberDiff line change
@@ -25,6 +25,7 @@
2525

2626
$default_user = $conf->getUser();
2727
$default_host = $conf->getHost();
28+
$default_port = $conf->getPort();
2829
$default_namespace = PhabricatorLiskDAO::getDefaultStorageNamespace();
2930

3031
try {
@@ -82,6 +83,7 @@
8283
$api->setUser($args->getArg('user'));
8384
PhabricatorEnv::overrideConfig('mysql.user', $args->getArg('user'));
8485
$api->setHost($default_host);
86+
$api->setPort($default_port);
8587
$api->setPassword($password);
8688
$api->setNamespace($args->getArg('namespace'));
8789

‎src/applications/config/check/PhabricatorSetupCheckDatabase.php

+3
Original file line numberDiff line numberDiff line change
@@ -12,13 +12,15 @@ protected function executeChecks() {
1212
$conn_user = $conf->getUser();
1313
$conn_pass = $conf->getPassword();
1414
$conn_host = $conf->getHost();
15+
$conn_port = $conf->getPort();
1516

1617
ini_set('mysql.connect_timeout', 2);
1718

1819
$config = array(
1920
'user' => $conn_user,
2021
'pass' => $conn_pass,
2122
'host' => $conn_host,
23+
'port' => $conn_port,
2224
'database' => null,
2325
);
2426

@@ -40,6 +42,7 @@ protected function executeChecks() {
4042
->setMessage($message)
4143
->setIsFatal(true)
4244
->addRelatedPhabricatorConfig('mysql.host')
45+
->addRelatedPhabricatorConfig('mysql.port')
4346
->addRelatedPhabricatorConfig('mysql.user')
4447
->addRelatedPhabricatorConfig('mysql.pass');
4548
return;

‎src/applications/config/option/PhabricatorMySQLConfigOptions.php

+4
Original file line numberDiff line numberDiff line change
@@ -69,6 +69,10 @@ public function getOptions() {
6969
"this namespace if you want. Normally, you should not do this ".
7070
"unless you are developing Phabricator and using namespaces to ".
7171
"separate multiple sandbox datasets.")),
72+
$this->newOption('mysql.port', 'string', null)
73+
->setLocked(true)
74+
->setDescription(
75+
pht("MySQL port to use when connecting to the database.")),
7276
);
7377
}
7478

‎src/infrastructure/storage/configuration/DefaultDatabaseConfigurationProvider.php

+4
Original file line numberDiff line numberDiff line change
@@ -29,6 +29,10 @@ public function getHost() {
2929
return PhabricatorEnv::getEnvConfig('mysql.host');
3030
}
3131

32+
public function getPort() {
33+
return PhabricatorEnv::getEnvConfig('mysql.port');
34+
}
35+
3236
public function getDatabase() {
3337
if (!$this->getDao()) {
3438
return null;

‎src/infrastructure/storage/lisk/PhabricatorLiskDAO.php

+1
Original file line numberDiff line numberDiff line change
@@ -110,6 +110,7 @@ public function establishLiveConnection($mode) {
110110
'user' => $conf->getUser(),
111111
'pass' => $conf->getPassword(),
112112
'host' => $conf->getHost(),
113+
'port' => $conf->getPort(),
113114
'database' => $conf->getDatabase(),
114115
'retries' => 3,
115116
),

‎src/infrastructure/storage/management/PhabricatorStorageManagementAPI.php

+10
Original file line numberDiff line numberDiff line change
@@ -45,6 +45,15 @@ public function getHost() {
4545
return $this->host;
4646
}
4747

48+
public function setPort($port) {
49+
$this->port = $port;
50+
return $this;
51+
}
52+
53+
public function getPort() {
54+
return $this->port;
55+
}
56+
4857
public function getDatabaseName($fragment) {
4958
return $this->namespace.'_'.$fragment;
5059
}
@@ -74,6 +83,7 @@ public function getConn($fragment) {
7483
'user' => $this->user,
7584
'pass' => $this->password,
7685
'host' => $this->host,
86+
'port' => $this->port,
7787
'database' => $fragment
7888
? $database
7989
: null,

0 commit comments

Comments
 (0)
Failed to load comments.