function _drush_upgrade_preserve_modules

4.x upgrade.drush.inc _drush_upgrade_preserve_modules($destination_core)

Preserve existing modules. Move them out of the way prior to updatedb of Drupal core. We will move them back afterwards.

1 call to _drush_upgrade_preserve_modules()
drush_upgrade_site_upgrade in commands/core/upgrade.drush.inc
Main command hook for site-upgrade.

File

commands/core/upgrade.drush.inc, line 664
Refine your Drupal major version upgrade.

Code

function _drush_upgrade_preserve_modules($destination_core) {
  $modules_preserve['root'] = $destination_core;
  $modules_preserve['list'] = array();

  $moduledir_list = array(
    'sites_all_modules' => $destination_core . '/sites/all/modules',
    'sites_conf_path_modules' => $destination_core . conf_path() . '/modules',
  );

  foreach ($moduledir_list as $moduledir_name => $moduledir) {
    if (is_dir($moduledir)) {
      $preserved_moduledir = drush_tempnam($moduledir_name, dirname($moduledir));
      $result = drush_move_dir($moduledir, $preserved_moduledir, TRUE);
      if ($result) {
        $modules_preserve['list'][$moduledir] = $preserved_moduledir;
        drush_log(dt('Move !src to !dest prior to updatedb on Drupal core.', array('!src' => $moduledir, '!dest' => $preserved_moduledir)), 'ok');
      }
      else {
        return drush_set_error('DRUSH_MODULE_PRESERVE_FAILED', dt('Failed to move !src to !dest.', array('!src' => $moduledir, '!dest' => $preserved_moduledir)));
      }
    }
  }

  drush_set_context('DRUSH_MODULES_PRESERVE', $modules_preserve);
  return TRUE;
}