function pm_update_packages

8.0.x pm_update_packages($update_info, $tmpfile)
6.x pm_update_packages($update_info, $tmpfile)
7.x pm_update_packages($update_info, $tmpfile)
3.x pm_update_packages($projects)
4.x pm_update_packages($update_info, $tmpfile)
5.x pm_update_packages($update_info, $tmpfile)
master pm_update_packages($update_info, $tmpfile)

Update projects according to an array of releases and print the release notes for each project, following interactive confirmation from the user.


$update_info: An array of projects from the update service, with an additional array key candidate_version that specifies the version to be installed.

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


commands/pm/, line 249
pm-updatecode command implementation.


function pm_update_packages($update_info, $tmpfile) {
  $release_info = drush_get_engine('release_info');

  $drupal_root = drush_get_context('DRUSH_DRUPAL_ROOT');

  $print = '';
  $status = array();
  foreach ($update_info as $project) {
    $print .= $project['title'] . " [" . $project['name'] . '-' . $project['candidate_version'] . "], ";
    $status[$project['status']] = $project['status'];
  // We print the list of the projects that need to be updated.
  if (isset($status[DRUSH_UPDATESTATUS_NOT_SECURE])) {
    if (isset($status[DRUSH_UPDATESTATUS_NOT_CURRENT])) {
      $title = (dt('Security and code updates will be made to the following projects:'));
    else {
      $title = (dt('Security updates will be made to the following projects:'));
  else {
    $title = (dt('Code updates will be made to the following projects:'));
  $print = "$title " . (substr($print, 0, strlen($print) -2));
  file_put_contents($tmpfile, "\n\n$print\n\n", FILE_APPEND);

  // Print the release notes for projects to be updated.
  if (drush_get_option('notes', FALSE)) {
    drush_print('Obtaining release notes for above projects...');
    #TODO# Build the $request array from info in $project.
    foreach (array_keys($update_info) as $project_name) {
      $request = pm_parse_request($project_name);
      $release_info->get($request)->getReleaseNotes(NULL, TRUE, $tmpfile);

  // We print some warnings before the user confirms the update.
  if (drush_get_option('no-backup', FALSE)) {
    drush_print(dt("Note: You have selected to not store backups."));
  else {
    drush_print(dt("Note: A backup of your project will be stored to backups directory if it is not managed by a supported version control system."));
    drush_print(dt('Note: If you have made any modifications to any file that belongs to one of these projects, you will have to migrate those modifications after updating.'));
  if (!drush_confirm(dt('Do you really want to continue with the update process?'))) {
    return drush_user_abort();

  // Now we start the actual updating.
  foreach ($update_info as $project) {
    if (empty($project['path'])) {
      return drush_set_error('DRUSH_PM_UPDATING_NO_PROJECT_PATH', dt('The !project project path is not available, perhaps the !type is enabled but has been deleted from disk.', array('!project' => $project['name'], '!type' => $project['project_type'])));
    drush_log(dt('Starting to update !project code at !dir...', array('!project' => $project['title'], '!dir' => $project['path'])));

    // Define and check the full path to project directory and base (parent) directory.
    $project['full_project_path'] = $drupal_root . '/' . $project['path'];
    if (stripos($project['path'], $project['project_type']) === FALSE || !is_dir($project['full_project_path'])) {
      return drush_set_error('DRUSH_PM_UPDATING_PATH_NOT_FOUND', dt('The !project directory could not be found within the !types directory at !full_project_path, perhaps the project is enabled but has been deleted from disk.', array('!project' => $project['name'], '!type' => $project['project_type'], '!full_project_path' => $project['full_project_path'])));
    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)) {
      return FALSE;

    // Run update on one project.
    if (pm_update_project($project, $version_control) === FALSE) {
      return FALSE;
    pm_update_finish($project, $version_control);

  return TRUE;