- #27635: Style update.php

4.7.x
Steven Wittens 2005-07-29 20:31:05 +00:00
parent ab8377f02b
commit e5ad13e3f8
4 changed files with 63 additions and 71 deletions

View File

@ -15,6 +15,7 @@ Drupal x.x.x, xxxx-xx-xx (development version)
* added support for collapsible page sections. * added support for collapsible page sections.
* reorganized some settings pages. * reorganized some settings pages.
* added friendly database error screens. * added friendly database error screens.
* improved styling of update.php.
- profiles: - profiles:
* added a block to display author information along with posts. * added a block to display author information along with posts.
* added support for private profile fields. * added support for private profile fields.

View File

@ -2522,10 +2522,10 @@ function update_sql($sql) {
$edit = $_POST["edit"]; $edit = $_POST["edit"];
$result = db_query($sql); $result = db_query($sql);
if ($result) { if ($result) {
return array('1', nl2br(htmlentities($sql)) ." ", "<div style=\"color: green;\">OK</div>\n"); return array('1', check_plain($sql) ."\n<span class=\"success\">OK</span>\n");
} }
else { else {
return array('0', nl2br(htmlentities($sql)) ." ", "<div style=\"color: red;\">FAILED</div>\n"); return array('0', check_plain($sql) ."\n<span class=\"failure\">FAILED</span>\n");
} }
} }

View File

@ -17,3 +17,14 @@ h1 {
color: #004975; color: #004975;
font-weight: bold; font-weight: bold;
} }
/* Update styles */
h3.update {
font-size: 1em;
}
pre.update span.success {
color: #6bb521;
}
pre.update span.failure {
color: #b63300;
}

View File

