diff --git a/CHANGELOG.txt b/CHANGELOG.txt index 52b0eb1d240aa85f227dcf1a8903ab2a25fc061c..13a61143c96703def9e8386e564077ef49f989f5 100644 --- a/CHANGELOG.txt +++ b/CHANGELOG.txt @@ -15,6 +15,7 @@ Drupal x.x.x, xxxx-xx-xx (development version) * added support for collapsible page sections. * reorganized some settings pages. * added friendly database error screens. + * improved styling of update.php. - profiles: * added a block to display author information along with posts. * added support for private profile fields. diff --git a/database/updates.inc b/database/updates.inc index 5427e9674d165d398206f882d53797b4288853ea..f6c13f4c9522b852e427c0702e2b9ccf1ffd54d1 100644 --- a/database/updates.inc +++ b/database/updates.inc @@ -2522,10 +2522,10 @@ function update_sql($sql) { $edit = $_POST["edit"]; $result = db_query($sql); 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 { - 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"); } } diff --git a/misc/maintenance.css b/misc/maintenance.css index 0fbfc62f53f67e8653e9a131663c3d0ef9f20017..cb9e47adcc11de06bcdbfbcc49c7337a74e59ff6 100644 --- a/misc/maintenance.css +++ b/misc/maintenance.css @@ -17,3 +17,14 @@ h1 { color: #004975; font-weight: bold; } + +/* Update styles */ +h3.update { + font-size: 1em; +} +pre.update span.success { + color: #6bb521; +} +pre.update span.failure { + color: #b63300; +} diff --git a/update.php b/update.php index bb13fc8625bf3dea6cf9fe9a6efc227972625a58..60588976c2b3eaa6c5c3778c68684bd8801323c2 100644 --- a/update.php +++ b/update.php @@ -14,7 +14,7 @@ * FALSE back into a TRUE! */ -// Disable access checking? +// Enforce access checking? $access_check = TRUE; if (!ini_get("safe_mode")) { @@ -25,38 +25,21 @@ function update_data($start) { global $sql_updates; + $output = ''; $sql_updates = array_slice($sql_updates, ($start-- ? $start : 0)); 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(); foreach ($ret as $return) { - print $return[1]; - print $return[2]; + $output .= $return[1]; } variable_set("update_start", $date); - print "</pre>\n"; + $output .= "</pre>\n"; } 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; } -function update_page_footer() { - return "</div></body></html>"; -} - function update_page() { global $user, $sql_updates; @@ -70,21 +53,24 @@ function update_page() { switch ($op) { case "Update": // 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?q=admin\">administration pages</a>"; - print theme("item_list", $links); - // NOTE: we can't use l() here because the URL would point to 'update.php?q=admin'. + $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) { - print "No updates to perform."; + $output .= 'No updates to perform.'; } 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>."; - print " Otherwise, you may need to update your database manually."; - print update_page_footer(); + $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>'; + if ($GLOBALS['access_check'] == FALSE) { + $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; + 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 @@ -96,7 +82,6 @@ function update_page() { } $start = variable_get("update_start", 0); - $dates[] = "All"; $i = 1; foreach ($sql_updates as $date => $sql) { $dates[$i++] = $date; @@ -109,26 +94,25 @@ function update_page() { // 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(); + drupal_set_title('Drupal database update'); + print theme('maintenance_page', form($form)); break; } } function update_info() { - print update_page_header("Drupal database update"); - print "<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>"; - 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"; - 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"; - print "<li>Go through the various administration pages to change the existing and new settings to your liking.</li>\n"; - print "</ol>"; - print "Notes:"; - print "<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: - - <p>MySQL specific example: + drupal_set_title('Drupal database update'); + $output = "<ol>\n"; + $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>"; + $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"; + $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"; + $output .= "<li>Go through the various administration pages to change the existing and new settings to your liking.</li>\n"; + $output .= "</ol>"; + $output .= "Notes:"; + $output .= "<ol>"; + $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> <pre> CREATE TABLE users_roles ( uid int(10) unsigned NOT NULL default '0', @@ -145,9 +129,8 @@ function update_info() { PRIMARY KEY (locale) ); </pre> - </p> - <p>PostgreSQL specific example: + <p>PostgreSQL specific example:</p> <pre> CREATE TABLE users_roles ( uid integer NOT NULL default '0', @@ -164,18 +147,16 @@ function update_info() { PRIMARY KEY (locale) ); </pre> - </p> </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> ALTER TABLE system ADD throttle tinyint(1) NOT NULL DEFAULT '0'; ALTER TABLE system ADD bootstrap int(2); </pre> - </p> - <p>PostgreSQL specific example: + <p>PostgreSQL specific example:</p> <pre> ALTER TABLE system ADD throttle smallint; 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 ADD bootstrap integer; </pre> - </p> </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> CREATE TABLE sessions ( uid int(10) unsigned NOT NULL, @@ -199,14 +179,15 @@ function update_info() { KEY sid (sid(4)), KEY timestamp (timestamp)); </pre> - </p> </li>"; - print "</ol>"; - print update_page_footer(); + $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>'; + $output .= "</ol>"; + print theme('maintenance_page', $output); } +include_once "includes/bootstrap.inc"; +drupal_maintenance_theme(); if (isset($_GET["op"])) { - include_once "includes/bootstrap.inc"; drupal_bootstrap(DRUPAL_BOOTSTRAP_FULL); // Access check: @@ -214,19 +195,18 @@ function update_info() { update_page(); } else { - print update_page_header("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 "<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>"; - 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>"; - 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>"; - 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>"; - print "</ol>"; - - print update_page_footer(); + drupal_set_title('Access denied'); + 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> +<ol> + <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>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>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>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> +</ol>'); } } else { update_info(); } + ?>