Skip to content
Newer
Older
100644 213 lines (192 sloc) 8.31 KB
0a4f99e - added update.php to replace the updates/* files to make future upgr…
Kjartan Mannes authored Nov 15, 2001
1 <?php
645d026 @dbuytaert - Added $Id$ tags. Patch by Chris.
dbuytaert authored Sep 25, 2003
2 // $Id$
94e30bf @dbuytaert - Patch by JonBob: for consistency and readability, add brief descrip…
dbuytaert authored Aug 21, 2004
3
4 /**
5 * @file
6 * Administrative page for handling updates from one Drupal version to another.
7 *
8 * Point your browser to "http://www.site.com/update.php" and follow the
9 * instructions.
10 *
11 * If you are not logged in as administrator, you will need to modify the access
12 * check statement below. Change the TRUE into a FALSE to disable the access
13 * check. After finishing the upgrade, be sure to open this file and change the
14 * FALSE back into a TRUE!
15 */
780a345 @dbuytaert - Added some explanation to the top of the file and fixed a braino.
dbuytaert authored Dec 16, 2001
16
e5ad13e - #27635: Style update.php
Steven Wittens authored Jul 29, 2005
17 // Enforce access checking?
94e30bf @dbuytaert - Patch by JonBob: for consistency and readability, add brief descrip…
dbuytaert authored Aug 21, 2004
18 $access_check = TRUE;
d646fb0 @dbuytaert - Made it easier to by-pass the access check. Modified patch from Ste…
dbuytaert authored Oct 3, 2003
19
43da163 @dbuytaert - Fixed bug #4842: get_cfg_var() -> ini_get()
dbuytaert authored Dec 29, 2003
20 if (!ini_get("safe_mode")) {
0a4f99e - added update.php to replace the updates/* files to make future upgr…
Kjartan Mannes authored Nov 15, 2001
21 set_time_limit(180);
22 }
23
a283a3b @dbuytaert - Patch by Gerhard: move the updates to database/updates.inc so packa…
dbuytaert authored Feb 25, 2004
24 include_once "database/updates.inc";
0a4f99e - added update.php to replace the updates/* files to make future upgr…
Kjartan Mannes authored Nov 15, 2001
25
26 function update_data($start) {
a283a3b @dbuytaert - Patch by Gerhard: move the updates to database/updates.inc so packa…
dbuytaert authored Feb 25, 2004
27 global $sql_updates;
e5ad13e - #27635: Style update.php
Steven Wittens authored Jul 29, 2005
28 $output = '';
a283a3b @dbuytaert - Patch by Gerhard: move the updates to database/updates.inc so packa…
dbuytaert authored Feb 25, 2004
29 $sql_updates = array_slice($sql_updates, ($start-- ? $start : 0));
30 foreach ($sql_updates as $date => $func) {
e5ad13e - #27635: Style update.php
Steven Wittens authored Jul 29, 2005
31 $output .= '<h3 class="update">'. $date .'</h3><pre class="update">';
a283a3b @dbuytaert - Patch by Gerhard: move the updates to database/updates.inc so packa…
dbuytaert authored Feb 25, 2004
32 $ret = $func();
33 foreach ($ret as $return) {
e5ad13e - #27635: Style update.php
Steven Wittens authored Jul 29, 2005
34 $output .= $return[1];
a283a3b @dbuytaert - Patch by Gerhard: move the updates to database/updates.inc so packa…
dbuytaert authored Feb 25, 2004
35 }
0a4f99e - added update.php to replace the updates/* files to make future upgr…
Kjartan Mannes authored Nov 15, 2001
36 variable_set("update_start", $date);
e5ad13e - #27635: Style update.php
Steven Wittens authored Jul 29, 2005
37 $output .= "</pre>\n";
0a4f99e - added update.php to replace the updates/* files to make future upgr…
Kjartan Mannes authored Nov 15, 2001
38 }
18dfd4a - Adding a cache wipe to update.php, as this will avoid stale cache b…
Steven Wittens authored Jan 16, 2005
39 db_query('DELETE FROM {cache}');
9e82c05 @dbuytaert - update.php improvements and a grammatical fix from Al. Thanks.
dbuytaert authored May 20, 2003
40 return $output;
41 }
42
0a4f99e - added update.php to replace the updates/* files to make future upgr…
Kjartan Mannes authored Nov 15, 2001
43 function update_page() {
a283a3b @dbuytaert - Patch by Gerhard: move the updates to database/updates.inc so packa…
dbuytaert authored Feb 25, 2004
44 global $user, $sql_updates;
c2d2fb7 @dbuytaert - Fixed a typo in the PostgreSQL database scheme. Patch by Michael Fr…
dbuytaert authored May 13, 2003
45
11358d7 #10457: Warnings during update process
Steven Wittens authored Dec 24, 2004
46 if (isset($_POST['edit'])) {
47 $edit = $_POST['edit'];
48 }
49 if (isset($_POST['op'])) {
50 $op = $_POST['op'];
51 }
0a4f99e - added update.php to replace the updates/* files to make future upgr…
Kjartan Mannes authored Nov 15, 2001
52
11358d7 #10457: Warnings during update process
Steven Wittens authored Dec 24, 2004
53 switch ($op) {
0a4f99e - added update.php to replace the updates/* files to make future upgr…
Kjartan Mannes authored Nov 15, 2001
54 case "Update":
55 // make sure we have updates to run.
e5ad13e - #27635: Style update.php
Steven Wittens authored Jul 29, 2005
56 drupal_set_title('Drupal database update');
a0640e6 @dbuytaert - Improved module loading when serving cached pages. Moshe's bootstra…
dbuytaert authored Nov 18, 2003
57 $links[] = "<a href=\"index.php\">main page</a>";
58 $links[] = "<a href=\"index.php?q=admin\">administration pages</a>";
e5ad13e - #27635: Style update.php
Steven Wittens authored Jul 29, 2005
59 $output = theme('item_list', $links);
60 // NOTE: we can't use l() here because the URL would point to 'update.php?q=admin'.
0a4f99e - added update.php to replace the updates/* files to make future upgr…
Kjartan Mannes authored Nov 15, 2001
61 if ($edit["start"] == -1) {
e5ad13e - #27635: Style update.php
Steven Wittens authored Jul 29, 2005
62 $output .= 'No updates to perform.';
0a4f99e - added update.php to replace the updates/* files to make future upgr…
Kjartan Mannes authored Nov 15, 2001
63 }
64 else {
e5ad13e - #27635: Style update.php
Steven Wittens authored Jul 29, 2005
65 $output .= update_data($edit['start']);
0a4f99e - added update.php to replace the updates/* files to make future upgr…
Kjartan Mannes authored Nov 15, 2001
66 }
e5ad13e - #27635: Style update.php
Steven Wittens authored Jul 29, 2005
67 $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>';
68 if ($GLOBALS['access_check'] == FALSE) {
69 $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>";
70 }
71 print theme('maintenance_page', $output);
0a4f99e - added update.php to replace the updates/* files to make future upgr…
Kjartan Mannes authored Nov 15, 2001
72 break;
e5ad13e - #27635: Style update.php
Steven Wittens authored Jul 29, 2005
73
0a4f99e - added update.php to replace the updates/* files to make future upgr…
Kjartan Mannes authored Nov 15, 2001
74 default:
6d8d934 @dbuytaert - Patch #15337 by Gerhard: fixed bug in upgrade path. The 'update_sta…
dbuytaert authored Jan 13, 2005
75 // NOTE: We need the following five lines in order to fix a bug with
76 // database.mysql (issue #15337). We should be able to remove
77 // this work around in the future.
77fbe80 @dbuytaert - Added missing {}. Reported by Bart.
dbuytaert authored Feb 7, 2005
78 $result = db_query("SELECT * FROM {variable} WHERE name = 'update_start' AND value LIKE '%;\"'");
6d8d934 @dbuytaert - Patch #15337 by Gerhard: fixed bug in upgrade path. The 'update_sta…
dbuytaert authored Jan 13, 2005
79 if ($variable = db_fetch_object($result)) {
80 $variable->value = unserialize(substr($variable->value, 0, -2) .'";');
81 variable_set('update_start', $variable->value);
82 }
83
0a4f99e - added update.php to replace the updates/* files to make future upgr…
Kjartan Mannes authored Nov 15, 2001
84 $start = variable_get("update_start", 0);
85 $i = 1;
a283a3b @dbuytaert - Patch by Gerhard: move the updates to database/updates.inc so packa…
dbuytaert authored Feb 25, 2004
86 foreach ($sql_updates as $date => $sql) {
0a4f99e - added update.php to replace the updates/* files to make future upgr…
Kjartan Mannes authored Nov 15, 2001
87 $dates[$i++] = $date;
88 if ($date == $start) {
89 $selected = $i;
90 }
91 }
062e7d7 @dbuytaert - Added missing query to change the session field from VARCHAR(32) to…
dbuytaert authored Nov 24, 2002
92 $dates[$i] = "No updates available";
0a4f99e - added update.php to replace the updates/* files to make future upgr…
Kjartan Mannes authored Nov 15, 2001
93
94 // make update form and output it.
ac3a7fc @dbuytaert - Fixed a warning.
dbuytaert authored Sep 8, 2004
95 $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.");
0a4f99e - added update.php to replace the updates/* files to make future upgr…
Kjartan Mannes authored Nov 15, 2001
96 $form .= form_submit("Update");
e5ad13e - #27635: Style update.php
Steven Wittens authored Jul 29, 2005
97 drupal_set_title('Drupal database update');
98 print theme('maintenance_page', form($form));
0a4f99e - added update.php to replace the updates/* files to make future upgr…
Kjartan Mannes authored Nov 15, 2001
99 break;
100 }
101 }
102
497ab79 - added notes to update.php which you will see before you can perform…
Kjartan Mannes authored May 11, 2002
103 function update_info() {
e5ad13e - #27635: Style update.php
Steven Wittens authored Jul 29, 2005
104 drupal_set_title('Drupal database update');
105 $output = "<ol>\n";
106 $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>";
107 $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";
108 $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";
109 $output .= "<li>Go through the various administration pages to change the existing and new settings to your liking.</li>\n";
110 $output .= "</ol>";
111 $output .= "Notes:";
112 $output .= "<ol>";
113 $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:
114
115 <p>MySQL specific example:</p>
1ad9afb @dbuytaert - Added support for multiple user roles. Patch by Jim Hriggs.
dbuytaert authored May 10, 2004
116 <pre>
117 CREATE TABLE users_roles (
118 uid int(10) unsigned NOT NULL default '0',
119 rid int(10) unsigned NOT NULL default '0',
120 PRIMARY KEY (uid, rid)
121 );
1831e1b @dbuytaert - New locale module thanks to Gerhard, Goba, Marco, Kristjan and others.
dbuytaert authored Aug 11, 2004
122 CREATE TABLE locales_meta (
123 locale varchar(12) NOT NULL default '',
124 name varchar(64) NOT NULL default '',
125 enabled int(2) NOT NULL default '0',
126 isdefault int(2) NOT NULL default '0',
127 plurals int(1) NOT NULL default '0',
128 formula varchar(128) NOT NULL default '',
129 PRIMARY KEY (locale)
130 );
1ad9afb @dbuytaert - Added support for multiple user roles. Patch by Jim Hriggs.
dbuytaert authored May 10, 2004
131 </pre>
132
e5ad13e - #27635: Style update.php
Steven Wittens authored Jul 29, 2005
133 <p>PostgreSQL specific example:</p>
1ad9afb @dbuytaert - Added support for multiple user roles. Patch by Jim Hriggs.
dbuytaert authored May 10, 2004
134 <pre>
135 CREATE TABLE users_roles (
136 uid integer NOT NULL default '0',
137 rid integer NOT NULL default '0',
138 PRIMARY KEY (uid, rid)
139 );
1831e1b @dbuytaert - New locale module thanks to Gerhard, Goba, Marco, Kristjan and others.
dbuytaert authored Aug 11, 2004
140 CREATE TABLE locales_meta (
141 locale varchar(12) NOT NULL default '',
142 name varchar(64) NOT NULL default '',
143 enabled int4 NOT NULL default '0',
144 isdefault int4 NOT NULL default '0',
145 plurals int4 NOT NULL default '0',
146 formula varchar(128) NOT NULL default '',
147 PRIMARY KEY (locale)
148 );
1ad9afb @dbuytaert - Added support for multiple user roles. Patch by Jim Hriggs.
dbuytaert authored May 10, 2004
149 </pre>
150 </li>";
e5ad13e - #27635: Style update.php
Steven Wittens authored Jul 29, 2005
151 $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:
bb82569 @dbuytaert - Patch 6012 by Adrian: syncs the PostgreSQL port with the current st…
dbuytaert authored Feb 23, 2004
152
e5ad13e - #27635: Style update.php
Steven Wittens authored Jul 29, 2005
153 <p>MySQL specific example:</p>
bb82569 @dbuytaert - Patch 6012 by Adrian: syncs the PostgreSQL port with the current st…
dbuytaert authored Feb 23, 2004
154 <pre>
155 ALTER TABLE system ADD throttle tinyint(1) NOT NULL DEFAULT '0';
156 ALTER TABLE system ADD bootstrap int(2);
157 </pre>
158
e5ad13e - #27635: Style update.php
Steven Wittens authored Jul 29, 2005
159 <p>PostgreSQL specific example:</p>
bb82569 @dbuytaert - Patch 6012 by Adrian: syncs the PostgreSQL port with the current st…
dbuytaert authored Feb 23, 2004
160 <pre>
161 ALTER TABLE system ADD throttle smallint;
162 ALTER TABLE system ALTER COLUMN throttle SET DEFAULT '0';
163 UPDATE system SET throttle = 0;
164 ALTER TABLE system ALTER COLUMN throttle SET NOT NULL;
165 ALTER TABLE system ADD bootstrap integer;
166 </pre>
167 </li>";
e5ad13e - #27635: Style update.php
Steven Wittens authored Jul 29, 2005
168 $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:
1ad9afb @dbuytaert - Added support for multiple user roles. Patch by Jim Hriggs.
dbuytaert authored May 10, 2004
169
e5ad13e - #27635: Style update.php
Steven Wittens authored Jul 29, 2005
170 <p>MySQL specific example:</p>
1ad9afb @dbuytaert - Added support for multiple user roles. Patch by Jim Hriggs.
dbuytaert authored May 10, 2004
171 <pre>
172 CREATE TABLE sessions (
7d9a74d @dbuytaert - Added a note about having to create the session table manually when
dbuytaert authored Oct 1, 2003
173 uid int(10) unsigned NOT NULL,
174 sid varchar(32) NOT NULL default '',
175 hostname varchar(128) NOT NULL default '',
176 timestamp int(11) NOT NULL default '0',
177 session text,
178 KEY uid (uid),
179 KEY sid (sid(4)),
1ad9afb @dbuytaert - Added support for multiple user roles. Patch by Jim Hriggs.
dbuytaert authored May 10, 2004
180 KEY timestamp (timestamp));
181 </pre>
182 </li>";
e5ad13e - #27635: Style update.php
Steven Wittens authored Jul 29, 2005
183 $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>';
184 $output .= "</ol>";
185 print theme('maintenance_page', $output);
0a4f99e - added update.php to replace the updates/* files to make future upgr…
Kjartan Mannes authored Nov 15, 2001
186 }
497ab79 - added notes to update.php which you will see before you can perform…
Kjartan Mannes authored May 11, 2002
187
e5ad13e - #27635: Style update.php
Steven Wittens authored Jul 29, 2005
188 include_once "includes/bootstrap.inc";
189 drupal_maintenance_theme();
7c364f8 - Fixing to work with register_globals off.
Kjartan Mannes authored May 19, 2003
190 if (isset($_GET["op"])) {
ba16601 @dbuytaert - Patch #27003 by Neil: use named constants instead of strings
dbuytaert authored Jul 23, 2005
191 drupal_bootstrap(DRUPAL_BOOTSTRAP_FULL);
d026d15 @dbuytaert - Fixed links to admin page. Added help text.
dbuytaert authored Jan 7, 2003
192
286871d @dbuytaert - Some changes to the update.php script: revised the instructions a bit,
dbuytaert authored Dec 7, 2002
193 // Access check:
d646fb0 @dbuytaert - Made it easier to by-pass the access check. Modified patch from Ste…
dbuytaert authored Oct 3, 2003
194 if (($access_check == 0) || ($user->uid == 1)) {
c1f6ab3 - convert meta tags to taxonomy.
Kjartan Mannes authored May 15, 2002
195 update_page();
196 }
197 else {
e5ad13e - #27635: Style update.php
Steven Wittens authored Jul 29, 2005
198 drupal_set_title('Access denied');
199 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>
200 <ol>
201 <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>
202 <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>
203 <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>
204 <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>
205 </ol>');
c1f6ab3 - convert meta tags to taxonomy.
Kjartan Mannes authored May 15, 2002
206 }
207 }
208 else {
209 update_info();
0a4f99e - added update.php to replace the updates/* files to make future upgr…
Kjartan Mannes authored Nov 15, 2001
210 }
e5ad13e - #27635: Style update.php
Steven Wittens authored Jul 29, 2005
211
d268783 @dbuytaert - Small improvement to the admin menu based on feedback from Michael.
dbuytaert authored Jan 14, 2003
212 ?>
Something went wrong with that request. Please try again.