function drush_pm_updatecode

8.0.x drush_pm_updatecode()
6.x drush_pm_updatecode()
7.x drush_pm_updatecode()
3.x drush_pm_updatecode()
4.x drush_pm_updatecode()
5.x drush_pm_updatecode()
master drush_pm_updatecode()

Command callback. Displays update status info and allows to update installed projects. Pass specific projects as arguments, otherwise we update all that have candidate releases.

This command prompts for confirmation before updating, so it is safe to run just to check on In this case, say at the confirmation prompt.


commands/pm/, line 10


function drush_pm_updatecode() {
  // We don't provide for other options here, so we supply an explicit path.
  drush_include_engine('update_info', 'drupal', NULL, DRUSH_BASE_PATH . '/commands/pm/update_info');

  // Get update status information.
  $projects = _pm_get_update_info();

  // Get specific requests
  $requests = func_get_args();

  // Parse out project name and version
  $requests = pm_parse_project_version($requests);

  // Preprocess releases
  if (!empty($requests)) {
    // Force update projects where a specific version is reqested
    foreach ($requests as $name => $request) {
      if (!isset($projects[$name])) {
        // Catch projects with no version data (common for CVS checkouts
        // if you don't have CVS deploy installed).
        $projects[$name] = array(
          'title' => $name,
          'existing_version' => 'Unknown',
          'status' => DRUSH_PM_NO_VERSION,
      else if (!empty($request['version'])) {
        // Match the requested release
        $release = pm_get_release($request, $projects[$name]);
        if (!$release) {
          $projects[$name]['status'] = DRUSH_PM_REQUESTED_NOT_FOUND;
        else if ($release['version'] == $projects[$name]['existing_version']) {
          $projects[$name]['status'] = DRUSH_PM_REQUESTED_CURRENT;
        else {
          $projects[$name]['status'] = DRUSH_PM_REQUESTED_UPDATE;
        // Set the candidate version to the requested release
        $projects[$name]['candidate_version'] = $release['version'];

  // Table headers.
  $rows[] = array(dt('Name'), dt('Installed version'), dt('Proposed version'), dt('Status'));

  // Process releases, notifying user of status and building a list of proposed updates
  $updateable = pm_project_filter($projects, $rows);

  // Pipe preparation
  if (drush_get_context('DRUSH_PIPE')) {
    $pipe = "";
    foreach ($projects as $project) {
      $pipe .= $project['name'] . " ";
      $pipe .= $project['existing_version'] . " ";
      $pipe .= $project['candidate_version'] . " ";
      $pipe .= str_replace(' ', '-', pm_update_filter($project)) . "\n";
    // Automatically curtail update process if in pipe mode
    $updateable = FALSE;

  $last = pm_update_last_check();
  drush_print(dt('Update information last refreshed: ') . ($last ? format_date($last) : dt('Never')));
  drush_print(dt("Update status information on all installed and enabled Drupal projects:"));
  drush_print_table($rows, TRUE);

  // If specific project updates were requested then remove releases for all others
  if (!empty($requests)) {
    foreach ($updateable as $name => $project) {
      if (!isset($requests[$name])) {

  if (isset($updateable['drupal'])) {
    $drupal_project = $updateable['drupal'];
    $module_list = array_keys($projects);

    // We can only upgrade drupal core if there are no non-core
    // modules enabled.  _pm_update_core will disable the
    // modules passed in, and insure that they are enabled again
    // when we're done.  However, each run of pm-updatecode will
    // update -either- core, or the non-core modules; never both.
    // This simplifies rollbacks.
    if (empty($updateable)) {
      return _pm_update_core($drupal_project, $module_list);
    // If there are modules other than drupal core enabled, then go
    // ahead and print instructions on how to upgrade core.  We will
    // also continue, allowing the user to upgrade any upgradable
    // modules if desired.
    else {
      drush_print(dt("NOTE: A code update for the Drupal core is available."));
      if (drush_get_context('DRUSH_PM_UPDATE_ALL', FALSE)) {
        drush_print(dt("Drupal core will be updated after all of the non-core modules are updated.\n"));
      else {
        drush_print(dt("Drupal core cannot be updated at the same time that non-core modules are updated.  In order to update Drupal core with this tool, first allow the update of the modules listed above to complet, and then run pm-updatecode again.\n"));
      drush_set_context('DRUSH_PM_CORE_UPDATE_AVAILABLE', TRUE);

  if (empty($updateable)) {
    return drush_log(dt('No code updates available.'), 'ok');

  // Offer to update to the identified releases
  return pm_update_packages($updateable);