function drush_update_do_one

8.0.x update.inc drush_update_do_one($module, $number, $dependency_map, &$context)
8.0.x update_7.inc drush_update_do_one($module, $number, $dependency_map, &$context)
6.x update.inc drush_update_do_one($module, $number, $dependency_map, &$context)
6.x update_7.inc drush_update_do_one($module, $number, $dependency_map, &$context)
7.x update.inc drush_update_do_one($module, $number, $dependency_map, &$context)
7.x update_7.inc drush_update_do_one($module, $number, $dependency_map, &$context)
3.x update_7.inc drush_update_do_one($module, $number, $dependency_map, &$context)
4.x update.inc drush_update_do_one($module, $number, $dependency_map, &$context)
5.x update.inc drush_update_do_one($module, $number, $dependency_map, &$context)
5.x update_7.inc drush_update_do_one($module, $number, $dependency_map, &$context)
master update.inc drush_update_do_one($module, $number, $dependency_map, &$context)
master update_7.inc drush_update_do_one($module, $number, $dependency_map, &$context)

Perform one update and store the results which will later be displayed on the finished page.

An update function can force the current and all later updates for this module to abort by returning a $ret array with an element like: $ret['#abort'] = array('success' => FALSE, 'query' => 'What went wrong'); The schema version will not be updated in this case, and all the aborted updates will continue to appear on update.php as updates that have not yet been run.

Parameters

$module: The module whose update will be run.

$number: The update number to run.

$context: The batch context array

2 string references to 'drush_update_do_one'
drush_update_batch in commands/core/drupal/update.inc
Start the database update batch process.
drush_update_batch in commands/core/drupal/update_7.inc
Start the database update batch process.

File

commands/core/drupal/update_7.inc, line 54
Update.php for provisioned sites. This file is a derivative of the standard drupal update.php, which has been modified to allow being run from the command line.

Code

function drush_update_do_one($module, $number, $dependency_map, &$context) {
  $function = $module . '_update_' . $number;

  // If this update was aborted in a previous step, or has a dependency that
  // was aborted in a previous step, go no further.
  if (!empty($context['results']['#abort']) && array_intersect($context['results']['#abort'], array_merge($dependency_map, array($function)))) {
    return;
  }

  $context['log'] = FALSE;

  $ret = array();
  if (function_exists($function)) {
    try {
      if ($context['log']) {
        Database::startLog($function);
      }

      drush_log("Executing " . $function);
      $ret['results']['query'] = $function($context['sandbox']);

      // If the update hook returned a status message (common in batch updates),
      // show it to the user.
      if ($ret['results']['query']) {
        drush_log($ret['results']['query'], 'ok');
      }

      $ret['results']['success'] = TRUE;
    }
    // @TODO We may want to do different error handling for different exception
    // types, but for now we'll just print the message.
    catch (Exception $e) {
      $ret['#abort'] = array(
        'success' => FALSE,
        'query' => $e->getMessage(),
      );
      drush_set_error('DRUPAL_EXCEPTION', $e->getMessage());
    }

    if ($context['log']) {
      $ret['queries'] = Database::getLog($function);
    }
  }

  if (isset($context['sandbox']['#finished'])) {
    $context['finished'] = $context['sandbox']['#finished'];
    unset($context['sandbox']['#finished']);
  }

  if (!isset($context['results'][$module])) {
    $context['results'][$module] = array();
  }
  if (!isset($context['results'][$module][$number])) {
    $context['results'][$module][$number] = array();
  }
  $context['results'][$module][$number] = array_merge($context['results'][$module][$number], $ret);

  if (!empty($ret['#abort'])) {
    // Record this function in the list of updates that were aborted.
    $context['results']['#abort'][] = $function;
  }

  // Record the schema update if it was completed successfully.
  if ($context['finished'] == 1 && empty($ret['#abort'])) {
    drupal_set_installed_schema_version($module, $number);
  }

  $context['message'] = 'Performed update: ' . $function;
}