You are here

function update_do_updates in Drupal 4

Same name and namespace in other branches
  1. 5 update.php \update_do_updates()

Perform updates for one second or until finished.

Return value

An array indicating the status after doing updates. The first element is the overall percentage finished. The second element is a status message.

2 calls to update_do_updates()
update_do_update_page in ./update.php
Perform updates for the JS version and return progress.
update_progress_page_nojs in ./update.php
Perform updates for the non-JS version and return the status page.

File

./update.php, line 402
Administrative page for handling updates from one Drupal version to another.

Code

function update_do_updates() {
  while ($update = reset($_SESSION['update_remaining'])) {
    $update_finished = update_data($update['module'], $update['version']);
    if ($update_finished == 1) {

      // Dequeue the completed update.
      unset($_SESSION['update_remaining'][key($_SESSION['update_remaining'])]);
      $update_finished = 0;

      // Make sure this step isn't counted double
    }
    if (timer_read('page') > 1000) {
      break;
    }
  }
  if ($_SESSION['update_total']) {
    $percentage = floor(($_SESSION['update_total'] - count($_SESSION['update_remaining']) + $update_finished) / $_SESSION['update_total'] * 100);
  }
  else {
    $percentage = 100;
  }

  // When no updates remain, clear the cache.
  if (!isset($update['module'])) {
    db_query('DELETE FROM {cache}');
  }
  return array(
    $percentage,
    isset($update['module']) ? 'Updating ' . $update['module'] . ' module' : 'Updating complete',
  );
}