Commit 1cbfe6b2 authored by Adrian Rossouw's avatar Adrian Rossouw

We now force all the host names lowercase, but drush_is_localhost is case sensitive.

parent 757625c9
......@@ -39,6 +39,7 @@ class provisionService_db extends provisionService {
}
function init() {
parent::init();
$this->server->setProperty('master_db');
$this->creds = array_map('urldecode', parse_url($this->server->master_db));
......@@ -174,6 +175,7 @@ class provisionService_db extends provisionService {
//TODO - this should not be here at all
$creds['db_type'] = drush_set_option('db_type', $db_type, 'site');
$creds['db_host'] = drush_set_option('db_host', $this->server->remote_host, 'site');
$creds['db_port'] = drush_set_option('db_port', $this->server->db_port, 'site');
$creds['db_passwd'] = drush_set_option('db_passwd', provision_password(), 'site');
$creds['db_name'] = drush_set_option('db_name', $this->suggest_db_name(), 'site');
$creds['db_user'] = drush_set_option('db_user', $creds['db_name'], 'site');
......@@ -184,7 +186,7 @@ class provisionService_db extends provisionService {
function fetch_site_credentials() {
$creds = array();
$keys = array('db_type', 'db_user', 'db_name', 'db_host', 'db_passwd');
$keys = array('db_type', 'db_port', 'db_user', 'db_name', 'db_host', 'db_passwd');
foreach ($keys as $key) {
$creds[$key] = drush_get_option($key, '', 'site');
}
......@@ -256,7 +258,7 @@ class provisionService_db_pdo extends provisionService_db {
function init() {
parent::init();
$this->dsn = sprintf("%s:host=%s", $this->PDO_type, drush_is_local_host($this->creds['host']) ? 'localhost' : $this->creds['host']);
$this->dsn = sprintf("%s:host=%s", $this->PDO_type, provision_is_local_host($this->creds['host']) ? 'localhost' : $this->creds['host']);
}
function connect() {
......
......@@ -7,6 +7,11 @@
class provisionService_db_mysql extends provisionService_db_pdo {
public $PDO_type = 'mysql';
protected $has_port = TRUE;
function default_port() {
return 3306;
}
function database_exists($name) {
$result = $this->query("SHOW DATABASES LIKE '%s'", $name);
......
......@@ -406,7 +406,7 @@ class provisionServer extends provisionEnvironment {
* out and error.
*/
function shell_exec($command) {
if (drush_is_local_host($this->remote_host)) {
if (provision_is_local_host($this->remote_host)) {
return drush_shell_exec(escapeshellcmd($command));
}
else {
......@@ -423,7 +423,7 @@ class provisionServer extends provisionEnvironment {
* Exclude sites/*, except sites/*.
*/
function sync($path = NULL, $exclude_sites = FALSE) {
if (!drush_is_local_host($this->remote_host)) {
if (!provision_is_local_host($this->remote_host)) {
if (is_null($path)) {
$path = $this->config_path;
}
......
......@@ -25,6 +25,26 @@ drush_errors_on();
* values, that allow sites to be more easily moved between different provisioned platforms.
*/
/**
* Make a determination whether or not the given
* host is local or not.
*
* We needed to fork this from drush core to handle the case sensitivity in host names.
*
* @param host
* A hostname, 'localhost' or '127.0.0.1'.
* @return
* True if the host is local.
*/
function provision_is_local_host($host) {
$host = strtolower($host);
// In order for this to work right, you must use 'localhost' or '127.0.0.1'
// or the machine returned by 'uname -n' for your 'remote-host' entry in
// your site alias. Note that sometimes 'uname -n' does not return the
// correct value. To fix it, put the correct hostname in /etc/hostname
// and then run 'hostname -F /etc/hostname'.
return ($host == 'localhost') || ($host == '127.0.0.1') || ($host == strtolower(php_uname('n')));
}
/**
* Save modified options to the drushrc.php file
......
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