function _pm_update_core

8.0.x updatecode.pm.inc _pm_update_core(&$project, $tmpfile)
6.x updatecode.pm.inc _pm_update_core(&$project, $tmpfile)
7.x updatecode.pm.inc _pm_update_core(&$project, $tmpfile)
3.x updatecode.pm.inc _pm_update_core(&$project, $module_list = array())
4.x updatecode.pm.inc _pm_update_core(&$project, $tmpfile)
5.x updatecode.pm.inc _pm_update_core(&$project, $tmpfile)
master updatecode.pm.inc _pm_update_core(&$project, $tmpfile)

Update drupal core, following interactive confirmation from the user.

Parameters

$project: The drupal project information from the drupal.org update service, copied from $update_info['drupal']. @see drush_pm_updatecode.

1 call to _pm_update_core()
drush_pm_updatecode in commands/pm/updatecode.pm.inc
Command callback. Displays update status info and allows to update installed projects.

File

commands/pm/updatecode.pm.inc, line 128
pm-updatecode command implementation.

Code

function _pm_update_core(&$project, $tmpfile) {
  $release_info = drush_get_engine('release_info');

  drush_print(dt('Code updates will be made to drupal core.'));
  drush_print(dt("WARNING:  Updating core will discard any modifications made to Drupal core files, most noteworthy among these are .htaccess and robots.txt.  If you have made any modifications to these files, please back them up before updating so that you can re-create your modifications in the updated version of the file."));
  drush_print(dt("Note: Updating core can potentially break your site. It is NOT recommended to update production sites without prior testing."));
  drush_print();
  if (drush_get_option('notes', FALSE)) {
    drush_print('Obtaining release notes for above projects...');
    #TODO# Build the $request array from info in $project.
    $request = pm_parse_request('drupal');
    $release_info->get($request)->getReleaseNotes(NULL, TRUE, $tmpfile);
  }
  if (!drush_confirm(dt('Do you really want to continue?'))) {
    drush_print(dt('Rolling back all changes. Run again with --no-core to update modules only.'));
    return drush_user_abort();
  }

  $drupal_root = drush_get_context('DRUSH_DRUPAL_ROOT');

  // We need write permission on $drupal_root.
  if (!is_writable($drupal_root)) {
    return drush_set_error('DRUSH_PATH_NO_WRITABLE', dt('Drupal root path is not writable.'));
  }

  // Create a directory 'core' if it does not already exist.
  $project['path'] = 'drupal-' . $project['candidate_version'];
  $project['full_project_path'] = $drupal_root . '/' . $project['path'];
  if (!is_dir($project['full_project_path'])) {
    drush_mkdir($project['full_project_path']);
  }

  // Create a list of directories to exclude from the update process.
  // On Drupal >=8 skip also directories in the document root.
  if (drush_drupal_major_version() >= 8) {
    $skip_list = array(
      'sites',
      $project['path'],
      'modules',
      'profiles',
      'themes',
    );
  }
  else {
    $skip_list = array('sites', $project['path']);
  }
  // Add non-writable directories: we can't move them around.
  // We will also use $items_to_test later for $version_control check.
  $items_to_test = drush_scan_directory($drupal_root, '/.*/', array_merge(array('.', '..'), $skip_list), 0, FALSE, 'basename', 0, TRUE);
  foreach (array_keys($items_to_test) as $item) {
    if (is_dir($item) && !is_writable($item)) {
      $skip_list[] = $item;
      unset($items_to_test[$item]);
    }
    elseif (is_link($item)) {
      $skip_list[] = $item;
      unset($items_to_test[$item]);
    }
  }
  $project['skip_list'] = $skip_list;

  // Move all files and folders in $drupal_root to the new 'core' directory
  // except for the items in the skip list
  _pm_update_move_files($drupal_root, $project['full_project_path'], $project['skip_list']);

  // Set a context variable to indicate that rollback should reverse
  // the _pm_update_move_files above.
  drush_set_context('DRUSH_PM_DRUPAL_CORE', $project);

  if (!$version_control = drush_pm_include_version_control($project['full_project_path'])) {
    return FALSE;
  }

  // Check we have a version control system, and it clears its pre-flight.
  if (!$version_control->pre_update($project, $items_to_test)) {
    return FALSE;
  }

  // Update core.
  if (pm_update_project($project, $version_control) === FALSE) {
    return FALSE;
  }

  // Take the updated files in the 'core' directory that have been updated,
  // and move all except for the items in the skip list back to
  // the drupal root.
  _pm_update_move_files($project['full_project_path'], $drupal_root, $project['skip_list']);
  drush_delete_dir($project['full_project_path']);
  $project['full_project_path'] = $drupal_root;

  // If there is a backup target, then find items
  // in the backup target that do not exist at the
  // drupal root.  These are to be moved back.
  if (array_key_exists('backup_target', $project)) {
    _pm_update_move_files($project['backup_target'], $drupal_root, $project['skip_list'], FALSE);
    _pm_update_move_files($project['backup_target'] . '/profiles', $drupal_root . '/profiles', array('default'), FALSE);
  }

  pm_update_finish($project, $version_control);

  return TRUE;
}