Commit 05f65d6b authored by Adrian Rossouw's avatar Adrian Rossouw

Fixed site renaming.

parent fefa37ae
......@@ -13,48 +13,68 @@
/**
* Make sure we have a valid site being renamed, and that the site being renamed exists
*/
function drush_provision_drupal_provision_rename_validate($url = null, $new_url = null, $platform = null) {
function drush_provision_drupal_provision_rename_validate($new_url = null, $platform = null) {
drush_bootstrap(DRUSH_BOOTSTRAP_DRUPAL_SITE);
}
/**
* Make a backup before making any changes, and add extract the file we are restoring from
*/
function drush_provision_drupal_pre_provision_rename($url, $new_url, $platform = null) {
drush_invoke('provision-backup', $url);
function drush_provision_drupal_pre_provision_rename($new_url, $platform = null) {
/* Set offline mode to true and re-generate the settings.php. This will write a
* $conf['site_offline'] = 1; to the settings.php
*/
drush_log(dt("Putting site under maintenance"));
drush_set_option('site_offline', 1);
_provision_drupal_create_settings_file();
drush_invoke('provision-backup');
}
/**
* Remove the extracted site directory
*/
function drush_provision_drupal_pre_provision_rename_rollback($url, $new_url, $platform = null) {
provision_file()->unlink(drush_get_option('backup_file'))
->succeed('Removed unused rename site package')
->fail('Could not remove unused site package');
function drush_provision_drupal_pre_provision_rename_rollback($new_url, $platform = null) {
// Set site_offline to false and regenerate the config
drush_log(dt("Bringing site out of maintenance"));
drush_set_option('site_offline', 0);
$success = provision_file()->unlink(drush_get_option('backup_file'))
->succeed('Removed unused migration site package')
->fail('Could not remove unused migration site package');
d()->service('http')->create_site_config();
d()->service('http')->parse_configs();
}
/**
* Switch the rename directories around now that we have the new db installed
*/
function drush_provision_drupal_provision_rename($url, $new_url, $platform = null) {
function drush_provision_drupal_provision_rename($new_url, $platform = null) {
drush_set_option('old_platform', d()->platform->name);
$options = d()->options;
$options['uri'] = ltrim($new_url, '@');
$options['platform'] = (isset($platform)) ? $platform : $options['platform'];
$options['aliases'] = array();
$options['redirection'] = 0;
drush_backend_invoke_args('provision-save', array($new_url), $options);
# note that we reset the aliases so they don't conflict with the original site
drush_backend_invoke('provision-deploy', array(
$new_url,
drush_get_option('backup_file'),
'root' => $platform,
'aliases' => drush_get_option('aliases'),
'redirection' => drush_get_option('redirection'),
'web_host' => drush_get_option('web_host'),
'web_ip' => drush_get_option('web_ip'),
'db_host' => drush_get_option('db_host')
));
provision_backend_invoke($new_url, 'provision-deploy', array(drush_get_option('backup_file')));
if (!drush_get_error()) {
provision_backend_invoke($new_url, 'provision-verify');
}
}
function drush_provision_drupal_post_provision_rename($url) {
/* @TODO: sort this out.. to do a drush_backend_invoke means
* that drush_save_config($context) gets called.. somehow?
* and it tries to write to the drushrc.php of the old site
* that's been deleted
*/
drush_invoke("provision-delete", $url);
function drush_provision_drupal_post_provision_rename($new_url) {
drush_set_option('installed', FALSE);
// we remove the aliases even if redirection is enabled as a precaution
// if redirection is enabled, keep silent about errors
_provision_drupal_delete_aliases(d()->aliases);
_provision_recursive_delete(d()->site_path);
d()->service('http')->sync(d()->site_path);
// remove the existing alias
$config = new provisionConfig_drushrc_alias(d()->name);
$config->unlink();
}
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