* (bug 2309) Allow templates and template parameters in HTML attribute zone,
[lhc/web/wiklou.git] / maintenance / updaters.inc
1 <?php
2 /**
3 * @package MediaWiki
4 * @subpackage Maintenance
5 */
6
7 /** */
8
9 require_once 'convertLinks.inc';
10 require_once 'InitialiseMessages.inc';
11 require_once 'userDupes.inc';
12
13 $wgRenamedTables = array(
14 # from to patch file
15 array( 'group', 'groups', 'patch-rename-group.sql' ),
16 );
17
18 $wgNewTables = array(
19 # table patch file (in maintenance/archives)
20 array( 'hitcounter', 'patch-hitcounter.sql' ),
21 array( 'querycache', 'patch-querycache.sql' ),
22 array( 'objectcache', 'patch-objectcache.sql' ),
23 array( 'categorylinks', 'patch-categorylinks.sql' ),
24 array( 'logging', 'patch-logging.sql' ),
25 array( 'user_rights', 'patch-user_rights.sql' ),
26 array( 'groups', 'patch-userlevels.sql' ),
27 array( 'validate', 'patch-validate.sql' ),
28 );
29
30 $wgNewFields = array(
31 # table field patch file (in maintenance/archives)
32 array( 'ipblocks', 'ipb_id', 'patch-ipblocks.sql' ),
33 array( 'ipblocks', 'ipb_expiry', 'patch-ipb_expiry.sql' ),
34 array( 'recentchanges', 'rc_type', 'patch-rc_type.sql' ),
35 array( 'recentchanges', 'rc_ip', 'patch-rc_ip.sql' ),
36 array( 'recentchanges', 'rc_id', 'patch-rc_id.sql' ),
37 array( 'recentchanges', 'rc_patrolled', 'patch-rc-patrol.sql' ),
38 array( 'user', 'user_real_name', 'patch-user-realname.sql' ),
39 array( 'user', 'user_token', 'patch-user_token.sql' ),
40 array( 'user', 'user_email_token', 'patch-user_email_token.sql' ),
41 array( 'user_rights', 'ur_user', 'patch-rename-user_groups-and_rights.sql' ),
42 array( 'groups', 'gr_rights', 'patch-userlevels-rights.sql' ),
43 array( 'logging', 'log_params', 'patch-log_params.sql' ),
44 array( 'archive', 'ar_rev_id', 'patch-archive-rev_id.sql' ),
45 array( 'archive', 'ar_text_id', 'patch-archive-text_id.sql' ),
46 array( 'page', 'page_len', 'patch-page_len.sql' ),
47 array( 'revision', 'rev_deleted', 'patch-rev_deleted.sql' ),
48 array( 'image', 'img_width', 'patch-img_width.sql' ),
49 array( 'image', 'img_metadata', 'patch-img_metadata.sql' ),
50 array( 'image', 'img_media_type', 'patch-img_media_type.sql' ),
51 array( 'validate', 'val_ip', 'patch-val_ip.sql' ),
52 );
53
54 function rename_table( $from, $to, $patch ) {
55 global $wgDatabase;
56 if ( $wgDatabase->tableExists( $from ) ) {
57 if ( $wgDatabase->tableExists( $to ) ) {
58 echo "...can't move table $from to $to, $to already exists.\n";
59 } else {
60 echo "Moving table $from to $to...";
61 dbsource( "maintenance/archives/$patch", $wgDatabase );
62 echo "ok\n";
63 }
64 } else {
65 // Source table does not exist
66 // Renames are done before creations, so this is typical for a new installation
67 // Ignore silently
68 }
69 }
70
71 function add_table( $name, $patch ) {
72 global $wgDatabase;
73 if ( $wgDatabase->tableExists( $name ) ) {
74 echo "...$name table already exists.\n";
75 } else {
76 echo "Creating $name table...";
77 dbsource( "maintenance/archives/$patch", $wgDatabase );
78 echo "ok\n";
79 }
80 }
81
82 function add_field( $table, $field, $patch ) {
83 global $wgDatabase;
84 if ( !$wgDatabase->tableExists( $table ) ) {
85 echo "...$table table does not exist, skipping new field patch\n";
86 } elseif ( $wgDatabase->fieldExists( $table, $field ) ) {
87 echo "...have $field field in $table table.\n";
88 } else {
89 echo "Adding $field field to table $table...";
90 dbsource( "maintenance/archives/$patch" , $wgDatabase );
91 echo "ok\n";
92 }
93 }
94
95 function do_revision_updates() {
96 global $wgSoftwareRevision;
97 if ( $wgSoftwareRevision < 1001 ) {
98 update_passwords();
99 }
100 }
101
102 function update_passwords() {
103 wfDebugDieBacktrace( "This function needs to be updated or removed.\n" );
104
105 global $wgDatabase;
106 $fname = "Update script: update_passwords()";
107 print "\nIt appears that you need to update the user passwords in your\n" .
108 "database. If you have already done this (if you've run this update\n" .
109 "script once before, for example), doing so again will make all your\n" .
110 "user accounts inaccessible, so be sure you only do this once.\n" .
111 "Update user passwords? (yes/no)";
112
113 $resp = readconsole();
114 if ( ! ( "Y" == $resp{0} || "y" == $resp{0} ) ) { return; }
115
116 $sql = "SELECT user_id,user_password FROM user";
117 $source = $wgDatabase->query( $sql, $fname );
118
119 while ( $row = $wgDatabase->fetchObject( $source ) ) {
120 $id = $row->user_id;
121 $oldpass = $row->user_password;
122 $newpass = md5( "{$id}-{$oldpass}" );
123
124 $sql = "UPDATE user SET user_password='{$newpass}' " .
125 "WHERE user_id={$id}";
126 $wgDatabase->query( $sql, $fname );
127 }
128 }
129
130 function do_interwiki_update() {
131 # Check that interwiki table exists; if it doesn't source it
132 global $wgDatabase;
133 if( $wgDatabase->tableExists( "interwiki" ) ) {
134 echo "...already have interwiki table\n";
135 return true;
136 }
137 echo "Creating interwiki table: ";
138 dbsource( "maintenance/archives/patch-interwiki.sql" );
139 echo "ok\n";
140 echo "Adding default interwiki definitions: ";
141 dbsource( "maintenance/interwiki.sql" );
142 echo "ok\n";
143 }
144
145 function do_index_update() {
146 # Check that proper indexes are in place
147 global $wgDatabase;
148 $meta = $wgDatabase->fieldInfo( "recentchanges", "rc_timestamp" );
149 if( $meta->multiple_key == 0 ) {
150 echo "Updating indexes to 20031107: ";
151 dbsource( "maintenance/archives/patch-indexes.sql" );
152 echo "ok\n";
153 return true;
154 }
155 echo "...indexes seem up to 20031107 standards\n";
156 return false;
157 }
158
159 function do_image_name_unique_update() {
160 global $wgDatabase;
161 if( $wgDatabase->indexExists( 'image', 'PRIMARY' ) ) {
162 echo "...image primary key already set.\n";
163 } else {
164 echo "Making img_name the primary key... ";
165 dbsource( "maintenance/archives/patch-image_name_primary.sql", $wgDatabase );
166 echo "ok\n";
167 }
168 }
169
170 function do_watchlist_update() {
171 global $wgDatabase;
172 if( $wgDatabase->fieldExists( 'watchlist', 'wl_notificationtimestamp' ) ) {
173 echo "ENOTIF: The watchlist table is already set up for email notification.\n";
174 } else {
175 echo "ENOTIF: Adding wl_notificationtimestamp field for email notification management.";
176 /* ALTER TABLE watchlist ADD (wl_notificationtimestamp varchar(14) binary NOT NULL default '0'); */
177 dbsource( "maintenance/archives/patch-email-notification.sql", $wgDatabase );
178 echo "ok\n";
179 }
180 }
181
182 function do_copy_newtalk_to_watchlist() {
183 global $wgDatabase;
184 global $wgCommandLineMode; # this needs to be saved while getID() and getName() are called
185
186 if ( $wgDatabase->tableExists( 'user_newtalk' ) ) {
187 $res = $wgDatabase->safeQuery( 'SELECT user_id, user_ip FROM !',
188 $wgDatabase->tableName( 'user_newtalk' ) );
189 $num_newtalks=$wgDatabase->numRows($res);
190 echo "ENOTIF: Now converting ".$num_newtalks." user_newtalk entries to watchlist table entries ... \n";
191
192 $user = new User();
193 for ( $i = 1; $i <= $num_newtalks; $i++ ) {
194 $wluser = $wgDatabase->fetchObject( $res );
195 echo 'ENOTIF: <= user_newtalk: user_id='.$wluser->user_id.' user_ip='.$wluser->user_ip."\n";
196 if ($wluser->user_id == 0) { # anonymous users ... have IP numbers as "names"
197 if ($user->isIP($wluser->user_ip)) { # do only if it really looks like an IP number (double checked)
198 $wgDatabase->replace( 'watchlist',
199 array(array('wl_user','wl_namespace', 'wl_title', 'wl_notificationtimestamp' )),
200 array('wl_user' => 0,
201 'wl_namespace' => NS_USER_TALK,
202 'wl_title' => $wluser->user_ip,
203 'wl_notificationtimestamp' => '19700101000000'
204 ), 'updaters.inc::do_watchlist_update2'
205 );
206 echo 'ENOTIF: ====> watchlist: user_id=0 '.$wluser->user_ip."\n";
207 }
208 } else { # normal users ... have user_ids
209 $user->setID($wluser->user_id);
210 $wgDatabase->replace( 'watchlist',
211 array(array('wl_user','wl_namespace', 'wl_title', 'wl_notificationtimestamp' )),
212 array('wl_user' => $user->getID(),
213 'wl_namespace' => NS_USER_TALK,
214 'wl_title' => $user->getName(),
215 'wl_notificationtimestamp' => '19700101000000'
216 ), 'updaters.inc::do_watchlist_update3'
217 );
218 echo 'ENOTIF: ====> watchlist: user_id='.$user->getID().' '.$user->getName()."\n";
219 }
220 }
221 echo "ENOTIF: The watchlist table has got the former user_newtalk entries.\n";
222 dbsource( "maintenance/archives/patch-drop-user_newtalk.sql", $wgDatabase );
223 echo "ENOTIF: Deleting the user_newtalk table as its entries are now in the watchlist table.\n";
224 } else {
225 echo "ENOTIF: No user_newtalk table found. Nothing to convert to watchlist table entries.\n";
226 }
227 }
228
229
230 function do_user_update() {
231 global $wgDatabase;
232 if( $wgDatabase->fieldExists( 'user', 'user_emailauthenticationtimestamp' ) ) {
233 echo "User table contains old email authentication field. Dropping... ";
234 dbsource( "maintenance/archives/patch-email-authentication.sql", $wgDatabase );
235 echo "ok\n";
236 } else {
237 echo "...user table does not contain old email authentication field.\n";
238 }
239 }
240
241 # Assumes that the groups table has been added.
242 function do_group_update() {
243 global $wgDatabase;
244 $res = $wgDatabase->safeQuery( 'SELECT COUNT(*) AS c FROM !',
245 $wgDatabase->tableName( 'groups' ) );
246 $row = $wgDatabase->fetchObject( $res );
247 $wgDatabase->freeResult( $res );
248 if( $row->c == 0 ) {
249 echo "Adding default group definitions... ";
250 dbsource( "maintenance/archives/patch-userlevels-defaultgroups.sql", $wgDatabase );
251 echo "ok\n";
252 }
253 }
254
255 /**
256 * 1.4 betas were missing the 'binary' marker from logging.log_title,
257 * which causes a collation mismatch error on joins in MySQL 4.1.
258 */
259 function do_logging_encoding() {
260 global $wgDatabase;
261 $logging = $wgDatabase->tableName( 'logging' );
262 $res = $wgDatabase->query( "SELECT log_title FROM $logging LIMIT 0" );
263 $flags = explode( ' ', mysql_field_flags( $res, 0 ) );
264 $wgDatabase->freeResult( $res );
265
266 if( in_array( 'binary', $flags ) ) {
267 echo "Logging table has correct title encoding.\n";
268 } else {
269 echo "Fixing title encoding on logging table... ";
270 dbsource( 'maintenance/archives/patch-logging-title.sql', $wgDatabase );
271 echo "ok\n";
272 }
273 }
274
275 function do_schema_restructuring() {
276 global $wgDatabase;
277 $fname="do_schema_restructuring";
278 if ( $wgDatabase->tableExists( 'page' ) ) {
279 echo "...page table already exists.\n";
280 } else {
281 echo "...converting from cur/old to page/revision/text DB structure.\n"; flush();
282 echo wfTimestamp();
283 echo "......checking for duplicate entries.\n"; flush();
284
285 extract( $wgDatabase->tableNames( 'cur', 'old', 'page', 'revision', 'text' ) );
286
287 $rows = $wgDatabase->query( "SELECT cur_title, cur_namespace, COUNT(cur_namespace) AS c
288 FROM $cur GROUP BY cur_title, cur_namespace HAVING c>1", $fname );
289
290 if ( $wgDatabase->numRows( $rows ) > 0 ) {
291 echo wfTimestamp();
292 echo "......<b>Found duplicate entries</b>\n";
293 echo ( sprintf( "<b> %-60s %3s %5s</b>\n", 'Title', 'NS', 'Count' ) );
294 while ( $row = $wgDatabase->fetchObject( $rows ) ) {
295 if ( ! isset( $duplicate[$row->cur_namespace] ) ) {
296 $duplicate[$row->cur_namespace] = array();
297 }
298 $duplicate[$row->cur_namespace][] = $row->cur_title;
299 echo ( sprintf( " %-60s %3s %5s\n", $row->cur_title, $row->cur_namespace, $row->c ) );
300 }
301 $sql = "SELECT cur_title, cur_namespace, cur_id, cur_timestamp FROM $cur WHERE ";
302 $firstCond = true;
303 foreach ( $duplicate as $ns => $titles ) {
304 if ( $firstCond ) {
305 $firstCond = false;
306 } else {
307 $sql .= ' OR ';
308 }
309 $sql .= "( cur_namespace = {$ns} AND cur_title in (";
310 $first = true;
311 foreach ( $titles as $t ) {
312 if ( $first ) {
313 $sql .= $wgDatabase->addQuotes( $t );
314 $first = false;
315 } else {
316 $sql .= ', ' . $wgDatabase->addQuotes( $t );
317 }
318 }
319 $sql .= ") ) \n";
320 }
321 # By sorting descending, the most recent entry will be the first in the list.
322 # All following entries will be deleted by the next while-loop.
323 $sql .= 'ORDER BY cur_namespace, cur_title, cur_timestamp DESC';
324
325 $rows = $wgDatabase->query( $sql, $fname );
326
327 $prev_title = $prev_namespace = false;
328 $deleteId = array();
329
330 while ( $row = $wgDatabase->fetchObject( $rows ) ) {
331 if ( $prev_title == $row->cur_title && $prev_namespace == $row->cur_namespace ) {
332 $deleteId[] = $row->cur_id;
333 }
334 $prev_title = $row->cur_title;
335 $prev_namespace = $row->cur_namespace;
336 }
337 $sql = "DELETE FROM $cur WHERE cur_id IN ( " . join( ',', $deleteId ) . ')';
338 $rows = $wgDatabase->query( $sql, $fname );
339 echo wfTimestamp();
340 echo "......<b>Deleted</b> ".$wgDatabase->affectedRows()." records.\n";
341 }
342
343
344 echo wfTimestamp();
345 echo "......Creating tables.\n";
346 $wgDatabase->query("CREATE TABLE $page (
347 page_id int(8) unsigned NOT NULL auto_increment,
348 page_namespace int NOT NULL,
349 page_title varchar(255) binary NOT NULL,
350 page_restrictions tinyblob NOT NULL default '',
351 page_counter bigint(20) unsigned NOT NULL default '0',
352 page_is_redirect tinyint(1) unsigned NOT NULL default '0',
353 page_is_new tinyint(1) unsigned NOT NULL default '0',
354 page_random real unsigned NOT NULL,
355 page_touched char(14) binary NOT NULL default '',
356 page_latest int(8) unsigned NOT NULL,
357 page_len int(8) unsigned NOT NULL,
358
359 PRIMARY KEY page_id (page_id),
360 UNIQUE INDEX name_title (page_namespace,page_title),
361 INDEX (page_random),
362 INDEX (page_len)
363 ) TYPE=InnoDB", $fname );
364 $wgDatabase->query("CREATE TABLE $revision (
365 rev_id int(8) unsigned NOT NULL auto_increment,
366 rev_page int(8) unsigned NOT NULL,
367 rev_comment tinyblob NOT NULL default '',
368 rev_user int(5) unsigned NOT NULL default '0',
369 rev_user_text varchar(255) binary NOT NULL default '',
370 rev_timestamp char(14) binary NOT NULL default '',
371 rev_minor_edit tinyint(1) unsigned NOT NULL default '0',
372 rev_deleted tinyint(1) unsigned NOT NULL default '0',
373
374 PRIMARY KEY rev_page_id (rev_page, rev_id),
375 UNIQUE INDEX rev_id (rev_id),
376 INDEX rev_timestamp (rev_timestamp),
377 INDEX page_timestamp (rev_page,rev_timestamp),
378 INDEX user_timestamp (rev_user,rev_timestamp),
379 INDEX usertext_timestamp (rev_user_text,rev_timestamp)
380 ) TYPE=InnoDB", $fname );
381
382 echo wfTimestamp();
383 echo "......Locking tables.\n";
384 $wgDatabase->query( "LOCK TABLES $page WRITE, $revision WRITE, $old WRITE, $cur WRITE", $fname );
385
386 $maxold = $wgDatabase->selectField( 'old', 'max(old_id)', '', $fname );
387 echo wfTimestamp();
388 echo "......maxold is {$maxold}\n";
389
390 echo wfTimestamp();
391 global $wgLegacySchemaConversion;
392 if( $wgLegacySchemaConversion ) {
393 // Create HistoryBlobCurStub entries.
394 // Text will be pulled from the leftover 'cur' table at runtime.
395 echo "......Moving metadata from cur; using blob references to text in cur table.\n";
396 $cur_text = "concat('O:18:\"historyblobcurstub\":1:{s:6:\"mCurId\";i:',cur_id,';}')";
397 $cur_flags = "'object'";
398 } else {
399 // Copy all cur text in immediately: this may take longer but avoids
400 // having to keep an extra table around.
401 echo "......Moving text from cur.\n";
402 $cur_text = 'cur_text';
403 $cur_flags = "''";
404 }
405 $wgDatabase->query( "INSERT INTO $old (old_namespace, old_title, old_text, old_comment, old_user, old_user_text,
406 old_timestamp, old_minor_edit, old_flags)
407 SELECT cur_namespace, cur_title, $cur_text, cur_comment, cur_user, cur_user_text, cur_timestamp, cur_minor_edit, $cur_flags
408 FROM $cur", $fname );
409
410 echo wfTimestamp();
411 echo "......Setting up revision table.\n";
412 $wgDatabase->query( "INSERT INTO $revision (rev_id, rev_page, rev_comment, rev_user, rev_user_text, rev_timestamp,
413 rev_minor_edit)
414 SELECT old_id, cur_id, old_comment, old_user, old_user_text,
415 old_timestamp, old_minor_edit
416 FROM $old,$cur WHERE old_namespace=cur_namespace AND old_title=cur_title", $fname );
417
418 echo wfTimestamp();
419 echo "......Setting up page table.\n";
420 $wgDatabase->query( "INSERT INTO $page (page_id, page_namespace, page_title, page_restrictions, page_counter,
421 page_is_redirect, page_is_new, page_random, page_touched, page_latest, page_len)
422 SELECT cur_id, cur_namespace, cur_title, cur_restrictions, cur_counter, cur_is_redirect, cur_is_new,
423 cur_random, cur_touched, rev_id, LENGTH(cur_text)
424 FROM $cur,$revision
425 WHERE cur_id=rev_page AND rev_timestamp=cur_timestamp AND rev_id > {$maxold}", $fname );
426
427 echo wfTimestamp();
428 echo "......Unlocking tables.\n";
429 $wgDatabase->query( "UNLOCK TABLES", $fname );
430
431 echo wfTimestamp();
432 echo "......Renaming old.\n";
433 $wgDatabase->query( "ALTER TABLE $old RENAME TO $text", $fname );
434
435 echo wfTimestamp();
436 echo "...done.\n";
437 }
438 }
439
440 function do_inverse_timestamp() {
441 global $wgDatabase;
442 $fname="do_schema_restructuring";
443 if( $wgDatabase->fieldExists( 'revision', 'inverse_timestamp' ) ) {
444 echo "Removing revision.inverse_timestamp and fixing indexes... ";
445 dbsource( 'maintenance/archives/patch-inverse_timestamp.sql', $wgDatabase );
446 echo "ok\n";
447 } else {
448 echo "revision timestamp indexes already up to 2005-03-13\n";
449 }
450 }
451
452 function do_text_id() {
453 global $wgDatabase;
454 if( $wgDatabase->fieldExists( 'revision', 'rev_text_id' ) ) {
455 echo "...rev_text_id already in place.\n";
456 } else {
457 echo "Adding rev_text_id field... ";
458 dbsource( 'maintenance/archives/patch-rev_text_id.sql', $wgDatabase );
459 echo "ok\n";
460 }
461 }
462
463 function do_namespace_size() {
464 $tables = array(
465 'page' => 'page',
466 'archive' => 'ar',
467 'recentchanges' => 'rc',
468 'watchlist' => 'wl',
469 'querycache' => 'qc',
470 'logging' => 'log',
471 );
472 foreach( $tables as $table => $prefix ) {
473 do_namespace_size_on( $table, $prefix );
474 flush();
475 }
476 }
477
478 function do_namespace_size_on( $table, $prefix ) {
479 global $wgDatabase;
480 $field = $prefix . '_namespace';
481
482 $tablename = $wgDatabase->tableName( $table );
483 $result = $wgDatabase->query( "SHOW COLUMNS FROM $tablename LIKE '$field'" );
484 $info = $wgDatabase->fetchObject( $result );
485 $wgDatabase->freeResult( $result );
486
487 if( substr( $info->Type, 0, 3 ) == 'int' ) {
488 echo "...$field is already a full int ($info->Type).\n";
489 } else {
490 echo "Promoting $field from $info->Type to int... ";
491
492 $sql = "ALTER TABLE $tablename MODIFY $field int NOT NULL";
493 $wgDatabase->query( $sql );
494
495 echo "ok\n";
496 }
497 }
498
499 function do_pagelinks_update() {
500 global $wgDatabase;
501 if( $wgDatabase->tableExists( 'pagelinks' ) ) {
502 echo "...already have pagelinks table.\n";
503 } else {
504 echo "Converting links and brokenlinks tables to pagelinks... ";
505 dbsource( "maintenance/archives/patch-pagelinks.sql", $wgDatabase );
506 echo "ok\n";
507 flush();
508
509 global $wgCanonicalNamespaceNames;
510 foreach( $wgCanonicalNamespaceNames as $ns => $name ) {
511 if( $ns != 0 ) {
512 do_pagelinks_namespace( $ns );
513 }
514 }
515 }
516 }
517
518 function do_pagelinks_namespace( $namespace ) {
519 global $wgDatabase, $wgContLang;
520
521 $ns = IntVal( $namespace );
522 echo "Cleaning up broken links for namespace $ns... ";
523
524 $pagelinks = $wgDatabase->tableName( 'pagelinks' );
525 $name = $wgContLang->getNsText( $ns );
526 $prefix = $wgDatabase->strencode( $name );
527 $likeprefix = str_replace( '_', '\\_', $prefix);
528
529 $sql = "UPDATE $pagelinks
530 SET pl_namespace=$ns,
531 pl_title=TRIM(LEADING '$prefix:' FROM pl_title)
532 WHERE pl_namespace=0
533 AND pl_title LIKE '$likeprefix:%'";
534
535 $wgDatabase->query( $sql, 'do_pagelinks_namespace' );
536 echo "ok\n";
537 }
538
539 function do_drop_img_type() {
540 global $wgDatabase;
541
542 if( $wgDatabase->fieldExists( 'image', 'img_type' ) ) {
543 echo "Dropping unused img_type field in image table... ";
544 dbsource( "maintenance/archives/patch-drop_img_type.sql", $wgDatabase );
545 echo "ok\n";
546 } else {
547 echo "No img_type field in image table; Good.\n";
548 }
549 }
550
551 function do_old_links_update() {
552 global $wgDatabase;
553 if( $wgDatabase->tableExists( 'pagelinks' ) ) {
554 echo "Already have pagelinks; skipping old links table updates.\n";
555 } else {
556 convertLinks(); flush();
557 }
558 }
559
560 function do_user_unique_update() {
561 global $wgDatabase;
562 $duper = new UserDupes( $wgDatabase );
563 if( $duper->hasUniqueIndex() ) {
564 echo "Already have unique user_name index.\n";
565 } else {
566 if( !$duper->clearDupes() ) {
567 echo "WARNING: This next step will probably fail due to unfixed duplicates...\n";
568 }
569 echo "Adding unique index on user_name... ";
570 dbsource( 'maintenance/archives/patch-user_nameindex.sql', $wgDatabase );
571 echo "ok\n";
572 }
573 }
574
575 function do_all_updates() {
576 global $wgNewTables, $wgNewFields, $wgRenamedTables;
577
578 # Rename tables
579 foreach ( $wgRenamedTables as $tableRecord ) {
580 rename_table( $tableRecord[0], $tableRecord[1], $tableRecord[2] );
581 }
582
583 # Add missing tables
584 foreach ( $wgNewTables as $tableRecord ) {
585 add_table( $tableRecord[0], $tableRecord[1] );
586 flush();
587 }
588
589 # Add missing fields
590 foreach ( $wgNewFields as $fieldRecord ) {
591 add_field( $fieldRecord[0], $fieldRecord[1], $fieldRecord[2] );
592 flush();
593 }
594
595 # Add default group data
596 do_group_update(); flush();
597
598 # Do schema updates which require special handling
599 do_interwiki_update(); flush();
600 do_index_update(); flush();
601 do_old_links_update(); flush();
602 do_image_name_unique_update(); flush();
603 do_watchlist_update(); flush();
604 do_user_update(); flush();
605 do_copy_newtalk_to_watchlist(); flush();
606 do_logging_encoding(); flush();
607
608 do_schema_restructuring(); flush();
609 do_inverse_timestamp(); flush();
610 do_text_id(); flush();
611 do_namespace_size(); flush();
612
613 do_pagelinks_update(); flush();
614
615 do_drop_img_type(); flush();
616
617 do_user_unique_update(); flush();
618
619 initialiseMessages(); flush();
620 }
621
622 ?>