@ -14,7 +14,7 @@
* FALSE back into a TRUE! * FALSE back into a TRUE!
*/ */
// Disable access checking? // Enforce access checking?
$access_check = TRUE; $access_check = TRUE;
if (!ini_get("safe_mode")) { if (!ini_get("safe_mode")) {
@ -25,38 +25,21 @@ include_once "database/updates.inc";
function update_data($start) { function update_data($start) {
global $sql_updates; global $sql_updates;
$output = '';
$sql_updates = array_slice($sql_updates, ($start-- ? $start : 0)); $sql_updates = array_slice($sql_updates, ($start-- ? $start : 0));
foreach ($sql_updates as $date => $func) { foreach ($sql_updates as $date => $func) {
print "<strong>$date</strong><br />\n<pre>\n"; $output .= '<h3 class="update">'. $date .'</h3><pre class="update">';
$ret = $func(); $ret = $func();
foreach ($ret as $return) { foreach ($ret as $return) {
print $return[1]; $output .= $return[1];
print $return[2];
} }
variable_set("update_start", $date); variable_set("update_start", $date);
print "</pre>\n"; $output .= "</pre>\n";
} }
db_query('DELETE FROM {cache}'); db_query('DELETE FROM {cache}');
}
function update_page_header($title) {
$output = "<html><head><title>$title</title>";
$output .= <<<EOF
<link rel="stylesheet" type="text/css" media="print" href="misc/print.css" />
<style type="text/css" title="layout" media="Screen">
@import url("misc/drupal.css");
</style>
EOF;
$output .= "</head><body>";
$output .= "<div id=\"logo\"><a href=\"http://drupal.org/\"><img src=\"misc/druplicon-small.png\" alt=\"Druplicon - Drupal logo\" title=\"Druplicon - Drupal logo\" /></a></div>";
$output .= "<div id=\"update\"><h1>$title</h1>";
return $output; return $output;
} }
function update_page_footer() {
return "</div></body></html>";
}
function update_page() { function update_page() {
global $user, $sql_updates; global $user, $sql_updates;
@ -70,21 +53,24 @@ function update_page() {
switch ($op) { switch ($op) {
case "Update": case "Update":
// make sure we have updates to run. // make sure we have updates to run.
print update_page_header("Drupal database update"); drupal_set_title('Drupal database update');
$links[] = "<a href=\"index.php\">main page</a>"; $links[] = "<a href=\"index.php\">main page</a>";
$links[] = "<a href=\"index.php?q=admin\">administration pages</a>"; $links[] = "<a href=\"index.php?q=admin\">administration pages</a>";
print theme("item_list", $links); $output = theme('item_list', $links);
// NOTE: we can't use l() here because the URL would point to 'update.php?q=admin'. // NOTE: we can't use l() here because the URL would point to 'update.php?q=admin'.
if ($edit["start"] == -1) { if ($edit["start"] == -1) {
print "No updates to perform."; $output .= 'No updates to perform.';
} }
else { else {
update_data($edit["start"]); $output .= update_data($edit['start']);
} }
print "<br />Updates were attempted. If you see no failures above, you may proceed happily to the <a href=\"index.php?q=admin\">administration pages</a>."; $output .= '<p>Updates were attempted. If you see no failures above, you may proceed happily to the <a href="index.php?q=admin">administration pages</a>. Otherwise, you may need to update your database manually.</p>';
print " Otherwise, you may need to update your database manually."; if ($GLOBALS['access_check'] == FALSE) {
print update_page_footer(); $output .= "<p><strong>Reminder: don't forget to set the <code>\$access_check</code> value at the top of <code>update.php</code> back to <code>TRUE</code>.</strong>";
}
print theme('maintenance_page', $output);
break; break;
default: default:
// NOTE: We need the following five lines in order to fix a bug with // NOTE: We need the following five lines in order to fix a bug with
// database.mysql (issue #15337). We should be able to remove // database.mysql (issue #15337). We should be able to remove
@ -96,7 +82,6 @@ function update_page() {
} }
$start = variable_get("update_start", 0); $start = variable_get("update_start", 0);
$dates[] = "All";
$i = 1; $i = 1;
foreach ($sql_updates as $date => $sql) { foreach ($sql_updates as $date => $sql) {
$dates[$i++] = $date; $dates[$i++] = $date;
@ -109,26 +94,25 @@ function update_page() {
// make update form and output it. // 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_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"); $form .= form_submit("Update");
print update_page_header("Drupal database update"); drupal_set_title('Drupal database update');
print form($form); print theme('maintenance_page', form($form));
print update_page_footer();
break; break;
} }
} }
function update_info() { function update_info() {
print update_page_header("Drupal database update"); drupal_set_title('Drupal database update');
print "<ol>\n"; $output = "<ol>\n";
print "<li>Use this script to <strong>upgrade an existing Drupal installation</strong>. You don't need this script when installing Drupal from scratch.</li>"; $output .= "<li>Use this script to <strong>upgrade an existing Drupal installation</strong>. You don't need this script when installing Drupal from scratch.</li>";
print "<li>Before doing anything, backup your database. This process will change your database and its values, and some things might get lost.</li>\n"; $output .= "<li>Before doing anything, backup your database. This process will change your database and its values, and some things might get lost.</li>\n";
print "<li>Update your Drupal sources, check the notes below and <a href=\"update.php?op=update\">run the database upgrade script</a>. Don't upgrade your database twice as it may cause problems.</p></li>\n"; $output .= "<li>Update your Drupal sources, check the notes below and <a href=\"update.php?op=update\">run the database upgrade script</a>. Don't upgrade your database twice as it may cause problems.</li>\n";
print "<li>Go through the various administration pages to change the existing and new settings to your liking.</li>\n"; $output .= "<li>Go through the various administration pages to change the existing and new settings to your liking.</li>\n";
print "</ol>"; $output .= "</ol>";
print "Notes:"; $output .= "Notes:";
print "<ol>"; $output .= "<ol>";
print " <li>If you <strong>upgrade from Drupal 4.4.x</strong>, you will need to create the <code>users_roles</code> and <code>locales_meta</code> tables manually before upgrading. To create these tables, issue the following SQL commands: $output .= " <li>If you <strong>upgrade from Drupal 4.4.x</strong>, you will need to create the <code>users_roles</code> and <code>locales_meta</code> tables manually before upgrading. To create these tables, issue the following SQL commands:
<p>MySQL specific example: <p>MySQL specific example:</p>
<pre> <pre>
CREATE TABLE users_roles ( CREATE TABLE users_roles (
uid int(10) unsigned NOT NULL default '0', uid int(10) unsigned NOT NULL default '0',
@ -145,9 +129,8 @@ function update_info() {
PRIMARY KEY (locale) PRIMARY KEY (locale)
); );
</pre> </pre>
</p>
<p>PostgreSQL specific example: <p>PostgreSQL specific example:</p>
<pre> <pre>
CREATE TABLE users_roles ( CREATE TABLE users_roles (
uid integer NOT NULL default '0', uid integer NOT NULL default '0',
@ -164,18 +147,16 @@ function update_info() {
PRIMARY KEY (locale) PRIMARY KEY (locale)
); );
</pre> </pre>
</p>
</li>"; </li>";
print " <li>If you <strong>upgrade from Drupal 4.3.x</strong>, you will need to add the <code>bootstrap</code> and <code>throttle</code> fields to the <code>system</code> table manually before upgrading. To add the required fields, issue the following SQL commands: $output .= " <li>If you <strong>upgrade from Drupal 4.3.x</strong>, you will need to add the <code>bootstrap</code> and <code>throttle</code> fields to the <code>system</code> table manually before upgrading. To add the required fields, issue the following SQL commands:
<p>MySQL specific example: <p>MySQL specific example:</p>
<pre> <pre>
ALTER TABLE system ADD throttle tinyint(1) NOT NULL DEFAULT '0'; ALTER TABLE system ADD throttle tinyint(1) NOT NULL DEFAULT '0';
ALTER TABLE system ADD bootstrap int(2); ALTER TABLE system ADD bootstrap int(2);
</pre> </pre>
</p>
<p>PostgreSQL specific example: <p>PostgreSQL specific example:</p>
<pre> <pre>
ALTER TABLE system ADD throttle smallint; ALTER TABLE system ADD throttle smallint;
ALTER TABLE system ALTER COLUMN throttle SET DEFAULT '0'; ALTER TABLE system ALTER COLUMN throttle SET DEFAULT '0';
@ -183,11 +164,10 @@ function update_info() {
ALTER TABLE system ALTER COLUMN throttle SET NOT NULL; ALTER TABLE system ALTER COLUMN throttle SET NOT NULL;
ALTER TABLE system ADD bootstrap integer; ALTER TABLE system ADD bootstrap integer;
</pre> </pre>
</p>
</li>"; </li>";
print " <li>If you <strong>upgrade from Drupal 4.2.0</strong>, you will need to create the <code>sessions</code> table manually before upgrading. After creating the table, you will want to log in and immediately continue the upgrade. To create the <code>sessions</code> table, issue the following SQL command: $output .= " <li>If you <strong>upgrade from Drupal 4.2.0</strong>, you will need to create the <code>sessions</code> table manually before upgrading. After creating the table, you will want to log in and immediately continue the upgrade. To create the <code>sessions</code> table, issue the following SQL command:
<p>MySQL specific example: <p>MySQL specific example:</p>
<pre> <pre>
CREATE TABLE sessions ( CREATE TABLE sessions (
uid int(10) unsigned NOT NULL, uid int(10) unsigned NOT NULL,
@ -199,14 +179,15 @@ function update_info() {
KEY sid (sid(4)), KEY sid (sid(4)),
KEY timestamp (timestamp)); KEY timestamp (timestamp));
</pre> </pre>
</p>
</li>"; </li>";
print "</ol>"; $output .= '<p>For more help, see the <a href="http://drupal.org/node/258">Installation and upgrading handbook</a>. If you are unsure what these terms mean you should probably contact your hosting provider.</p>';
print update_page_footer(); $output .= "</ol>";
print theme('maintenance_page', $output);
} }
include_once "includes/bootstrap.inc";
drupal_maintenance_theme();
if (isset($_GET["op"])) { if (isset($_GET["op"])) {
include_once "includes/bootstrap.inc";
drupal_bootstrap(DRUPAL_BOOTSTRAP_FULL); drupal_bootstrap(DRUPAL_BOOTSTRAP_FULL);
// Access check: // Access check:
@ -214,19 +195,18 @@ if (isset($_GET["op"])) {
update_page(); update_page();
} }
else { else {
print update_page_header("Access denied"); drupal_set_title('Access denied');
print "<p>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 <code>update.php</code> to bypass this access check. To do this:</p>"; print theme('maintenance_page', '<p>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 <code>update.php</code> to bypass this access check. To do this:</p>
print "<ol>"; <ol>
print " <li>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.</li>"; <li>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.</li>
print " <li>There is a line near top of update.php that says <code>\$access_check = TRUE;</code>. Change it to <code>\$access_check = FALSE;</code>.</li>"; <li>There is a line near top of update.php that says <code>$access_check = TRUE;</code>. Change it to <code>$access_check = FALSE;</code>.</li>
print " <li>As soon as the script is done, you must change the update.php script back to its original form to <code>\$access_check = TRUE;</code>.</li>"; <li>As soon as the script is done, you must change the update.php script back to its original form to <code>$access_check = TRUE;</code>.</li>
print " <li>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.</li>"; <li>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.</li>
print "</ol>"; </ol>');
print update_page_footer();
} }
} }
else { else {
update_info(); update_info();
} }
?> ?>