You are here

function drd_server_domain_find_required_updates in Drupal Remote Dashboard Server 7

Same name and namespace in other branches
  1. 6.2 drd_server.domain.inc \drd_server_domain_find_required_updates()
  2. 6 drd_server.domain.inc \drd_server_domain_find_required_updates()
  3. 7.2 drd_server.domain.inc \drd_server_domain_find_required_updates()
1 string reference to 'drd_server_domain_find_required_updates'
drd_server_domain_run_update in ./drd_server.domain.inc

File

./drd_server.domain.inc, line 158

Code

function drd_server_domain_find_required_updates() {
  drupal_get_messages();
  $form = array();
  $form_state = array();
  $form = update_script_selection_form($form, $form_state);
  $operations = array();
  if (isset($form) && isset($form['start'])) {
    $start = array();
    foreach ($form['start'] as $module => $def) {
      if (isset($def['#value']) && module_exists($module)) {
        $start[$module] = $def['#value'];
      }
    }
    $updates = update_resolve_dependencies($start);
    $dependency_map = array();
    foreach ($updates as $function => $update) {
      $dependency_map[$function] = !empty($update['reverse_paths']) ? array_keys($update['reverse_paths']) : array();
    }
    foreach ($updates as $update) {
      if ($update['allowed']) {
        if (isset($start[$update['module']])) {
          drupal_set_installed_schema_version($update['module'], $update['number'] - 1);
          unset($start[$update['module']]);
        }
        $function = $update['module'] . '_update_' . $update['number'];
        $operations[] = array(
          'update_do_one',
          array(
            $update['module'],
            $update['number'],
            $dependency_map[$function],
          ),
        );
        watchdog('DRD', 'Updating ' . $update['module'] . ': version ' . $update['number']);
        drupal_set_message('Updating ' . $update['module'] . ': version ' . $update['number']);
      }
    }
  }
  $operations[] = array(
    'drd_server_domain_capture_update_messages',
    array(),
  );
  $batch = array(
    'operations' => $operations,
    'title' => 'Updating',
    'init_message' => 'Starting updates',
    'error_message' => 'An unrecoverable error has occurred. You can find the error message below. It is advised to copy it to the clipboard for reference.',
  );
  batch_set($batch);
}