Commit 5a101afa authored by Adrian Rossouw's avatar Adrian Rossouw

I am now capable of installing new Drupal 6 sites.

parent 31c8af22
......@@ -121,7 +121,7 @@ class provisionService_db extends provisionService {
* Generate a new mysql database and user account for the specified credentials
*/
function create_site_database($url) {
$creds = $this->create_site_credentials($url);
$creds = $this->generate_site_credentials($url);
extract($creds);
......@@ -139,6 +139,7 @@ class provisionService_db extends provisionService {
drush_log("Could not GRANT user access.", 'warning');
}
$this->create_database($db_name);
$status = $this->database_exists($db_name);
if ($status) {
......@@ -218,7 +219,7 @@ class provisionService_db extends provisionService {
$creds['db_host'] = drush_set_option('db_host', drush_get_option('db_host'), 'site');
$creds['db_passwd'] = drush_set_option('db_passwd', provision_password(), 'site');
$creds['db_name'] = drush_set_option('db_name', $this->suggest_db_name($url), 'site');
$creds['db_user'] = drush_set_option('db_user', $db_name, 'site');
$creds['db_user'] = drush_set_option('db_user', $creds['db_name'], 'site');
$creds['db_grant_host'] = $this->grant_host();
return $creds;
......@@ -268,7 +269,7 @@ class provisionService_db extends provisionService {
return FALSE;
}
function grant_host($db_host, $web_ip, $web_host) {
function grant_host() {
return 'localhost';
}
......@@ -321,7 +322,8 @@ class provisionService_db_pdo extends provisionService_db {
$this->query_callback($args, TRUE);
$query = preg_replace_callback(PROVISION_QUERY_REGEXP, array($this, 'query_callback'), $query);
print_r($query);
drush_log($query);
try {
$result = $this->conn->query($query);
}
......
......@@ -46,21 +46,23 @@ class provisionService_db_mysql extends provisionService_db_pdo {
function revoke($name, $username, $host = '') {
$host = ($host) ? $host : '%';
$success = provision_db_query("REVOKE ALL PRIVILEGES ON `%s`.* FROM `%s`@`%s`", $name, $username, $host);
$success = $this->query("REVOKE ALL PRIVILEGES ON `%s`.* FROM `%s`@`%s`", $name, $username, $host);
// check if there are any privileges left for the user
$grants = provision_db_query("SHOW GRANTS FOR `%s`@`%s`", $username, $host);
$grants = $this->query("SHOW GRANTS FOR `%s`@`%s`", $username, $host);
$grant_found = FALSE;
while ($grant = provision_db_fetch_array($grants)) {
// those are empty grants: just the user line
if (!preg_match("/^GRANT USAGE ON /", array_pop($grant))) {
// real grant, we shouldn't remove the user
$grant_found = TRUE;
break;
if ($grants) {
while ($grant = $grants->fetch()) {
// those are empty grants: just the user line
if (!preg_match("/^GRANT USAGE ON /", array_pop($grant))) {
// real grant, we shouldn't remove the user
$grant_found = TRUE;
break;
}
}
}
if (!$grant_found) {
$success = provision_db_query("DROP USER `%s`@`%s`", $username, $host) && $success;
$success = $this->query("DROP USER `%s`@`%s`", $username, $host) && $success;
}
return $success;
}
......@@ -81,8 +83,8 @@ class provisionService_db_mysql extends provisionService_db_pdo {
}
function grant_host($db_host, $web_ip, $web_host) {
$result = provision_db_result(provision_db_query("select current_user()"));
function grant_host() {
$result = $this->query("select current_user()")->fetchColumn(0);
preg_match('/^.*@(.*)$/', $result, $matches);
return $matches[1];
}
......
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