$func) { $output .= '

'. $date .'

';
    $ret = $func();
    foreach ($ret as $return) {
      $output .= $return[1];
    }
    variable_set("update_start", $date);
    $output .= "
\n"; } db_query('DELETE FROM {cache}'); return $output; } function update_selection_page() { global $sql_updates; $start = variable_get("update_start", 0); $i = 1; foreach ($sql_updates as $date => $sql) { $dates[$i++] = $date; if ($date == $start) { $selected = $i; } } $dates[$i] = "No updates available"; // make update form and output it. $form = form_select("Perform updates from", "start", (isset($selected) ? $selected : -1), $dates, "This defaults to the first available update since the last update you performed."); $form .= form_submit("Update"); drupal_set_title('Drupal database update'); return form($form); } function update_do_updates() { $edit = $_POST['edit']; drupal_set_title('Drupal database update'); // NOTE: we can't use l() here because the URL would point to 'update.php?q=admin'. $links[] = "main page"; $links[] = "administration pages"; $output = theme('item_list', $links); $output .= update_data($edit['start']); $output .= '

Updates were attempted. If you see no failures above, you may proceed happily to the administration pages. Otherwise, you may need to update your database manually.

'; if ($GLOBALS['access_check'] == FALSE) { $output .= "

Reminder: don't forget to set the \$access_check value at the top of update.php back to TRUE."; } return $output; } function update_info_page() { drupal_set_title('Drupal database update'); $output = "

    \n"; $output .= "
  1. Use this script to upgrade an existing Drupal installation. You don't need this script when installing Drupal from scratch.
  2. "; $output .= "
  3. Before doing anything, backup your database. This process will change your database and its values, and some things might get lost.
  4. \n"; $output .= "
  5. Update your Drupal sources, check the notes below and run the database upgrade script. Don't upgrade your database twice as it may cause problems.
  6. \n"; $output .= "
  7. Go through the various administration pages to change the existing and new settings to your liking.
  8. \n"; $output .= "
"; $output .= '

For more help, see the Installation and upgrading handbook. If you are unsure what these terms mean you should probably contact your hosting provider.

'; return $output; } function update_access_denied_page() { drupal_set_title('Access denied'); return '

Access denied. You are not authorized to access this page. Please log in as the admin user (the first user you created). If you cannot log in, you will have to edit update.php to bypass this access check. To do this:

  1. With a text editor find the update.php file on your system. It should be in the main Drupal directory that you installed all the files into.
  2. There is a line near top of update.php that says $access_check = TRUE;. Change it to $access_check = FALSE;.
  3. As soon as the script is done, you must change the update.php script back to its original form to $access_check = TRUE;.
  4. To avoid having this problem in future, remember to log in to your website as the admin user (the user you first created) before you backup your database at the beginning of the update process.
'; } include_once './includes/bootstrap.inc'; drupal_maintenance_theme(); if (isset($_GET["op"])) { drupal_bootstrap(DRUPAL_BOOTSTRAP_FULL); // Access check: if (($access_check == 0) || ($user->uid == 1)) { $op = isset($_POST['op']) ? $_POST['op'] : ''; switch ($op) { case 'Update': $output = update_do_updates(); break; default: $output = update_selection_page(); break; } } else { $output = update_access_denied_page(); } } else { drupal_bootstrap(DRUPAL_BOOTSTRAP_DATABASE); $output = update_info_page(); } if (isset($output)) { print theme('maintenance_page', $output); }