Commit a2601b4a authored by juampynr's avatar juampynr Committed by Steven Jones

Issue #1261006 - Follow up: Tidy docs and add missing parent method.

parent 1d0ff080
...@@ -25,8 +25,8 @@ function db_drush_help($section) { ...@@ -25,8 +25,8 @@ function db_drush_help($section) {
return dt('Unable to connect to database server.'); return dt('Unable to connect to database server.');
case 'error:PROVISION_CREATE_DB_FAILED' : case 'error:PROVISION_CREATE_DB_FAILED' :
return dt('Unable to create new databases.'); return dt('Unable to create new databases.');
case 'error:PROVISION_CREATE_DB_USER_FAILED' : case 'error:PROVISION_GRANT_DB_USER_FAILED' :
return dt('Unable to create new database users.'); return dt('Unable to grant privileges to database users.');
case 'error:PROVISION_DROP_DB_FAILED' : case 'error:PROVISION_DROP_DB_FAILED' :
return dt('Unable to drop database.'); return dt('Unable to drop database.');
} }
...@@ -71,10 +71,10 @@ class provisionService_db extends provisionService { ...@@ -71,10 +71,10 @@ class provisionService_db extends provisionService {
drush_set_error('PROVISION_CREATE_DB_FAILED'); drush_set_error('PROVISION_CREATE_DB_FAILED');
} }
if ($this->can_grant_privileges()) { if ($this->can_grant_privileges()) {
drush_log(dt('Provision can create database users.'), 'message');; drush_log(dt('Provision can grant privileges on database users.'), 'message');;
} }
else { else {
drush_set_error('PROVISION_CREATE_DB_USER_FAILED'); drush_set_error('PROVISION_GRANT_DB_USER_FAILED');
} }
} else { } else {
drush_set_error('PROVISION_CONNECT_DB_FAILED'); drush_set_error('PROVISION_CONNECT_DB_FAILED');
...@@ -235,7 +235,11 @@ class provisionService_db extends provisionService { ...@@ -235,7 +235,11 @@ class provisionService_db extends provisionService {
return FALSE; return FALSE;
} }
function can_create_database() { function can_create_database() {
return FALSE;
}
function can_grant_privileges() {
return FALSE; return FALSE;
} }
......
...@@ -36,17 +36,21 @@ class provisionService_db_mysql extends provisionService_db_pdo { ...@@ -36,17 +36,21 @@ class provisionService_db_mysql extends provisionService_db_pdo {
} }
/** /**
* Verifies that Aegir can grant privileges to a user on a database * Verifies that provision can grant privileges to a user on a database.
* *
* @return * @return
* boolean TRUE if the check was successful * TRUE if the check was successful.
*/ */
function can_grant_privileges() { function can_grant_privileges() {
$test = drush_get_option('aegir_db_prefix', 'site_'); $dbname = drush_get_option('aegir_db_prefix', 'site_');
$status = $this->grant($test, $test . 'user', $test . 'password', $test . 'host'); $user = $dbname . '_user';
$password = $dbname . '_password';
$host = $dbname . '_host';
if ($status = $this->grant($dbname, $user, $password, $host)) {
$this->revoke($dbname, $user, $host);
}
return $status; return $status;
} }
function grant($name, $username, $password, $host = '') { function grant($name, $username, $password, $host = '') {
$host = ($host) ? $host : '%'; $host = ($host) ? $host : '%';
......
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