$func) { print "$date
\n
\n";
    $ret = $func();
    foreach ($ret as $return) {
      print $return[1];
      print $return[2];
    }
    variable_set("update_start", $date);
    print "
\n"; } } function update_page_header($title) { $output = "$title"; $output .= << EOF; $output .= ""; $output .= "
\"Druplicon
"; $output .= "

$title

"; return $output; } function update_page_footer() { return "
"; } function update_page() { global $user, $sql_updates; $edit = $_POST["edit"]; switch ($_POST["op"]) { case "Update": // make sure we have updates to run. print update_page_header("Drupal database update"); $links[] = "main page"; $links[] = "administration pages"; print theme("item_list", $links); // NOTE: we can't use l() here because the URL would point to 'update.php?q=admin'. if ($edit["start"] == -1) { print "No updates to perform."; } else { update_data($edit["start"]); } print "
Updates were attempted. If you see no failures above, you may proceed happily to the administration pages."; print " Otherwise, you may need to update your database manually."; print update_page_footer(); break; default: $start = variable_get("update_start", 0); $dates[] = "All"; $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"); print update_page_header("Drupal database update"); print form($form); print update_page_footer(); break; } } function update_info() { print update_page_header("Drupal database update"); print "
    \n"; print "
  1. Use this script to upgrade an existing Drupal installation. You don't need this script when installing Drupal from scratch.
  2. "; print "
  3. Before doing anything, backup your database. This process will change your database and its values, and some things might get lost.
  4. \n"; print "
  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"; print "
  7. Go through the various administration pages to change the existing and new settings to your liking.
  8. \n"; print "
"; print "Notes:"; print "
    "; print "
  1. If you upgrade from Drupal 4.4.x, you will need to create the users_roles and locales_meta tables manually before upgrading. To create these tables, issue the following SQL commands:

    MySQL specific example:

      CREATE TABLE users_roles (
        uid int(10) unsigned NOT NULL default '0',
        rid int(10) unsigned NOT NULL default '0',
        PRIMARY KEY (uid, rid)
      );
      CREATE TABLE locales_meta (
        locale varchar(12) NOT NULL default '',
        name varchar(64) NOT NULL default '',
        enabled int(2) NOT NULL default '0',
        isdefault int(2) NOT NULL default '0',
        plurals int(1) NOT NULL default '0',
        formula varchar(128) NOT NULL default '',
        PRIMARY KEY  (locale)
      );
      

    PostgreSQL specific example:

      CREATE TABLE users_roles (
        uid integer NOT NULL default '0',
        rid integer NOT NULL default '0',
        PRIMARY KEY (uid, rid)
      );
      CREATE TABLE locales_meta (
        locale varchar(12) NOT NULL default '',
        name varchar(64) NOT NULL default '',
        enabled int4 NOT NULL default '0',
        isdefault int4 NOT NULL default '0',
        plurals int4 NOT NULL default '0',
        formula varchar(128) NOT NULL default '',
        PRIMARY KEY  (locale)
      );
      

  2. "; print "
  3. If you upgrade from Drupal 4.3.x, you will need to add the bootstrap and throttle fields to the system table manually before upgrading. To add the required fields, issue the following SQL commands:

    MySQL specific example:

      ALTER TABLE system ADD throttle tinyint(1) NOT NULL DEFAULT '0';
      ALTER TABLE system ADD bootstrap int(2);
      

    PostgreSQL specific example:

      ALTER TABLE system ADD throttle smallint;
      ALTER TABLE system ALTER COLUMN throttle SET DEFAULT '0';
      UPDATE system SET throttle = 0;
      ALTER TABLE system ALTER COLUMN throttle SET NOT NULL;
      ALTER TABLE system ADD bootstrap integer;
      

  4. "; print "
  5. If you upgrade from Drupal 4.2.0, you will need to create the sessions table manually before upgrading. After creating the table, you will want to log in and immediately continue the upgrade. To create the sessions table, issue the following SQL command:

    MySQL specific example:

      CREATE TABLE sessions (
      uid int(10) unsigned NOT NULL,
      sid varchar(32) NOT NULL default '',
      hostname varchar(128) NOT NULL default '',
      timestamp int(11) NOT NULL default '0',
      session text,
      KEY uid (uid),
      KEY sid (sid(4)),
      KEY timestamp (timestamp));
      

  6. "; print "
"; print update_page_footer(); } if (isset($_GET["op"])) { include_once "includes/bootstrap.inc"; include_once "includes/common.inc"; // Access check: if (($access_check == 0) || ($user->uid == 1)) { update_page(); } else { print update_page_header("Access denied"); print "Access denied. You are not authorized to access to this page. Please log in as the user with user ID #1. If you cannot log-in, you will have to edit update.php to by-pass this access check; in that case, open update.php in a text editor and follow the instructions at the top."; print update_page_footer(); } } else { update_info(); } ?>