Commit aac08b4a authored by Adrian Rossouw's avatar Adrian Rossouw

A bevy of subtle fixes. Primarily #597750 because we no longer 'do' site id....

A bevy of subtle fixes. Primarily #597750 because we no longer 'do' site id. Also fixed restore which left you with a broken site, and handled the fact that
the drush_config_file function would only give us the right value when we were bootstrapped to that level.

this meant we couldnt regenerate the site drushrc.php until we'd bootstrapped to drupal_configuration, which meant during restore it would always use the old values.

Also when the restore task finished, the save_site_config malarky would end up writing the old values over the correct ones.
parent 390760da
......@@ -54,37 +54,16 @@ class provisionService_db extends provisionService {
}
/**
* Find a viable database name, based on available information.
*
* This function exists solely to work past mysql's database name restrictions.
* As mysql also does not have the ability to rename databases, it is completely
* possible that sites will be running with derivative names on the same server,
* until the upgrade / restore process is completed.
*
* TODO: abstract this properly.
* Find a viable database name, based on the site's uri.
*/
function suggest_db_name() {
if ($sid = drush_get_option('site_id')) {
$suggest_base = drush_get_option('aegir_db_prefix', 'site_') . $sid;
}
elseif ($name = drush_get_option('db_name')) {
// consider the verified database name if no site id was provided
//
// we strip out eventual _N suffixes before finding a new db name
// this is necessary because we may already have gone through this
// process (in a migration) and had a _N suffix added
$suggest_base = preg_replace('/_\d+$/', '', $name);
}
else {
// This is a last option, and not ideal: base the db name on the
// site name
//
// Provision only users will trigger this mostly.
$suggest_base = substr(str_replace(array('.', '-'), '' , ereg_replace('^www\.', '', drush_get_option('uri'))), 0, 14);
}
$suggest[] = $suggest_base;
$uri = d($this->context)->uri;
$suggest_base = str_replace(array('.', '-'), '' , ereg_replace('^www\.', '', $uri));
$suggest[] = substr($suggest_base, 0, 16);
for ($i = 0; $i < 100; $i++) {
$suggest[] = $suggest_base .'_'. $i;
$suggest[] = sprintf("%s_%d", substr($suggest_base, 0, 16 - strlen( (string) $i) ), $i);
}
foreach ($suggest as $option) {
......@@ -95,7 +74,6 @@ class provisionService_db extends provisionService {
drush_set_error('PROVISION_CREATE_DB_FAILED', dt("Could not find a free database names after 100 attempts"));
return false;
}
/**
......
......@@ -4,15 +4,19 @@ function drush_db_provision_deploy_validate() {
d()->service('db')->connect();
}
function drush_db_provision_deploy() {
function drush_db_pre_provision_deploy() {
d()->service('db')->create_site_database();
d()->service('db')->import_site_database();
}
function drush_db_provision_deploy_rollback() {
function drush_db_pre_provision_deploy_rollback() {
d()->service('db')->destroy_site_database();
}
function drush_db_provision_deploy() {
d()->service('db')->import_site_database();
}
// Rollback doesn't apply here yet. Unless we trigger a deploy of the first dump
// made. Which could go on infinitely if something is really long.
function drush_db_post_provision_deploy() {
......
......@@ -61,14 +61,19 @@ function drush_provision_drupal_pre_provision_deploy($backup_file) {
->status();
if ($swapped) {
drush_set_option('site_dirs_swapped', TRUE);
_provision_drupal_create_settings_file();
}
else {
return false;
}
}
// We have already created a new database. Save the info to the config files.
provision_prepare_environment();
provision_save_site_data();
// Load the newly created information, including re-loading the new db creds.
drush_bootstrap(DRUSH_BOOTSTRAP_DRUPAL_SITE);
_provision_drupal_create_settings_file();
$site_packages = drush_get_option('packages', array(), 'site');
$profiles = array_keys($site_packages['profiles']);
......@@ -115,27 +120,19 @@ function drush_provision_drupal_pre_provision_deploy_rollback() {
_provision_drupal_create_settings_file();
provision_save_site_data();
}
}
if (provision_file()->exists(drush_get_option('extract_path'))->status()) {
_provision_recursive_delete(drush_get_option('extract_path'));
}
}
function drush_provision_drupal_provision_deploy() {
_provision_drupal_maintain_aliases();
_provision_drupal_create_directories();
}
function drush_provision_drupal_post_provision_deploy() {
provision_prepare_environment();
_provision_drupal_create_directories();
_provision_drupal_create_settings_file();
provision_save_site_data();
// call the drush updatedb command.
provision_backend_invoke(d()->name, 'updatedb');
// We should be able to fully load Drupal now.
......
......@@ -39,6 +39,7 @@ function drush_provision_drupal_provision_restore($restore_file) {
provision_backend_invoke(d()->name, 'provision-deploy', array(drush_get_option('restore_file')));
if (!drush_get_error()) {
provision_backend_invoke(d()->name, 'provision-verify');
drush_set_option('installed', false);
}
}
......@@ -260,6 +260,10 @@ class provisionConfig_drushrc_server extends provisionConfig_drushrc {
class provisionConfig_drushrc_platform extends provisionConfig_drushrc {
protected $context_name = 'drupal';
public $description = 'Platform Drush configuration file';
function filename() {
return $this->root . '/drushrc.php';
}
}
/**
......@@ -269,5 +273,10 @@ class provisionConfig_drushrc_site extends provisionConfig_drushrc {
protected $context_name = 'site';
public $template = 'provision_drushrc_site.tpl.php';
public $description = 'Site Drush configuration file';
function filename() {
return $this->site_path . '/drushrc.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