$func) { $output .= '
'; $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_page() { global $user, $sql_updates; if (isset($_POST['edit'])) { $edit = $_POST['edit']; } if (isset($_POST['op'])) { $op = $_POST['op']; } switch ($op) { case "Update": // make sure we have updates to run. drupal_set_title('Drupal database update'); $links[] = "main page"; $links[] = "administration pages"; $output = 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) { $output .= 'No updates to perform.'; } else { $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
.";
}
print theme('maintenance_page', $output);
break;
default:
// NOTE: We need the following five lines in order to fix a bug with
// database.mysql (issue #15337). We should be able to remove
// this work around in the future.
$result = db_query("SELECT * FROM {variable} WHERE name = 'update_start' AND value LIKE '%;\"'");
if ($variable = db_fetch_object($result)) {
$variable->value = unserialize(substr($variable->value, 0, -2) .'";');
variable_set('update_start', $variable->value);
}
$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');
print theme('maintenance_page', form($form));
break;
}
}
function update_info() {
drupal_set_title('Drupal database update');
$output = "
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) );
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;
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));
For more help, see the Installation and upgrading handbook. If you are unsure what these terms mean you should probably contact your hosting provider.
'; $output .= "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:
$access_check = TRUE;
. Change it to $access_check = FALSE;
.$access_check = TRUE;
.