Index: trunk/phase3/maintenance/updaters.inc |
— | — | @@ -0,0 +1,126 @@ |
| 2 | +<?php |
| 3 | + |
| 4 | +function do_revision_updates() { |
| 5 | + global $wgSoftwareRevision; |
| 6 | + if ( $wgSoftwareRevision < 1001 ) { |
| 7 | + update_passwords(); |
| 8 | + } |
| 9 | +} |
| 10 | + |
| 11 | +function update_passwords() { |
| 12 | + global $wgDatabase; |
| 13 | + $fname = "Update script: update_passwords()"; |
| 14 | + print "\nIt appears that you need to update the user passwords in your\n" . |
| 15 | + "database. If you have already done this (if you've run this update\n" . |
| 16 | + "script once before, for example), doing so again will make all your\n" . |
| 17 | + "user accounts inaccessible, so be sure you only do this once.\n" . |
| 18 | + "Update user passwords? (yes/no)"; |
| 19 | + |
| 20 | + $resp = readconsole(); |
| 21 | + if ( ! ( "Y" == $resp{0} || "y" == $resp{0} ) ) { return; } |
| 22 | + |
| 23 | + $sql = "SELECT user_id,user_password FROM user"; |
| 24 | + $source = $wgDatabase->query( $sql, $fname ); |
| 25 | + |
| 26 | + while ( $row = $wgDatabase->fetchObject( $source ) ) { |
| 27 | + $id = $row->user_id; |
| 28 | + $oldpass = $row->user_password; |
| 29 | + $newpass = md5( "{$id}-{$oldpass}" ); |
| 30 | + |
| 31 | + $sql = "UPDATE user SET user_password='{$newpass}' " . |
| 32 | + "WHERE user_id={$id}"; |
| 33 | + $wgDatabase->query( $sql, $fname ); |
| 34 | + } |
| 35 | +} |
| 36 | + |
| 37 | +function do_ipblocks_update() { |
| 38 | + global $wgDatabase; |
| 39 | + |
| 40 | + $do1 = $do2 = false; |
| 41 | + |
| 42 | + if ( !$wgDatabase->fieldExists( "ipblocks", "ipb_id" ) ) { |
| 43 | + $do1 = true; |
| 44 | + } |
| 45 | + if ( !$wgDatabase->fieldExists( "ipblocks", "ipb_expiry" ) ) { |
| 46 | + $do2 = true; |
| 47 | + } |
| 48 | + |
| 49 | + if ( $do1 || $do2 ) { |
| 50 | + echo "Updating ipblocks table... "; |
| 51 | + if ( $do1 ) { |
| 52 | + dbsource( "maintenance/archives/patch-ipblocks.sql", $wgDatabase ); |
| 53 | + } |
| 54 | + if ( $do2 ) { |
| 55 | + dbsource( "maintenance/archives/patch-ipb_expiry.sql", $wgDatabase ); |
| 56 | + } |
| 57 | + echo "ok\n"; |
| 58 | + } else { |
| 59 | + echo "...ipblocks is up to date.\n"; |
| 60 | + } |
| 61 | + |
| 62 | +} |
| 63 | + |
| 64 | + |
| 65 | +function do_interwiki_update() { |
| 66 | + # Check that interwiki table exists; if it doesn't source it |
| 67 | + global $wgDatabase; |
| 68 | + if( $wgDatabase->tableExists( "interwiki" ) ) { |
| 69 | + echo "...already have interwiki table\n"; |
| 70 | + return true; |
| 71 | + } |
| 72 | + echo "Creating interwiki table: "; |
| 73 | + dbsource( "maintenance/archives/patch-interwiki.sql" ); |
| 74 | + echo "ok\n"; |
| 75 | + echo "Adding default interwiki definitions: "; |
| 76 | + dbsource( "maintenance/interwiki.sql" ); |
| 77 | + echo "ok\n"; |
| 78 | +} |
| 79 | + |
| 80 | +function do_index_update() { |
| 81 | + # Check that proper indexes are in place |
| 82 | + global $wgDatabase; |
| 83 | + $meta = $wgDatabase->fieldInfo( "recentchanges", "rc_timestamp" ); |
| 84 | + if( $meta->multiple_key == 0 ) { |
| 85 | + echo "Updating indexes to 20031107: "; |
| 86 | + dbsource( "maintenance/archives/patch-indexes.sql" ); |
| 87 | + echo "ok\n"; |
| 88 | + return true; |
| 89 | + } |
| 90 | + echo "...indexes seem up to 20031107 standards\n"; |
| 91 | + return false; |
| 92 | +} |
| 93 | + |
| 94 | +function do_linkscc_update() { |
| 95 | + // Create linkscc if necessary |
| 96 | + global $wgDatabase; |
| 97 | + if( $wgDatabase->tableExists( "linkscc" ) ) { |
| 98 | + echo "...have linkscc table.\n"; |
| 99 | + } else { |
| 100 | + echo "Adding linkscc table... "; |
| 101 | + dbsource( "maintenance/archives/patch-linkscc.sql", $wgDatabase ); |
| 102 | + echo "ok\n"; |
| 103 | + } |
| 104 | +} |
| 105 | + |
| 106 | +function do_hitcounter_update() { |
| 107 | + // Create hitcounter if necessary |
| 108 | + global $wgDatabase; |
| 109 | + if( $wgDatabase->tableExists( "hitcounter" ) ) { |
| 110 | + echo "...have hitcounter table.\n"; |
| 111 | + } else { |
| 112 | + echo "Adding hitcounter table... "; |
| 113 | + dbsource( "maintenance/archives/patch-hitcounter.sql", $wgDatabase ); |
| 114 | + echo "ok\n"; |
| 115 | + } |
| 116 | +} |
| 117 | + |
| 118 | +function do_recentchanges_update() { |
| 119 | + global $wgDatabase; |
| 120 | + if ( !$wgDatabase->fieldExists( "recentchanges", "rc_type" ) ) { |
| 121 | + echo "Adding rc_type, rc_moved_to_ns, rc_moved_to_title..."; |
| 122 | + dbsource( "maintenance/archives/patch-rc_type.sql" , $wgDatabase ); |
| 123 | + echo "ok\n"; |
| 124 | + } |
| 125 | +} |
| 126 | + |
| 127 | +?> |
\ No newline at end of file |
Property changes on: trunk/phase3/maintenance/updaters.inc |
___________________________________________________________________ |
Added: svn:eol-style |
1 | 128 | + native |
Added: svn:keywords |
2 | 129 | + Author Date Id Revision |
Index: trunk/phase3/config/index.php |
— | — | @@ -143,6 +143,7 @@ |
144 | 144 | |
145 | 145 | |
146 | 146 | include( "../install-utils.inc" ); |
| 147 | +include( "../maintenance/updaters.inc" ); |
147 | 148 | class ConfigData { |
148 | 149 | function getEncoded( $data ) { |
149 | 150 | # Hackish |
— | — | @@ -319,7 +320,21 @@ |
320 | 321 | $wgDatabase->selectDB( $wgDBname ); |
321 | 322 | |
322 | 323 | if( $wgDatabase->tableExists( "cur" ) ) { |
323 | | - print "<li>There are already MediaWiki tables in this database. Skipping rest of database setup...</li>\n"; |
| 324 | + print "<li>There are already MediaWiki tables in this database. Checking if updates are needed...</li>\n<pre>"; |
| 325 | + |
| 326 | + chdir( ".." ); |
| 327 | + flush(); |
| 328 | + do_ipblocks_update(); flush(); |
| 329 | + do_interwiki_update(); flush(); |
| 330 | + do_index_update(); flush(); |
| 331 | + do_linkscc_update(); flush(); |
| 332 | + do_hitcounter_update(); flush(); |
| 333 | + do_recentchanges_update(); flush(); |
| 334 | + initialiseMessages(); flush(); |
| 335 | + chdir( "config" ); |
| 336 | + |
| 337 | + print "</pre>\n"; |
| 338 | + print "<li>Finished update checks.</li>\n"; |
324 | 339 | } else { |
325 | 340 | # FIXME: Check for errors |
326 | 341 | print "<li>Creating tables..."; |
— | — | @@ -557,13 +572,14 @@ |
558 | 573 | $conf->LanguageCode = "en"; |
559 | 574 | $conf->Encoding = "UTF-8"; |
560 | 575 | } |
| 576 | + $sep = (DIRECTORY_SEPARATOR == "\\") ? ";" : ":"; |
561 | 577 | return " |
562 | 578 | # This file was automatically generated. Don't touch unless you |
563 | 579 | # know what you're doing; see LocalSettings.sample for an edit- |
564 | 580 | # friendly file. |
565 | 581 | |
566 | 582 | \$IP = \"{$conf->IP}\"; |
567 | | -ini_set( \"include_path\", \"\$IP/includes:\$IP/languages:\" . ini_get(\"include_path\") ); |
| 583 | +ini_set( \"include_path\", \"\$IP/includes$sep\$IP/languages$sep\" . ini_get(\"include_path\") ); |
568 | 584 | include_once( \"DefaultSettings.php\" ); |
569 | 585 | |
570 | 586 | if( \$wgCommandLineMode ) { |
Index: trunk/phase3/update.php |
— | — | @@ -4,6 +4,7 @@ |
5 | 5 | # |
6 | 6 | |
7 | 7 | include( "./install-utils.inc" ); |
| 8 | +include_once( "./maintenance/updaters.inc" ); |
8 | 9 | install_version_checks(); |
9 | 10 | |
10 | 11 | if ( ! ( is_readable( "./LocalSettings.php" ) |
— | — | @@ -130,127 +131,4 @@ |
131 | 132 | print "ok\n"; |
132 | 133 | } |
133 | 134 | |
134 | | -function do_revision_updates() { |
135 | | - global $wgSoftwareRevision; |
136 | | - if ( $wgSoftwareRevision < 1001 ) { |
137 | | - update_passwords(); |
138 | | - } |
139 | | -} |
140 | | - |
141 | | -function update_passwords() { |
142 | | - global $wgDatabase; |
143 | | - $fname = "Update script: update_passwords()"; |
144 | | - print "\nIt appears that you need to update the user passwords in your\n" . |
145 | | - "database. If you have already done this (if you've run this update\n" . |
146 | | - "script once before, for example), doing so again will make all your\n" . |
147 | | - "user accounts inaccessible, so be sure you only do this once.\n" . |
148 | | - "Update user passwords? (yes/no)"; |
149 | | - |
150 | | - $resp = readconsole(); |
151 | | - if ( ! ( "Y" == $resp{0} || "y" == $resp{0} ) ) { return; } |
152 | | - |
153 | | - $sql = "SELECT user_id,user_password FROM user"; |
154 | | - $source = $wgDatabase->query( $sql, $fname ); |
155 | | - |
156 | | - while ( $row = $wgDatabase->fetchObject( $source ) ) { |
157 | | - $id = $row->user_id; |
158 | | - $oldpass = $row->user_password; |
159 | | - $newpass = md5( "{$id}-{$oldpass}" ); |
160 | | - |
161 | | - $sql = "UPDATE user SET user_password='{$newpass}' " . |
162 | | - "WHERE user_id={$id}"; |
163 | | - $wgDatabase->query( $sql, $fname ); |
164 | | - } |
165 | | -} |
166 | | - |
167 | | -function do_ipblocks_update() { |
168 | | - global $wgDatabase; |
169 | | - |
170 | | - $do1 = $do2 = false; |
171 | | - |
172 | | - if ( !$wgDatabase->fieldExists( "ipblocks", "ipb_id" ) ) { |
173 | | - $do1 = true; |
174 | | - } |
175 | | - if ( !$wgDatabase->fieldExists( "ipblocks", "ipb_expiry" ) ) { |
176 | | - $do2 = true; |
177 | | - } |
178 | | - |
179 | | - if ( $do1 || $do2 ) { |
180 | | - echo "Updating ipblocks table... "; |
181 | | - if ( $do1 ) { |
182 | | - dbsource( "maintenance/archives/patch-ipblocks.sql", $wgDatabase ); |
183 | | - } |
184 | | - if ( $do2 ) { |
185 | | - dbsource( "maintenance/archives/patch-ipb_expiry.sql", $wgDatabase ); |
186 | | - } |
187 | | - echo "ok\n"; |
188 | | - } else { |
189 | | - echo "...ipblocks is up to date.\n"; |
190 | | - } |
191 | | - |
192 | | -} |
193 | | - |
194 | | - |
195 | | -function do_interwiki_update() { |
196 | | - # Check that interwiki table exists; if it doesn't source it |
197 | | - global $wgDatabase; |
198 | | - if( $wgDatabase->tableExists( "interwiki" ) ) { |
199 | | - echo "...already have interwiki table\n"; |
200 | | - return true; |
201 | | - } |
202 | | - echo "Creating interwiki table: "; |
203 | | - dbsource( "maintenance/archives/patch-interwiki.sql" ); |
204 | | - echo "ok\n"; |
205 | | - echo "Adding default interwiki definitions: "; |
206 | | - dbsource( "maintenance/interwiki.sql" ); |
207 | | - echo "ok\n"; |
208 | | -} |
209 | | - |
210 | | -function do_index_update() { |
211 | | - # Check that proper indexes are in place |
212 | | - global $wgDatabase; |
213 | | - $meta = $wgDatabase->fieldInfo( "recentchanges", "rc_timestamp" ); |
214 | | - if( $meta->multiple_key == 0 ) { |
215 | | - echo "Updating indexes to 20031107: "; |
216 | | - dbsource( "maintenance/archives/patch-indexes.sql" ); |
217 | | - echo "ok\n"; |
218 | | - return true; |
219 | | - } |
220 | | - echo "...indexes seem up to 20031107 standards\n"; |
221 | | - return false; |
222 | | -} |
223 | | - |
224 | | -function do_linkscc_update() { |
225 | | - // Create linkscc if necessary |
226 | | - global $wgDatabase; |
227 | | - if( $wgDatabase->tableExists( "linkscc" ) ) { |
228 | | - echo "...have linkscc table.\n"; |
229 | | - } else { |
230 | | - echo "Adding linkscc table... "; |
231 | | - dbsource( "maintenance/archives/patch-linkscc.sql", $wgDatabase ); |
232 | | - echo "ok\n"; |
233 | | - } |
234 | | -} |
235 | | - |
236 | | -function do_hitcounter_update() { |
237 | | - // Create hitcounter if necessary |
238 | | - global $wgDatabase; |
239 | | - if( $wgDatabase->tableExists( "hitcounter" ) ) { |
240 | | - echo "...have hitcounter table.\n"; |
241 | | - } else { |
242 | | - echo "Adding hitcounter table... "; |
243 | | - dbsource( "maintenance/archives/patch-hitcounter.sql", $wgDatabase ); |
244 | | - echo "ok\n"; |
245 | | - } |
246 | | -} |
247 | | - |
248 | | -function do_recentchanges_update() { |
249 | | - global $wgDatabase; |
250 | | - if ( !$wgDatabase->fieldExists( "recentchanges", "rc_type" ) ) { |
251 | | - echo "Adding rc_type, rc_moved_to_ns, rc_moved_to_title..."; |
252 | | - dbsource( "maintenance/archives/patch-rc_type.sql" , $wgDatabase ); |
253 | | - echo "ok\n"; |
254 | | - } |
255 | | -} |
256 | | - |
257 | 135 | ?> |