Commit 955d3c4c authored by Adrian Rossouw's avatar Adrian Rossouw

Support db ports other than the default (3306). We now always specify the port...

Support db ports other than the default (3306). We now always specify the port in the db url. #503444
parent fc3be694
......@@ -261,6 +261,10 @@ class provisionService_db_pdo extends provisionService_db {
function init() {
parent::init();
$this->dsn = sprintf("%s:host=%s", $this->PDO_type, $this->creds['host']);
if ($this->has_port) {
$this->dsn = "{$this->dsn};port={$this->server->db_port}";
}
}
function connect() {
......
......@@ -88,7 +88,12 @@ class provisionService_db_mysql extends provisionService_db_pdo {
}
function grant_host(provisionServer $server) {
$server->shell_exec('mysql -u intntnllyInvalid -h ' . escapeshellarg($this->server->remote_host));
$command = sprintf('mysql -u intntnllyInvalid -h %s -P %s',
escapeshellarg($this->server->remote_host),
escapeshellarg($this->server->db_port));
$server->shell_exec($command);
if (preg_match("/Access denied for user 'intntnllyInvalid'@'([^']*)'/", implode('', drush_shell_exec_output()), $match)) {
return $match[1];
}
......@@ -125,7 +130,8 @@ class provisionService_db_mysql extends provisionService_db_pdo {
host=%s
user=%s
password=%s
', $db_host, $db_user, $db_passwd);
port=%s
', $db_host, $db_user, $db_passwd, $this->server->db_port);
$stdin_spec = (!is_null($dump_file)) ? array("file", $dump_file, "r") : array("pipe", "r");
......
......@@ -136,7 +136,7 @@ class provisionConfig_drupal_settings extends provisionConfig {
}
$cloaked = $this->owner->service('http')->cloaked_db_creds();
foreach (array('db_type', 'db_user', 'db_passwd', 'db_host', 'db_name') as $key) {
foreach (array('db_type', 'db_user', 'db_passwd', 'db_host', 'db_name', 'db_port') as $key) {
$this->creds[$key] = ($cloaked) ? "\$_SERVER[{$key}]" : urldecode($this->data[$key]);
}
......@@ -609,7 +609,7 @@ function provision_parse_info_file($filename) {
* potentially of other sites' settings.php in a multisite set-up.
*/
function provision_prepare_environment() {
$fields = array('db_type', 'db_host', 'db_user', 'db_passwd', 'db_name');
$fields = array('db_type', 'db_host', 'db_user', 'db_passwd', 'db_name', 'db_port');
foreach ($fields as $key) {
$_SERVER[$key] = drush_get_option($key, null, 'site');
}
......
......@@ -14,12 +14,14 @@
'username' => "<?php print $this->creds['db_user']; ?>",
'password' => "<?php print $this->creds['db_passwd']; ?>",
'host' => "<?php print $this->creds['db_host']; ?>",
'port' => "<?php print $this->creds['db_port']; ?>",
);
$db_url['default'] = "<?php print strtr("%db_type://%db_user:%db_passwd@%db_host/%db_name", array(
$db_url['default'] = "<?php print strtr("%db_type://%db_user:%db_passwd@%db_host:%db_port/%db_name", array(
'%db_type' => $this->creds['db_type'],
'%db_user' => $this->creds['db_user'],
'%db_passwd' => $this->creds['db_passwd'],
'%db_host' => $this->creds['db_host'],
'%db_port' => $this->creds['db_port'],
'%db_name' => $this->creds['db_name'])); ?>";
......
<?php include('provision_drushrc.tpl.php'); ?>
# Aegir additions
<?php foreach (array('db_type', 'db_host', 'db_user', 'db_passwd', 'db_name') as $key) { ?>
<?php foreach (array('db_type', 'db_port', 'db_host', 'db_user', 'db_passwd', 'db_name') as $key) { ?>
$_SERVER['<?php print $key; ?>'] = $options['<?php print $key; ?>'];
<?php } ?>
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment