r46898 MediaWiki - Code Review archive

Repository:MediaWiki
Revision:r46897‎ | r46898 | r46899 >
Date:05:47, 6 February 2009
Author:tstarling
Status:deferred
Tags:
Comment:
Backported r46840, r46843, r46889 (installer XSS fixes)
Modified paths:
  • /branches/REL1_12/phase3/config/index.php (modified) (history)
  • /branches/REL1_12/phase3/includes/GlobalFunctions.php (modified) (history)
  • /branches/REL1_12/phase3/maintenance/convertLinks.inc (modified) (history)
  • /branches/REL1_12/phase3/maintenance/initStats.inc (modified) (history)
  • /branches/REL1_12/phase3/maintenance/updaters.inc (modified) (history)
  • /branches/REL1_12/phase3/maintenance/userDupes.inc (modified) (history)

Diff [purge]

Index: branches/REL1_12/phase3/maintenance/initStats.inc
@@ -3,34 +3,34 @@
44 function wfInitStats( $options=array() ) {
55 $dbr = wfGetDB( DB_SLAVE );
66
7 - echo "Counting total edits...";
 7+ wfOut( "Counting total edits..." );
88 $edits = $dbr->selectField( 'revision', 'COUNT(*)', '', __METHOD__ );
99 $edits += $dbr->selectField( 'archive', 'COUNT(*)', '', __METHOD__ );
10 - echo "{$edits}\nCounting number of articles...";
 10+ wfOut( "{$edits}\nCounting number of articles..." );
1111
1212 global $wgContentNamespaces;
1313 $good = $dbr->selectField( 'page', 'COUNT(*)', array( 'page_namespace' => $wgContentNamespaces, 'page_is_redirect' => 0, 'page_len > 0' ), __METHOD__ );
14 - echo "{$good}\nCounting total pages...";
 14+ wfOut( "{$good}\nCounting total pages..." );
1515
1616 $pages = $dbr->selectField( 'page', 'COUNT(*)', '', __METHOD__ );
17 - echo "{$pages}\nCounting number of users...";
 17+ wfOut( "{$pages}\nCounting number of users..." );
1818
1919 $users = $dbr->selectField( 'user', 'COUNT(*)', '', __METHOD__ );
20 - echo "{$users}\nCounting number of admins...";
 20+ wfOut( "{$users}\nCounting number of admins..." );
2121
2222 $admin = $dbr->selectField( 'user_groups', 'COUNT(*)', array( 'ug_group' => 'sysop' ), __METHOD__ );
23 - echo "{$admin}\nCounting number of images...";
 23+ wfOut( "{$admin}\nCounting number of images..." );
2424
2525 $image = $dbr->selectField( 'image', 'COUNT(*)', '', __METHOD__ );
26 - echo "{$image}\n";
 26+ wfOut( "{$image}\n" );
2727
2828 if( !isset( $options['noviews'] ) ) {
29 - echo "Counting total page views...";
 29+ wfOut( "Counting total page views..." );
3030 $views = $dbr->selectField( 'page', 'SUM(page_counter)', '', __METHOD__ );
31 - echo "{$views}\n";
 31+ wfOut( "{$views}\n" );
3232 }
3333
34 - echo "\nUpdating site statistics...";
 34+ wfOut( "\nUpdating site statistics..." );
3535
3636 $dbw = wfGetDB( DB_MASTER );
3737 $values = array( 'ss_total_edits' => $edits,
@@ -49,7 +49,7 @@
5050 $dbw->insert( 'site_stats', array_merge( $values, $conds, $views ), __METHOD__ );
5151 }
5252
53 - echo( "done.\n" );
 53+ wfOut( "done.\n" );
5454 }
5555
5656 ?>
\ No newline at end of file
Index: branches/REL1_12/phase3/maintenance/updaters.inc
@@ -142,11 +142,11 @@
143143 global $wgDatabase;
144144 if ( $wgDatabase->tableExists( $from ) ) {
145145 if ( $wgDatabase->tableExists( $to ) ) {
146 - echo "...can't move table $from to $to, $to already exists.\n";
 146+ wfOut( "...can't move table $from to $to, $to already exists.\n" );
147147 } else {
148 - echo "Moving table $from to $to...";
 148+ wfOut( "Moving table $from to $to..." );
149149 dbsource( archive($patch), $wgDatabase );
150 - echo "ok\n";
 150+ wfOut( "ok\n" );
151151 }
152152 } else {
153153 // Source table does not exist
@@ -158,47 +158,47 @@
159159 function add_table( $name, $patch, $fullpath=false ) {
160160 global $wgDatabase;
161161 if ( $wgDatabase->tableExists( $name ) ) {
162 - echo "...$name table already exists.\n";
 162+ wfOut( "...$name table already exists.\n" );
163163 } else {
164 - echo "Creating $name table...";
 164+ wfOut( "Creating $name table..." );
165165 if( $fullpath ) {
166166 dbsource( $patch, $wgDatabase );
167167 } else {
168168 dbsource( archive($patch), $wgDatabase );
169169 }
170 - echo "ok\n";
 170+ wfOut( "ok\n" );
171171 }
172172 }
173173
174174 function add_field( $table, $field, $patch, $fullpath=false ) {
175175 global $wgDatabase;
176176 if ( !$wgDatabase->tableExists( $table ) ) {
177 - echo "...$table table does not exist, skipping new field patch\n";
 177+ wfOut( "...$table table does not exist, skipping new field patch\n" );
178178 } elseif ( $wgDatabase->fieldExists( $table, $field ) ) {
179 - echo "...have $field field in $table table.\n";
 179+ wfOut( "...have $field field in $table table.\n" );
180180 } else {
181 - echo "Adding $field field to table $table...";
 181+ wfOut( "Adding $field field to table $table..." );
182182 if( $fullpath ) {
183183 dbsource( $patch, $wgDatabase );
184184 } else {
185185 dbsource( archive($patch), $wgDatabase );
186186 }
187 - echo "ok\n";
 187+ wfOut( "ok\n" );
188188 }
189189 }
190190
191191 function add_index( $table, $index, $patch, $fullpath=false ) {
192192 global $wgDatabase;
193193 if( $wgDatabase->indexExists( $table, $index ) ) {
194 - echo "...$index key already set on $table table.\n";
 194+ wfOut( "...$index key already set on $table table.\n" );
195195 } else {
196 - echo "Adding $index key to table $table... ";
 196+ wfOut( "Adding $index key to table $table... " );
197197 if( $fullpath ) {
198198 dbsource( $patch, $wgDatabase );
199199 } else {
200200 dbsource( archive($patch), $wgDatabase );
201201 }
202 - echo "ok\n";
 202+ wfOut( "ok\n" );
203203 }
204204 }
205205
@@ -214,11 +214,11 @@
215215
216216 global $wgDatabase;
217217 $fname = "Update script: update_passwords()";
218 - print "\nIt appears that you need to update the user passwords in your\n" .
 218+ wfOut( "\nIt appears that you need to update the user passwords in your\n" .
219219 "database. If you have already done this (if you've run this update\n" .
220220 "script once before, for example), doing so again will make all your\n" .
221221 "user accounts inaccessible, so be sure you only do this once.\n" .
222 - "Update user passwords? (yes/no)";
 222+ "Update user passwords? (yes/no)" );
223223
224224 $resp = readconsole();
225225 if ( ! ( "Y" == $resp{0} || "y" == $resp{0} ) ) { return; }
@@ -241,15 +241,15 @@
242242 # Check that interwiki table exists; if it doesn't source it
243243 global $wgDatabase, $IP;
244244 if( $wgDatabase->tableExists( "interwiki" ) ) {
245 - echo "...already have interwiki table\n";
 245+ wfOut( "...already have interwiki table\n" );
246246 return true;
247247 }
248 - echo "Creating interwiki table: ";
 248+ wfOut( "Creating interwiki table: " );
249249 dbsource( archive("patch-interwiki.sql") );
250 - echo "ok\n";
251 - echo "Adding default interwiki definitions: ";
 250+ wfOut( "ok\n" );
 251+ wfOut( "Adding default interwiki definitions: " );
252252 dbsource( "$IP/maintenance/interwiki.sql" );
253 - echo "ok\n";
 253+ wfOut( "ok\n" );
254254 }
255255
256256 function do_index_update() {
@@ -257,12 +257,12 @@
258258 global $wgDatabase;
259259 $meta = $wgDatabase->fieldInfo( "recentchanges", "rc_timestamp" );
260260 if( !$meta->isMultipleKey() ) {
261 - echo "Updating indexes to 20031107: ";
 261+ wfOut( "Updating indexes to 20031107: " );
262262 dbsource( archive("patch-indexes.sql") );
263 - echo "ok\n";
 263+ wfOut( "ok\n" );
264264 return true;
265265 }
266 - echo "...indexes seem up to 20031107 standards\n";
 266+ wfOut( "...indexes seem up to 20031107 standards\n" );
267267 return false;
268268 }
269269
@@ -271,67 +271,67 @@
272272
273273 $meta = $wgDatabase->fieldInfo( "image", "img_major_mime" );
274274 if( !$meta->isMultipleKey() ) {
275 - echo "Updating indexes to 20050912: ";
 275+ wfOut( "Updating indexes to 20050912: " );
276276 dbsource( archive("patch-mimesearch-indexes.sql") );
277 - echo "ok\n";
 277+ wfOut( "ok\n" );
278278 return true;
279279 }
280 - echo "...indexes seem up to 20050912 standards\n";
 280+ wfOut( "...indexes seem up to 20050912 standards\n" );
281281 return false;
282282 }
283283
284284 function do_image_name_unique_update() {
285285 global $wgDatabase;
286286 if( $wgDatabase->indexExists( 'image', 'PRIMARY' ) ) {
287 - echo "...image primary key already set.\n";
 287+ wfOut( "...image primary key already set.\n" );
288288 } else {
289 - echo "Making img_name the primary key... ";
 289+ wfOut( "Making img_name the primary key... " );
290290 dbsource( archive("patch-image_name_primary.sql"), $wgDatabase );
291 - echo "ok\n";
 291+ wfOut( "ok\n" );
292292 }
293293 }
294294
295295 function do_logging_timestamp_index() {
296296 global $wgDatabase;
297297 if( $wgDatabase->indexExists( 'logging', 'times' ) ) {
298 - echo "...timestamp key on logging already exists.\n";
 298+ wfOut( "...timestamp key on logging already exists.\n" );
299299 } else {
300 - echo "Adding timestamp key on logging table... ";
 300+ wfOut( "Adding timestamp key on logging table... " );
301301 dbsource( archive("patch-logging-times-index.sql"), $wgDatabase );
302 - echo "ok\n";
 302+ wfOut( "ok\n" );
303303 }
304304 }
305305
306306 function do_archive_user_index() {
307307 global $wgDatabase;
308308 if( $wgDatabase->indexExists( 'archive', 'usertext_timestamp' ) ) {
309 - echo "...usertext,timestamp key on archive already exists.\n";
 309+ wfOut( "...usertext,timestamp key on archive already exists.\n" );
310310 } else {
311 - echo "Adding usertext,timestamp key on archive table... ";
 311+ wfOut( "Adding usertext,timestamp key on archive table... " );
312312 dbsource( archive("patch-archive-user-index.sql"), $wgDatabase );
313 - echo "ok\n";
 313+ wfOut( "ok\n" );
314314 }
315315 }
316316
317317 function do_image_user_index() {
318318 global $wgDatabase;
319319 if( $wgDatabase->indexExists( 'image', 'img_usertext_timestamp' ) ) {
320 - echo "...usertext,timestamp key on image already exists.\n";
 320+ wfOut( "...usertext,timestamp key on image already exists.\n" );
321321 } else {
322 - echo "Adding usertext,timestamp key on image table... ";
 322+ wfOut( "Adding usertext,timestamp key on image table... " );
323323 dbsource( archive("patch-image-user-index.sql"), $wgDatabase );
324 - echo "ok\n";
 324+ wfOut( "ok\n" );
325325 }
326326 }
327327
328328 function do_oldimage_user_index() {
329329 global $wgDatabase;
330330 if( $wgDatabase->indexExists( 'oldimage', 'oi_usertext_timestamp' ) ) {
331 - echo "...usertext,timestamp key on oldimage already exists.\n";
 331+ wfOut( "...usertext,timestamp key on oldimage already exists.\n" );
332332 } else {
333 - echo "Adding usertext,timestamp key on oldimage table... ";
 333+ wfOut( "Adding usertext,timestamp key on oldimage table... " );
334334 dbsource( archive("patch-oldimage-user-index.sql"), $wgDatabase );
335 - echo "ok\n";
 335+ wfOut( "ok\n" );
336336 }
337337 }
338338
@@ -339,18 +339,18 @@
340340 global $wgDatabase;
341341 $fname = 'do_watchlist_update';
342342 if( $wgDatabase->fieldExists( 'watchlist', 'wl_notificationtimestamp' ) ) {
343 - echo "The watchlist table is already set up for email notification.\n";
 343+ wfOut( "The watchlist table is already set up for email notification.\n" );
344344 } else {
345 - echo "Adding wl_notificationtimestamp field for email notification management.";
 345+ wfOut( "Adding wl_notificationtimestamp field for email notification management." );
346346 /* ALTER TABLE watchlist ADD (wl_notificationtimestamp varchar(14) binary NOT NULL default '0'); */
347347 dbsource( archive( 'patch-email-notification.sql' ), $wgDatabase );
348 - echo "ok\n";
 348+ wfOut( "ok\n" );
349349 }
350350 # Check if we need to add talk page rows to the watchlist
351351 $talk = $wgDatabase->selectField( 'watchlist', 'count(*)', 'wl_namespace & 1', $fname );
352352 $nontalk = $wgDatabase->selectField( 'watchlist', 'count(*)', 'NOT (wl_namespace & 1)', $fname );
353353 if ( $talk != $nontalk ) {
354 - echo "Adding missing watchlist talk page rows... ";
 354+ wfOut( "Adding missing watchlist talk page rows... " );
355355 flush();
356356
357357 $wgDatabase->insertSelect( 'watchlist', 'watchlist',
@@ -360,9 +360,9 @@
361361 'wl_title' => 'wl_title',
362362 'wl_notificationtimestamp' => 'wl_notificationtimestamp'
363363 ), array( 'NOT (wl_namespace & 1)' ), $fname, 'IGNORE' );
364 - echo "ok\n";
 364+ wfOut( "ok\n" );
365365 } else {
366 - echo "...watchlist talk page rows already present\n";
 366+ wfOut( "...watchlist talk page rows already present\n" );
367367 }
368368 }
369369
@@ -373,7 +373,7 @@
374374 $res = $wgDatabase->safeQuery( 'SELECT user_id, user_ip FROM !',
375375 $wgDatabase->tableName( 'user_newtalk' ) );
376376 $num_newtalks=$wgDatabase->numRows($res);
377 - echo "Now converting ".$num_newtalks." user_newtalk entries to watchlist table entries ... \n";
 377+ wfOut( "Now converting $num_newtalks user_newtalk entries to watchlist table entries ... \n" );
378378
379379 $user = new User();
380380 for ( $i = 1; $i <= $num_newtalks; $i++ ) {
@@ -401,18 +401,18 @@
402402 );
403403 }
404404 }
405 - echo "Done.\n";
 405+ wfOut( "Done.\n" );
406406 }
407407
408408
409409 function do_user_update() {
410410 global $wgDatabase;
411411 if( $wgDatabase->fieldExists( 'user', 'user_emailauthenticationtimestamp' ) ) {
412 - echo "User table contains old email authentication field. Dropping... ";
 412+ wfOut( "User table contains old email authentication field. Dropping... " );
413413 dbsource( archive( 'patch-email-authentication.sql' ), $wgDatabase );
414 - echo "ok\n";
 414+ wfOut( "ok\n" );
415415 } else {
416 - echo "...user table does not contain old email authentication field.\n";
 416+ wfOut( "...user table does not contain old email authentication field.\n" );
417417 }
418418 }
419419
@@ -430,11 +430,11 @@
431431 $wgDatabase->freeResult( $res );
432432
433433 if( in_array( 'binary', $flags ) ) {
434 - echo "Logging table has correct title encoding.\n";
 434+ wfOut( "Logging table has correct title encoding.\n" );
435435 } else {
436 - echo "Fixing title encoding on logging table... ";
 436+ wfOut( "Fixing title encoding on logging table... " );
437437 dbsource( archive( 'patch-logging-title.sql' ), $wgDatabase );
438 - echo "ok\n";
 438+ wfOut( "ok\n" );
439439 }
440440 }
441441
@@ -442,11 +442,11 @@
443443 global $wgDatabase;
444444 $fname="do_schema_restructuring";
445445 if ( $wgDatabase->tableExists( 'page' ) ) {
446 - echo "...page table already exists.\n";
 446+ wfOut( "...page table already exists.\n" );
447447 } else {
448 - echo "...converting from cur/old to page/revision/text DB structure.\n"; flush();
449 - echo wfTimestamp( TS_DB );
450 - echo "......checking for duplicate entries.\n"; flush();
 448+ wfOut( "...converting from cur/old to page/revision/text DB structure.\n" );
 449+ wfOut( wfTimestamp( TS_DB ) );
 450+ wfOut( "......checking for duplicate entries.\n" );
451451
452452 list ($cur, $old, $page, $revision, $text) = $wgDatabase->tableNamesN( 'cur', 'old', 'page', 'revision', 'text' );
453453
@@ -454,15 +454,15 @@
455455 FROM $cur GROUP BY cur_title, cur_namespace HAVING c>1", $fname );
456456
457457 if ( $wgDatabase->numRows( $rows ) > 0 ) {
458 - echo wfTimestamp( TS_DB );
459 - echo "......<b>Found duplicate entries</b>\n";
460 - echo ( sprintf( "<b> %-60s %3s %5s</b>\n", 'Title', 'NS', 'Count' ) );
 458+ wfOut( wfTimestamp( TS_DB ) );
 459+ wfOut( "......<b>Found duplicate entries</b>\n" );
 460+ wfOut( sprintf( "<b> %-60s %3s %5s</b>\n", 'Title', 'NS', 'Count' ) );
461461 while ( $row = $wgDatabase->fetchObject( $rows ) ) {
462462 if ( ! isset( $duplicate[$row->cur_namespace] ) ) {
463463 $duplicate[$row->cur_namespace] = array();
464464 }
465465 $duplicate[$row->cur_namespace][] = $row->cur_title;
466 - echo ( sprintf( " %-60s %3s %5s\n", $row->cur_title, $row->cur_namespace, $row->c ) );
 466+ wfOut( sprintf( " %-60s %3s %5s\n", $row->cur_title, $row->cur_namespace, $row->c ) );
467467 }
468468 $sql = "SELECT cur_title, cur_namespace, cur_id, cur_timestamp FROM $cur WHERE ";
469469 $firstCond = true;
@@ -502,13 +502,13 @@
503503 }
504504 $sql = "DELETE FROM $cur WHERE cur_id IN ( " . join( ',', $deleteId ) . ')';
505505 $rows = $wgDatabase->query( $sql, $fname );
506 - echo wfTimestamp( TS_DB );
507 - echo "......<b>Deleted</b> ".$wgDatabase->affectedRows()." records.\n";
 506+ wfOut( wfTimestamp( TS_DB ) );
 507+ wfOut( "......<b>Deleted</b> ".$wgDatabase->affectedRows()." records.\n" );
508508 }
509509
510510
511 - echo wfTimestamp( TS_DB );
512 - echo "......Creating tables.\n";
 511+ wfOut( wfTimestamp( TS_DB ) );
 512+ wfOut( "......Creating tables.\n" );
513513 $wgDatabase->query("CREATE TABLE $page (
514514 page_id int(8) unsigned NOT NULL auto_increment,
515515 page_namespace int NOT NULL,
@@ -546,26 +546,26 @@
547547 INDEX usertext_timestamp (rev_user_text,rev_timestamp)
548548 ) TYPE=InnoDB", $fname );
549549
550 - echo wfTimestamp( TS_DB );
551 - echo "......Locking tables.\n";
 550+ wfOut( wfTimestamp( TS_DB ) );
 551+ wfOut( "......Locking tables.\n" );
552552 $wgDatabase->query( "LOCK TABLES $page WRITE, $revision WRITE, $old WRITE, $cur WRITE", $fname );
553553
554554 $maxold = intval( $wgDatabase->selectField( 'old', 'max(old_id)', '', $fname ) );
555 - echo wfTimestamp( TS_DB );
556 - echo "......maxold is {$maxold}\n";
 555+ wfOut( wfTimestamp( TS_DB ) );
 556+ wfOut( "......maxold is {$maxold}\n" );
557557
558 - echo wfTimestamp( TS_DB );
 558+ wfOut( wfTimestamp( TS_DB ) );
559559 global $wgLegacySchemaConversion;
560560 if( $wgLegacySchemaConversion ) {
561561 // Create HistoryBlobCurStub entries.
562562 // Text will be pulled from the leftover 'cur' table at runtime.
563 - echo "......Moving metadata from cur; using blob references to text in cur table.\n";
 563+ wfOut( "......Moving metadata from cur; using blob references to text in cur table.\n" );
564564 $cur_text = "concat('O:18:\"historyblobcurstub\":1:{s:6:\"mCurId\";i:',cur_id,';}')";
565565 $cur_flags = "'object'";
566566 } else {
567567 // Copy all cur text in immediately: this may take longer but avoids
568568 // having to keep an extra table around.
569 - echo "......Moving text from cur.\n";
 569+ wfOut( "......Moving text from cur.\n" );
570570 $cur_text = 'cur_text';
571571 $cur_flags = "''";
572572 }
@@ -574,16 +574,16 @@
575575 SELECT cur_namespace, cur_title, $cur_text, cur_comment, cur_user, cur_user_text, cur_timestamp, cur_minor_edit, $cur_flags
576576 FROM $cur", $fname );
577577
578 - echo wfTimestamp( TS_DB );
579 - echo "......Setting up revision table.\n";
 578+ wfOut( wfTimestamp( TS_DB ) );
 579+ wfOut( "......Setting up revision table.\n" );
580580 $wgDatabase->query( "INSERT INTO $revision (rev_id, rev_page, rev_comment, rev_user, rev_user_text, rev_timestamp,
581581 rev_minor_edit)
582582 SELECT old_id, cur_id, old_comment, old_user, old_user_text,
583583 old_timestamp, old_minor_edit
584584 FROM $old,$cur WHERE old_namespace=cur_namespace AND old_title=cur_title", $fname );
585585
586 - echo wfTimestamp( TS_DB );
587 - echo "......Setting up page table.\n";
 586+ wfOut( wfTimestamp( TS_DB ) );
 587+ wfOut( "......Setting up page table.\n" );
588588 $wgDatabase->query( "INSERT INTO $page (page_id, page_namespace, page_title, page_restrictions, page_counter,
589589 page_is_redirect, page_is_new, page_random, page_touched, page_latest, page_len)
590590 SELECT cur_id, cur_namespace, cur_title, cur_restrictions, cur_counter, cur_is_redirect, cur_is_new,
@@ -591,38 +591,38 @@
592592 FROM $cur,$revision
593593 WHERE cur_id=rev_page AND rev_timestamp=cur_timestamp AND rev_id > {$maxold}", $fname );
594594
595 - echo wfTimestamp( TS_DB );
596 - echo "......Unlocking tables.\n";
 595+ wfOut( wfTimestamp( TS_DB ) );
 596+ wfOut( "......Unlocking tables.\n" );
597597 $wgDatabase->query( "UNLOCK TABLES", $fname );
598598
599 - echo wfTimestamp( TS_DB );
600 - echo "......Renaming old.\n";
 599+ wfOut( wfTimestamp( TS_DB ) );
 600+ wfOut( "......Renaming old.\n" );
601601 $wgDatabase->query( "ALTER TABLE $old RENAME TO $text", $fname );
602602
603 - echo wfTimestamp( TS_DB );
604 - echo "...done.\n";
 603+ wfOut( wfTimestamp( TS_DB ) );
 604+ wfOut( "...done.\n" );
605605 }
606606 }
607607
608608 function do_inverse_timestamp() {
609609 global $wgDatabase;
610610 if( $wgDatabase->fieldExists( 'revision', 'inverse_timestamp' ) ) {
611 - echo "Removing revision.inverse_timestamp and fixing indexes... ";
 611+ wfOut( "Removing revision.inverse_timestamp and fixing indexes... " );
612612 dbsource( archive( 'patch-inverse_timestamp.sql' ), $wgDatabase );
613 - echo "ok\n";
 613+ wfOut( "ok\n" );
614614 } else {
615 - echo "revision timestamp indexes already up to 2005-03-13\n";
 615+ wfOut( "revision timestamp indexes already up to 2005-03-13\n" );
616616 }
617617 }
618618
619619 function do_text_id() {
620620 global $wgDatabase;
621621 if( $wgDatabase->fieldExists( 'revision', 'rev_text_id' ) ) {
622 - echo "...rev_text_id already in place.\n";
 622+ wfOut( "...rev_text_id already in place.\n" );
623623 } else {
624 - echo "Adding rev_text_id field... ";
 624+ wfOut( "Adding rev_text_id field... " );
625625 dbsource( archive( 'patch-rev_text_id.sql' ), $wgDatabase );
626 - echo "ok\n";
 626+ wfOut( "ok\n" );
627627 }
628628 }
629629
@@ -653,25 +653,25 @@
654654 $wgDatabase->freeResult( $result );
655655
656656 if( substr( $info->Type, 0, 3 ) == 'int' ) {
657 - echo "...$field is already a full int ($info->Type).\n";
 657+ wfOut( "...$field is already a full int ($info->Type).\n" );
658658 } else {
659 - echo "Promoting $field from $info->Type to int... ";
 659+ wfOut( "Promoting $field from $info->Type to int... " );
660660
661661 $sql = "ALTER TABLE $tablename MODIFY $field int NOT NULL";
662662 $wgDatabase->query( $sql );
663663
664 - echo "ok\n";
 664+ wfOut( "ok\n" );
665665 }
666666 }
667667
668668 function do_pagelinks_update() {
669669 global $wgDatabase;
670670 if( $wgDatabase->tableExists( 'pagelinks' ) ) {
671 - echo "...already have pagelinks table.\n";
 671+ wfOut( "...already have pagelinks table.\n" );
672672 } else {
673 - echo "Converting links and brokenlinks tables to pagelinks... ";
 673+ wfOut( "Converting links and brokenlinks tables to pagelinks... " );
674674 dbsource( archive( 'patch-pagelinks.sql' ), $wgDatabase );
675 - echo "ok\n";
 675+ wfOut( "ok\n" );
676676 flush();
677677
678678 global $wgCanonicalNamespaceNames;
@@ -687,7 +687,7 @@
688688 global $wgDatabase, $wgContLang;
689689
690690 $ns = intval( $namespace );
691 - echo "Cleaning up broken links for namespace $ns... ";
 691+ wfOut( "Cleaning up broken links for namespace $ns... " );
692692
693693 $pagelinks = $wgDatabase->tableName( 'pagelinks' );
694694 $name = $wgContLang->getNsText( $ns );
@@ -701,25 +701,25 @@
702702 AND pl_title LIKE '$likeprefix:%'";
703703
704704 $wgDatabase->query( $sql, 'do_pagelinks_namespace' );
705 - echo "ok\n";
 705+ wfOut( "ok\n" );
706706 }
707707
708708 function do_drop_img_type() {
709709 global $wgDatabase;
710710
711711 if( $wgDatabase->fieldExists( 'image', 'img_type' ) ) {
712 - echo "Dropping unused img_type field in image table... ";
 712+ wfOut( "Dropping unused img_type field in image table... " );
713713 dbsource( archive( 'patch-drop_img_type.sql' ), $wgDatabase );
714 - echo "ok\n";
 714+ wfOut( "ok\n" );
715715 } else {
716 - echo "No img_type field in image table; Good.\n";
 716+ wfOut( "No img_type field in image table; Good.\n" );
717717 }
718718 }
719719
720720 function do_old_links_update() {
721721 global $wgDatabase;
722722 if( $wgDatabase->tableExists( 'pagelinks' ) ) {
723 - echo "Already have pagelinks; skipping old links table updates.\n";
 723+ wfOut( "Already have pagelinks; skipping old links table updates.\n" );
724724 } else {
725725 convertLinks(); flush();
726726 }
@@ -729,14 +729,14 @@
730730 global $wgDatabase;
731731 $duper = new UserDupes( $wgDatabase );
732732 if( $duper->hasUniqueIndex() ) {
733 - echo "Already have unique user_name index.\n";
 733+ wfOut( "Already have unique user_name index.\n" );
734734 } else {
735735 if( !$duper->clearDupes() ) {
736 - echo "WARNING: This next step will probably fail due to unfixed duplicates...\n";
 736+ wfOut( "WARNING: This next step will probably fail due to unfixed duplicates...\n" );
737737 }
738 - echo "Adding unique index on user_name... ";
 738+ wfOut( "Adding unique index on user_name... " );
739739 dbsource( archive( 'patch-user_nameindex.sql' ), $wgDatabase );
740 - echo "ok\n";
 740+ wfOut( "ok\n" );
741741 }
742742 }
743743
@@ -745,28 +745,28 @@
746746 global $wgDatabase;
747747
748748 if( $wgDatabase->tableExists( 'user_groups' ) ) {
749 - echo "...user_groups table already exists.\n";
 749+ wfOut( "...user_groups table already exists.\n" );
750750 return do_user_groups_reformat();
751751 }
752752
753 - echo "Adding user_groups table... ";
 753+ wfOut( "Adding user_groups table... " );
754754 dbsource( archive( 'patch-user_groups.sql' ), $wgDatabase );
755 - echo "ok\n";
 755+ wfOut( "ok\n" );
756756
757757 if( !$wgDatabase->tableExists( 'user_rights' ) ) {
758758 if( $wgDatabase->fieldExists( 'user', 'user_rights' ) ) {
759 - echo "Upgrading from a 1.3 or older database? Breaking out user_rights for conversion...";
 759+ wfOut( "Upgrading from a 1.3 or older database? Breaking out user_rights for conversion..." );
760760 dbsource( archive( 'patch-user_rights.sql' ), $wgDatabase );
761 - echo "ok\n";
 761+ wfOut( "ok\n" );
762762 } else {
763 - echo "*** WARNING: couldn't locate user_rights table or field for upgrade.\n";
764 - echo "*** You may need to manually configure some sysops by manipulating\n";
765 - echo "*** the user_groups table.\n";
 763+ wfOut( "*** WARNING: couldn't locate user_rights table or field for upgrade.\n" );
 764+ wfOut( "*** You may need to manually configure some sysops by manipulating\n" );
 765+ wfOut( "*** the user_groups table.\n" );
766766 return;
767767 }
768768 }
769769
770 - echo "Converting user_rights table to user_groups... ";
 770+ wfOut( "Converting user_rights table to user_groups... " );
771771 $result = $wgDatabase->select( 'user_rights',
772772 array( 'ur_user', 'ur_rights' ),
773773 array( "ur_rights != ''" ),
@@ -786,7 +786,7 @@
787787 }
788788 }
789789 $wgDatabase->freeResult( $result );
790 - echo "ok\n";
 790+ wfOut( "ok\n" );
791791 }
792792
793793 function do_user_groups_reformat() {
@@ -797,20 +797,20 @@
798798 if( $info->type() == 'int' ) {
799799 $oldug = $wgDatabase->tableName( 'user_groups' );
800800 $newug = $wgDatabase->tableName( 'user_groups_bogus' );
801 - echo "user_groups is in bogus intermediate format. Renaming to $newug... ";
 801+ wfOut( "user_groups is in bogus intermediate format. Renaming to $newug... " );
802802 $wgDatabase->query( "ALTER TABLE $oldug RENAME TO $newug" );
803 - echo "ok\n";
 803+ wfOut( "ok\n" );
804804
805 - echo "Re-adding fresh user_groups table... ";
 805+ wfOut( "Re-adding fresh user_groups table... " );
806806 dbsource( archive( 'patch-user_groups.sql' ), $wgDatabase );
807 - echo "ok\n";
 807+ wfOut( "ok\n" );
808808
809 - echo "***\n";
810 - echo "*** WARNING: You will need to manually fix up user permissions in the user_groups\n";
811 - echo "*** table. Old 1.5 alpha versions did some pretty funky stuff...\n";
812 - echo "***\n";
 809+ wfOut( "***\n" );
 810+ wfOut( "*** WARNING: You will need to manually fix up user permissions in the user_groups\n" );
 811+ wfOut( "*** table. Old 1.5 alpha versions did some pretty funky stuff...\n" );
 812+ wfOut( "***\n" );
813813 } else {
814 - echo "...user_groups is in current format.\n";
 814+ wfOut( "...user_groups is in current format.\n" );
815815 }
816816
817817 }
@@ -822,11 +822,11 @@
823823 $info = $wgDatabase->fieldInfo( 'watchlist', 'wl_notificationtimestamp' );
824824
825825 if( !$info->nullable() ) {
826 - echo "Making wl_notificationtimestamp nullable... ";
 826+ wfOut( "Making wl_notificationtimestamp nullable... " );
827827 dbsource( archive( 'patch-watchlist-null.sql' ), $wgDatabase );
828 - echo "ok\n";
 828+ wfOut( "ok\n" );
829829 } else {
830 - echo "...wl_notificationtimestamp is already nullable.\n";
 830+ wfOut( "...wl_notificationtimestamp is already nullable.\n" );
831831 }
832832
833833 }
@@ -837,13 +837,13 @@
838838 function do_page_random_update() {
839839 global $wgDatabase;
840840
841 - echo "Setting page_random to a random value on rows where it equals 0...";
 841+ wfOut( "Setting page_random to a random value on rows where it equals 0..." );
842842
843843 $page = $wgDatabase->tableName( 'page' );
844844 $wgDatabase->query( "UPDATE $page SET page_random = RAND() WHERE page_random = 0", 'do_page_random_update' );
845845 $rows = $wgDatabase->affectedRows();
846846
847 - echo "changed $rows rows\n";
 847+ wfOut( "changed $rows rows\n" );
848848 }
849849
850850 function do_templatelinks_update() {
@@ -851,12 +851,12 @@
852852 $fname = 'do_templatelinks_update';
853853
854854 if ( $wgDatabase->tableExists( 'templatelinks' ) ) {
855 - echo "...templatelinks table already exists\n";
 855+ wfOut( "...templatelinks table already exists\n" );
856856 return;
857857 }
858 - echo "Creating templatelinks table...\n";
 858+ wfOut( "Creating templatelinks table...\n" );
859859 dbsource( archive('patch-templatelinks.sql'), $wgDatabase );
860 - echo "Populating...\n";
 860+ wfOut( "Populating...\n" );
861861 if ( isset( $wgLoadBalancer ) && $wgLoadBalancer->getServerCount() > 1 ) {
862862 // Slow, replication-friendly update
863863 $res = $wgDatabase->select( 'pagelinks', array( 'pl_from', 'pl_namespace', 'pl_title' ),
@@ -893,14 +893,14 @@
894894 ), $fname
895895 );
896896 }
897 - echo "Done. Please run maintenance/refreshLinks.php for a more thorough templatelinks update.\n";
 897+ wfOut( "Done. Please run maintenance/refreshLinks.php for a more thorough templatelinks update.\n" );
898898 }
899899
900900 // Add index on ( rc_namespace, rc_user_text ) [Jul. 2006]
901901 // Add index on ( rc_user_text, rc_timestamp ) [Nov. 2006]
902902 function do_rc_indices_update() {
903903 global $wgDatabase;
904 - echo( "Checking for additional recent changes indices...\n" );
 904+ wfOut( "Checking for additional recent changes indices...\n" );
905905
906906 $indexes = array(
907907 'rc_ns_usertext' => 'patch-recentchanges-utindex.sql',
@@ -910,33 +910,33 @@
911911 foreach( $indexes as $index => $patch ) {
912912 $info = $wgDatabase->indexInfo( 'recentchanges', $index, __METHOD__ );
913913 if( !$info ) {
914 - echo( "...index `{$index}` not found; adding..." );
 914+ wfOut( "...index `{$index}` not found; adding..." );
915915 dbsource( archive( $patch ) );
916 - echo( "done.\n" );
 916+ wfOut( "done.\n" );
917917 } else {
918 - echo( "...index `{$index}` seems ok.\n" );
 918+ wfOut( "...index `{$index}` seems ok.\n" );
919919 }
920920 }
921921 }
922922
923923 function index_has_field($table, $index, $field) {
924924 global $wgDatabase;
925 - echo( "Checking if $table index $index includes field $field...\n" );
 925+ wfOut( "Checking if $table index $index includes field $field...\n" );
926926 $info = $wgDatabase->indexInfo( $table, $index, __METHOD__ );
927927 if( $info ) {
928928 foreach($info as $row) {
929929 if($row->Column_name == $field) {
930 - echo( "...index $index on table $table seems to be ok\n" );
 930+ wfOut( "...index $index on table $table seems to be ok\n" );
931931 return true;
932932 }
933933 }
934934 }
935 - echo( "...index $index on table $table has no field $field; adding\n" );
 935+ wfOut( "...index $index on table $table has no field $field; adding\n" );
936936 return false;
937937 }
938938
939939 function do_backlinking_indices_update() {
940 - echo( "Checking for backlinking indices...\n" );
 940+ wfOut( "Checking for backlinking indices...\n" );
941941 if (!index_has_field('pagelinks', 'pl_namespace', 'pl_from') ||
942942 !index_has_field('templatelinks', 'tl_namespace', 'tl_from') ||
943943 !index_has_field('imagelinks', 'il_to', 'il_from'))
@@ -946,7 +946,7 @@
947947 }
948948
949949 function do_categorylinks_indices_update() {
950 - echo( "Checking for categorylinks indices...\n" );
 950+ wfOut( "Checking for categorylinks indices...\n" );
951951 if (!index_has_field('categorylinks', 'cl_sortkey', 'cl_from'))
952952 {
953953 dbsource( archive( 'patch-categorylinksindex.sql' ) );
@@ -956,16 +956,15 @@
957957 function do_stats_init() {
958958 // Sometimes site_stats table is not properly populated.
959959 global $wgDatabase;
960 - echo "Checking site_stats row...";
 960+ wfOut( "Checking site_stats row..." );
961961 $row = $wgDatabase->selectRow( 'site_stats', '*', array( 'ss_row_id' => 1 ), __METHOD__ );
962962 if( $row === false ) {
963 - echo "data is missing! rebuilding...\n";
964 -
 963+ wfOut( "data is missing! rebuilding...\n" );
965964 global $IP;
966965 require_once "$IP/maintenance/initStats.inc";
967966 wfInitStats();
968967 } else {
969 - echo "ok.\n";
 968+ wfOut( "ok.\n" );
970969 }
971970 }
972971
@@ -973,9 +972,9 @@
974973 global $wgDatabase;
975974 # We can't guarantee that the user will be able to use TRUNCATE,
976975 # but we know that DELETE is available to us
977 - echo( "Purging caches..." );
 976+ wfOut( "Purging caches..." );
978977 $wgDatabase->delete( 'objectcache', '*', __METHOD__ );
979 - echo( "done.\n" );
 978+ wfOut( "done.\n" );
980979 }
981980
982981 function do_all_updates( $shared = false, $purge = true ) {
@@ -1019,15 +1018,14 @@
10201019 }
10211020
10221021
1023 - echo "Deleting old default messages (this may take a long time!)..."; flush();
 1022+ wfOut( "Deleting old default messages (this may take a long time!)..." );
10241023 deleteDefaultMessages();
1025 - echo "Done\n"; flush();
 1024+ wfOut( "Done\n" );
10261025
1027 - do_stats_init(); flush();
 1026+ do_stats_init();
10281027
10291028 if( $purge ) {
10301029 purge_cache();
1031 - flush();
10321030 }
10331031 }
10341032
@@ -1053,14 +1051,14 @@
10541052 $patch2 = 'patch-page_restrictions_sortkey.sql';
10551053
10561054 if ( $wgDatabase->tableExists( $name ) ) {
1057 - echo "...$name table already exists.\n";
 1055+ wfOut( "...$name table already exists.\n" );
10581056 } else {
1059 - echo "Creating $name table...";
 1057+ wfOut( "Creating $name table..." );
10601058 dbsource( archive($patch), $wgDatabase );
10611059 dbsource( archive($patch2), $wgDatabase );
1062 - echo "ok\n";
 1060+ wfOut( "ok\n" );
10631061
1064 - echo "Migrating old restrictions to new table...";
 1062+ wfOut( "Migrating old restrictions to new table..." );
10651063
10661064 $res = $wgDatabase->select( 'page', array( 'page_id', 'page_restrictions' ), array("page_restrictions!=''", "page_restrictions!='edit=:move='"), __METHOD__ );
10671065
@@ -1112,7 +1110,7 @@
11131111 __METHOD__ );
11141112 }
11151113 }
1116 - print "ok\n";
 1114+ wfOut( "ok\n" );
11171115 }
11181116
11191117 }
@@ -1270,12 +1268,12 @@
12711269 $newpath = array();
12721270 if( $wgDBmwschema === 'mediawiki' ) {
12731271 if (!array_key_exists( 'search_path', $conf ) or strpos( $conf['search_path'],$wgDBmwschema ) === false ) {
1274 - echo "Adding in schema \"$wgDBmwschema\" to search_path for user \"$wgDBuser\"\n";
 1272+ wfOut( "Adding in schema \"$wgDBmwschema\" to search_path for user \"$wgDBuser\"\n" );
12751273 $newpath[$wgDBmwschema] = 1;
12761274 }
12771275 }
12781276 if( !array_key_exists( 'search_path', $conf ) or strpos( $conf['search_path'],$wgDBts2schema ) === false ) {
1279 - echo "Adding in schema \"$wgDBts2schema\" to search_path for user \"$wgDBuser\"\n";
 1277+ wfOut( "Adding in schema \"$wgDBts2schema\" to search_path for user \"$wgDBuser\"\n" );
12801278 $newpath[$wgDBts2schema] = 1;
12811279 }
12821280 $searchpath = implode( ',', array_keys( $newpath ) );
@@ -1285,7 +1283,7 @@
12861284 }
12871285 else {
12881286 $path = $conf['search_path'];
1289 - echo "... search_path for user \"$wgDBuser\" looks correct ($path)\n";
 1287+ wfOut( "... search_path for user \"$wgDBuser\" looks correct ($path)\n" );
12901288 }
12911289 $goodconf = array(
12921290 'client_min_messages' => 'error',
@@ -1295,12 +1293,12 @@
12961294 foreach( array_keys( $goodconf ) AS $key ) {
12971295 $value = $goodconf[$key];
12981296 if( !array_key_exists( $key, $conf ) or $conf[$key] !== $value ) {
1299 - echo "Setting $key to '$value' for user \"$wgDBuser\"\n";
 1297+ wfOut( "Setting $key to '$value' for user \"$wgDBuser\"\n" );
13001298 $wgDatabase->doQuery( "ALTER USER $wgDBuser SET $key = '$value'" );
13011299 $wgDatabase->doQuery( "SET $key = '$value'" );
13021300 }
13031301 else {
1304 - echo "... default value of \"$key\" is correctly set to \"$value\" for user \"$wgDBuser\"\n";
 1302+ wfOut( "... default value of \"$key\" is correctly set to \"$value\" for user \"$wgDBuser\"\n" );
13051303 }
13061304 }
13071305
@@ -1414,62 +1412,62 @@
14151413
14161414 foreach ($newsequences as $ns) {
14171415 if ($wgDatabase->sequenceExists($ns)) {
1418 - echo "... sequence \"$ns\" already exists\n";
 1416+ wfOut( "... sequence \"$ns\" already exists\n" );
14191417 continue;
14201418 }
14211419
1422 - echo "Creating sequence \"$ns\"\n";
 1420+ wfOut( "Creating sequence \"$ns\"\n" );
14231421 $wgDatabase->query("CREATE SEQUENCE $ns");
14241422 }
14251423
14261424 foreach ($newtables as $nt) {
14271425 if ($wgDatabase->tableExists($nt[0])) {
1428 - echo "... table \"$nt[0]\" already exists\n";
 1426+ wfOut( "... table \"$nt[0]\" already exists\n" );
14291427 continue;
14301428 }
14311429
1432 - echo "Creating table \"$nt[0]\"\n";
 1430+ wfOut( "Creating table \"$nt[0]\"\n" );
14331431 dbsource(archive($nt[1]));
14341432 }
14351433
14361434 ## Needed before newcols
14371435 if ($wgDatabase->tableExists("archive2")) {
1438 - echo "Converting \"archive2\" back to normal archive table\n";
 1436+ wfOut( "Converting \"archive2\" back to normal archive table\n" );
14391437 if ($wgDatabase->ruleExists("archive", "archive_insert")) {
1440 - echo "Dropping rule \"archive_insert\"\n";
 1438+ wfOut( "Dropping rule \"archive_insert\"\n" );
14411439 $wgDatabase->query("DROP RULE archive_insert ON archive");
14421440 }
14431441 if ($wgDatabase->ruleExists("archive", "archive_delete")) {
1444 - echo "Dropping rule \"archive_delete\"\n";
 1442+ wfOut( "Dropping rule \"archive_delete\"\n" );
14451443 $wgDatabase->query("DROP RULE archive_delete ON archive");
14461444 }
14471445 dbsource(archive("patch-remove-archive2.sql"));
14481446 }
14491447 else
1450 - echo "... obsolete table \"archive2\" does not exist\n";
 1448+ wfOut( "... obsolete table \"archive2\" does not exist\n" );
14511449
14521450 foreach ($newcols as $nc) {
14531451 $fi = $wgDatabase->fieldInfo($nc[0], $nc[1]);
14541452 if (!is_null($fi)) {
1455 - echo "... column \"$nc[0].$nc[1]\" already exists\n";
 1453+ wfOut( "... column \"$nc[0].$nc[1]\" already exists\n" );
14561454 continue;
14571455 }
14581456
1459 - echo "Adding column \"$nc[0].$nc[1]\"\n";
 1457+ wfOut( "Adding column \"$nc[0].$nc[1]\"\n" );
14601458 $wgDatabase->query("ALTER TABLE $nc[0] ADD $nc[1] $nc[2]");
14611459 }
14621460
14631461 foreach ($typechanges as $tc) {
14641462 $fi = $wgDatabase->fieldInfo($tc[0], $tc[1]);
14651463 if (is_null($fi)) {
1466 - echo "... error: expected column $tc[0].$tc[1] to exist\n";
 1464+ wfOut( "... error: expected column $tc[0].$tc[1] to exist\n" );
14671465 exit(1);
14681466 }
14691467
14701468 if ($fi->type() === $tc[2])
1471 - echo "... column \"$tc[0].$tc[1]\" is already of type \"$tc[2]\"\n";
 1469+ wfOut( "... column \"$tc[0].$tc[1]\" is already of type \"$tc[2]\"\n" );
14721470 else {
1473 - echo "Changing column type of \"$tc[0].$tc[1]\" from \"{$fi->type()}\" to \"$tc[2]\"\n";
 1471+ wfOut( "Changing column type of \"$tc[0].$tc[1]\" from \"{$fi->type()}\" to \"$tc[2]\"\n" );
14741472 $sql = "ALTER TABLE $tc[0] ALTER $tc[1] TYPE $tc[2]";
14751473 if (strlen($tc[3])) {
14761474 $default = array();
@@ -1486,78 +1484,78 @@
14871485 }
14881486
14891487 if ($wgDatabase->fieldInfo('oldimage','oi_deleted')->type() !== 'smallint') {
1490 - echo "Changing \"oldimage.oi_deleted\" to type \"smallint\"\n";
 1488+ wfOut( "Changing \"oldimage.oi_deleted\" to type \"smallint\"\n" );
14911489 $wgDatabase->query( "ALTER TABLE oldimage ALTER oi_deleted DROP DEFAULT" );
14921490 $wgDatabase->query( "ALTER TABLE oldimage ALTER oi_deleted TYPE SMALLINT USING (oi_deleted::smallint)" );
14931491 $wgDatabase->query( "ALTER TABLE oldimage ALTER oi_deleted SET DEFAULT 0" );
14941492 }
14951493 else
1496 - echo "... column \"oldimage.oi_deleted\" is already of type \"smallint\"\n";
 1494+ wfOut( "... column \"oldimage.oi_deleted\" is already of type \"smallint\"\n" );
14971495
14981496
14991497 foreach ($newindexes as $ni) {
15001498 if (pg_index_exists($ni[0], $ni[1])) {
1501 - echo "... index \"$ni[1]\" on table \"$ni[0]\" already exists\n";
 1499+ wfOut( "... index \"$ni[1]\" on table \"$ni[0]\" already exists\n" );
15021500 continue;
15031501 }
1504 - echo "Creating index \"$ni[1]\" on table \"$ni[0]\" $ni[2]\n";
 1502+ wfOut( "Creating index \"$ni[1]\" on table \"$ni[0]\" $ni[2]\n" );
15051503 $wgDatabase->query( "CREATE INDEX $ni[1] ON $ni[0] $ni[2]" );
15061504 }
15071505
15081506 foreach ($newrules as $nr) {
15091507 if ($wgDatabase->ruleExists($nr[0], $nr[1])) {
1510 - echo "... rule \"$nr[1]\" on table \"$nr[0]\" already exists\n";
 1508+ wfOut( "... rule \"$nr[1]\" on table \"$nr[0]\" already exists\n" );
15111509 continue;
15121510 }
1513 - echo "Adding rule \"$nr[1]\" to table \"$nr[0]\"\n";
 1511+ wfOut( "Adding rule \"$nr[1]\" to table \"$nr[0]\"\n" );
15141512 dbsource(archive($nr[2]));
15151513 }
15161514
15171515 if ($wgDatabase->hasConstraint("oldimage_oi_name_fkey")) {
1518 - echo "Making foriegn key on table \"oldimage\" (to image) a cascade delete\n";
 1516+ wfOut( "Making foriegn key on table \"oldimage\" (to image) a cascade delete\n" );
15191517 $wgDatabase->query( "ALTER TABLE oldimage DROP CONSTRAINT oldimage_oi_name_fkey" );
15201518 $wgDatabase->query( "ALTER TABLE oldimage ADD CONSTRAINT oldimage_oi_name_fkey_cascade ".
15211519 "FOREIGN KEY (oi_name) REFERENCES image(img_name) ON DELETE CASCADE" );
15221520 }
15231521 else
1524 - echo "... table \"oldimage\" has correct cascade delete foreign key to image\n";
 1522+ wfOut( "... table \"oldimage\" has correct cascade delete foreign key to image\n" );
15251523
15261524 if (!$wgDatabase->triggerExists("page", "page_deleted")) {
1527 - echo "Adding function and trigger \"page_deleted\" to table \"page\"\n";
 1525+ wfOut( "Adding function and trigger \"page_deleted\" to table \"page\"\n" );
15281526 dbsource(archive('patch-page_deleted.sql'));
15291527 }
15301528 else
1531 - echo "... table \"page\" has \"page_deleted\" trigger\n";
 1529+ wfOut( "... table \"page\" has \"page_deleted\" trigger\n" );
15321530
15331531 $fi = $wgDatabase->fieldInfo("recentchanges", "rc_cur_id");
15341532 if (!$fi->nullable()) {
1535 - echo "Removing NOT NULL constraint from \"recentchanges.rc_cur_id\"\n";
 1533+ wfOut( "Removing NOT NULL constraint from \"recentchanges.rc_cur_id\"\n" );
15361534 dbsource(archive('patch-rc_cur_id-not-null.sql'));
15371535 }
15381536 else
1539 - echo "... column \"recentchanges.rc_cur_id\" has a NOT NULL constraint\n";
 1537+ wfOut( "... column \"recentchanges.rc_cur_id\" has a NOT NULL constraint\n" );
15401538
15411539 $pu = pg_describe_index("pagelink_unique");
15421540 if (!is_null($pu) && ($pu[0] != "pl_from" || $pu[1] != "pl_namespace" || $pu[2] != "pl_title")) {
1543 - echo "Dropping obsolete version of index \"pagelink_unique index\"\n";
 1541+ wfOut( "Dropping obsolete version of index \"pagelink_unique index\"\n" );
15441542 $wgDatabase->query("DROP INDEX pagelink_unique");
15451543 $pu = null;
15461544 }
15471545 else
1548 - echo "... obsolete version of index \"pagelink_unique index\" does not exist\n";
 1546+ wfOut( "... obsolete version of index \"pagelink_unique index\" does not exist\n" );
15491547
15501548 if (is_null($pu)) {
1551 - echo "Creating index \"pagelink_unique index\"\n";
 1549+ wfOut( "Creating index \"pagelink_unique index\"\n" );
15521550 $wgDatabase->query("CREATE UNIQUE INDEX pagelink_unique ON pagelinks (pl_from,pl_namespace,pl_title)");
15531551 }
15541552 else
1555 - echo "... index \"pagelink_unique_index\" aready exists\n";
 1553+ wfOut( "... index \"pagelink_unique_index\" already exists\n" );
15561554
15571555 if (pg_fkey_deltype("revision_rev_user_fkey") == 'r') {
1558 - echo "... constraint \"revision_rev_user_fkey\" is ON DELETE RESTRICT\n";
 1556+ wfOut( "... constraint \"revision_rev_user_fkey\" is ON DELETE RESTRICT\n" );
15591557 }
15601558 else {
1561 - echo "Changing constraint \"revision_rev_user_fkey\" to ON DELETE RESTRICT\n";
 1559+ wfOut( "Changing constraint \"revision_rev_user_fkey\" to ON DELETE RESTRICT\n" );
15621560 dbsource(archive('patch-revision_rev_user_fkey.sql'));
15631561 }
15641562
@@ -1565,29 +1563,29 @@
15661564 # Add missing extension tables
15671565 foreach ( $wgExtNewTables as $nt ) {
15681566 if ($wgDatabase->tableExists($nt[0])) {
1569 - echo "... table \"$nt[0]\" already exists\n";
 1567+ wfOut( "... table \"$nt[0]\" already exists\n" );
15701568 continue;
15711569 }
1572 - echo "Creating table \"$nt[0]\"\n";
 1570+ wfOut( "Creating table \"$nt[0]\"\n" );
15731571 dbsource($nt[1]);
15741572 }
15751573 # Add missing extension fields
15761574 foreach ( $wgExtPGNewFields as $nc ) {
15771575 $fi = $wgDatabase->fieldInfo($nc[0], $nc[1]);
15781576 if (!is_null($fi)) {
1579 - echo "... column \"$nc[0].$nc[1]\" already exists\n";
 1577+ wfOut( "... column \"$nc[0].$nc[1]\" already exists\n" );
15801578 continue;
15811579 }
1582 - echo "Adding column \"$nc[0].$nc[1]\"\n";
 1580+ wfOut( "Adding column \"$nc[0].$nc[1]\"\n" );
15831581 $wgDatabase->query( "ALTER TABLE $nc[0] ADD $nc[1] $nc[2]" );
15841582 }
15851583 # Add missing extension indexes
15861584 foreach ( $wgExtNewIndexes as $ni ) {
15871585 if (pg_index_exists($ni[0], $ni[1])) {
1588 - echo "... index \"$ni[1]\" on table \"$ni[0]\" already exists\n";
 1586+ wfOut( "... index \"$ni[1]\" on table \"$ni[0]\" already exists\n" );
15891587 continue;
15901588 }
1591 - echo "Creating index \"$ni[1]\" on table \"$ni[0]\"\n";
 1589+ wfOut( "Creating index \"$ni[1]\" on table \"$ni[0]\"\n" );
15921590 dbsource($ni[2]);
15931591 }
15941592
Index: branches/REL1_12/phase3/maintenance/userDupes.inc
@@ -39,7 +39,7 @@
4040 $fname = 'UserDupes::hasUniqueIndex';
4141 $info = $this->db->indexInfo( 'user', 'user_name', $fname );
4242 if( !$info ) {
43 - echo "WARNING: doesn't seem to have user_name index at all!\n";
 43+ wfOut( "WARNING: doesn't seem to have user_name index at all!\n" );
4444 return false;
4545 }
4646
@@ -86,11 +86,11 @@
8787
8888 $this->lock();
8989
90 - echo "Checking for duplicate accounts...\n";
 90+ wfOut( "Checking for duplicate accounts...\n" );
9191 $dupes = $this->getDupes();
9292 $count = count( $dupes );
9393
94 - echo "Found $count accounts with duplicate records on ".wfWikiID().".\n";
 94+ wfOut( "Found $count accounts with duplicate records on ".wfWikiID().".\n" );
9595 $this->trimmed = 0;
9696 $this->reassigned = 0;
9797 $this->failed = 0;
@@ -100,34 +100,34 @@
101101
102102 $this->unlock();
103103
104 - echo "\n";
 104+ wfOut( "\n" );
105105
106106 if( $this->reassigned > 0 ) {
107107 if( $doDelete ) {
108 - echo "$this->reassigned duplicate accounts had edits reassigned to a canonical record id.\n";
 108+ wfOut( "$this->reassigned duplicate accounts had edits reassigned to a canonical record id.\n" );
109109 } else {
110 - echo "$this->reassigned duplicate accounts need to have edits reassigned.\n";
 110+ wfOut( "$this->reassigned duplicate accounts need to have edits reassigned.\n" );
111111 }
112112 }
113113
114114 if( $this->trimmed > 0 ) {
115115 if( $doDelete ) {
116 - echo "$this->trimmed duplicate user records were deleted from ".wfWikiID().".\n";
 116+ wfOut( "$this->trimmed duplicate user records were deleted from ".wfWikiID().".\n" );
117117 } else {
118 - echo "$this->trimmed duplicate user accounts were found on ".wfWikiID()." which can be removed safely.\n";
 118+ wfOut( "$this->trimmed duplicate user accounts were found on ".wfWikiID()." which can be removed safely.\n" );
119119 }
120120 }
121121
122122 if( $this->failed > 0 ) {
123 - echo "Something terribly awry; $this->failed duplicate accounts were not removed.\n";
 123+ wfOut( "Something terribly awry; $this->failed duplicate accounts were not removed.\n" );
124124 return false;
125125 }
126126
127127 if( $this->trimmed == 0 || $doDelete ) {
128 - echo "It is now safe to apply the unique index on user_name.\n";
 128+ wfOut( "It is now safe to apply the unique index on user_name.\n" );
129129 return true;
130130 } else {
131 - echo "Run this script again with the --fix option to automatically delete them.\n";
 131+ wfOut( "Run this script again with the --fix option to automatically delete them.\n" );
132132 return false;
133133 }
134134 }
@@ -209,36 +209,36 @@
210210
211211 $firstRow = $this->db->fetchObject( $result );
212212 $firstId = $firstRow->user_id;
213 - echo "Record that will be used for '$name' is user_id=$firstId\n";
 213+ wfOut( "Record that will be used for '$name' is user_id=$firstId\n" );
214214
215215 while( $row = $this->db->fetchObject( $result ) ) {
216216 $dupeId = $row->user_id;
217 - echo "... dupe id $dupeId: ";
 217+ wfOut( "... dupe id $dupeId: " );
218218 $edits = $this->editCount( $dupeId );
219219 if( $edits > 0 ) {
220220 $this->reassigned++;
221 - echo "has $edits edits! ";
 221+ wfOut( "has $edits edits! " );
222222 if( $doDelete ) {
223223 $this->reassignEdits( $dupeId, $firstId );
224224 $newEdits = $this->editCount( $dupeId );
225225 if( $newEdits == 0 ) {
226 - echo "confirmed cleaned. ";
 226+ wfOut( "confirmed cleaned. " );
227227 } else {
228228 $this->failed++;
229 - echo "WARNING! $newEdits remaining edits for $dupeId; NOT deleting user.\n";
 229+ wfOut( "WARNING! $newEdits remaining edits for $dupeId; NOT deleting user.\n" );
230230 continue;
231231 }
232232 } else {
233 - echo "(will need to reassign edits on fix)";
 233+ wfOut( "(will need to reassign edits on fix)" );
234234 }
235235 } else {
236 - echo "ok, no edits. ";
 236+ wfOut( "ok, no edits. " );
237237 }
238238 $this->trimmed++;
239239 if( $doDelete ) {
240240 $this->trimAccount( $dupeId );
241241 }
242 - echo "\n";
 242+ wfOut( "\n" );
243243 }
244244 $this->db->freeResult( $result );
245245 }
@@ -300,12 +300,12 @@
301301 */
302302 function reassignEditsOn( $table, $field, $from, $to ) {
303303 $fname = 'UserDupes::reassignEditsOn';
304 - echo "reassigning on $table... ";
 304+ wfOut( "reassigning on $table... " );
305305 $this->db->update( $table,
306306 array( $field => $to ),
307307 array( $field => $from ),
308308 $fname );
309 - echo "ok. ";
 309+ wfOut( "ok. " );
310310 }
311311
312312 /**
@@ -315,9 +315,9 @@
316316 */
317317 function trimAccount( $userid ) {
318318 $fname = 'UserDupes::trimAccount';
319 - echo "deleting...";
 319+ wfOut( "deleting..." );
320320 $this->db->delete( 'user', array( 'user_id' => $userid ), $fname );
321 - echo " ok";
 321+ wfOut( " ok" );
322322 }
323323
324324 }
Index: branches/REL1_12/phase3/maintenance/convertLinks.inc
@@ -8,11 +8,11 @@
99 function convertLinks() {
1010 global $wgDBtype;
1111 if( $wgDBtype == 'postgres' ) {
12 - print "Links table already ok on Postgres.\n";
 12+ wfOut( "Links table already ok on Postgres.\n" );
1313 return;
1414 }
1515
16 - print "Converting links table to ID-ID...\n";
 16+ wfOut( "Converting links table to ID-ID...\n" );
1717
1818 global $wgLang, $wgDBserver, $wgDBadminuser, $wgDBadminpassword, $wgDBname;
1919 global $noKeys, $logPerformance, $fh;
@@ -47,7 +47,7 @@
4848
4949 $res = $dbw->query( "SELECT l_from FROM $links LIMIT 1" );
5050 if ( $dbw->fieldType( $res, 0 ) == "int" ) {
51 - print "Schema already converted\n";
 51+ wfOut( "Schema already converted\n" );
5252 return;
5353 }
5454
@@ -57,13 +57,13 @@
5858 $dbw->freeResult( $res );
5959
6060 if ( $numRows == 0 ) {
61 - print "Updating schema (no rows to convert)...\n";
 61+ wfOut( "Updating schema (no rows to convert)...\n" );
6262 createTempTable();
6363 } else {
6464 if ( $logPerformance ) { $fh = fopen ( $perfLogFilename, "w" ); }
6565 $baseTime = $startTime = getMicroTime();
6666 # Create a title -> cur_id map
67 - print "Loading IDs from $cur table...\n";
 67+ wfOut( "Loading IDs from $cur table...\n" );
6868 performanceLog ( "Reading $numRows rows from cur table...\n" );
6969 performanceLog ( "rows read vs seconds elapsed:\n" );
7070
@@ -81,13 +81,13 @@
8282 if ($reportCurReadProgress) {
8383 if (($curRowsRead % $curReadReportInterval) == 0) {
8484 performanceLog( $curRowsRead . " " . (getMicroTime() - $baseTime) . "\n" );
85 - print "\t$curRowsRead rows of $cur table read.\n";
 85+ wfOut( "\t$curRowsRead rows of $cur table read.\n" );
8686 }
8787 }
8888 }
8989 $dbw->freeResult( $res );
9090 $dbw->bufferResults( true );
91 - print "Finished loading IDs.\n\n";
 91+ wfOut( "Finished loading IDs.\n\n" );
9292 performanceLog( "Took " . (getMicroTime() - $baseTime) . " seconds to load IDs.\n\n" );
9393 #--------------------------------------------------------------------
9494
@@ -96,7 +96,7 @@
9797 createTempTable();
9898 performanceLog( "Resetting timer.\n\n" );
9999 $baseTime = getMicroTime();
100 - print "Processing $numRows rows from $links table...\n";
 100+ wfOut( "Processing $numRows rows from $links table...\n" );
101101 performanceLog( "Processing $numRows rows from $links table...\n" );
102102 performanceLog( "rows inserted vs seconds elapsed:\n" );
103103
@@ -126,19 +126,19 @@
127127 }
128128 }
129129 $dbw->freeResult($res);
130 - #print "rowOffset: $rowOffset\ttuplesAdded: $tuplesAdded\tnumBadLinks: $numBadLinks\n";
 130+ #wfOut( "rowOffset: $rowOffset\ttuplesAdded: $tuplesAdded\tnumBadLinks: $numBadLinks\n" );
131131 if ( $tuplesAdded != 0 ) {
132132 if ($reportLinksConvProgress) {
133 - print "Inserting $tuplesAdded tuples into $links_temp...";
 133+ wfOut( "Inserting $tuplesAdded tuples into $links_temp..." );
134134 }
135135 $dbw->query( implode("",$sqlWrite) );
136136 $totalTuplesInserted += $tuplesAdded;
137137 if ($reportLinksConvProgress)
138 - print " done. Total $totalTuplesInserted tuples inserted.\n";
 138+ wfOut( " done. Total $totalTuplesInserted tuples inserted.\n" );
139139 performanceLog( $totalTuplesInserted . " " . (getMicroTime() - $baseTime) . "\n" );
140140 }
141141 }
142 - print "$totalTuplesInserted valid titles and $numBadLinks invalid titles were processed.\n\n";
 142+ wfOut( "$totalTuplesInserted valid titles and $numBadLinks invalid titles were processed.\n\n" );
143143 performanceLog( "$totalTuplesInserted valid titles and $numBadLinks invalid titles were processed.\n" );
144144 performanceLog( "Total execution time: " . (getMicroTime() - $startTime) . " seconds.\n" );
145145 if ( $logPerformance ) { fclose ( $fh ); }
@@ -148,25 +148,25 @@
149149 if ( $overwriteLinksTable ) {
150150 $dbConn = Database::newFromParams( $wgDBserver, $wgDBadminuser, $wgDBadminpassword, $wgDBname );
151151 if (!($dbConn->isOpen())) {
152 - print "Opening connection to database failed.\n";
 152+ wfOut( "Opening connection to database failed.\n" );
153153 return;
154154 }
155155 # Check for existing links_backup, and delete it if it exists.
156 - print "Dropping backup links table if it exists...";
 156+ wfOut( "Dropping backup links table if it exists..." );
157157 $dbConn->query( "DROP TABLE IF EXISTS $links_backup", DB_MASTER);
158 - print " done.\n";
 158+ wfOut( " done.\n" );
159159
160160 # Swap in the new table, and move old links table to links_backup
161 - print "Swapping tables '$links' to '$links_backup'; '$links_temp' to '$links'...";
 161+ wfOut( "Swapping tables '$links' to '$links_backup'; '$links_temp' to '$links'..." );
162162 $dbConn->query( "RENAME TABLE links TO $links_backup, $links_temp TO $links", DB_MASTER );
163 - print " done.\n\n";
 163+ wfOut( " done.\n\n" );
164164
165165 $dbConn->close();
166 - print "Conversion complete. The old table remains at $links_backup;\n";
167 - print "delete at your leisure.\n";
 166+ wfOut( "Conversion complete. The old table remains at $links_backup;\n" );
 167+ wfOut( "delete at your leisure.\n" );
168168 } else {
169 - print "Conversion complete. The converted table is at $links_temp;\n";
170 - print "the original links table is unchanged.\n";
 169+ wfOut( "Conversion complete. The converted table is at $links_temp;\n" );
 170+ wfOut( "the original links table is unchanged.\n" );
171171 }
172172 }
173173
@@ -178,16 +178,16 @@
179179 $dbConn = Database::newFromParams( $wgDBserver, $wgDBadminuser, $wgDBadminpassword, $wgDBname );
180180
181181 if (!($dbConn->isOpen())) {
182 - print "Opening connection to database failed.\n";
 182+ wfOut( "Opening connection to database failed.\n" );
183183 return;
184184 }
185185 $links_temp = $dbConn->tableName( 'links_temp' );
186186
187 - print "Dropping temporary links table if it exists...";
 187+ wfOut( "Dropping temporary links table if it exists..." );
188188 $dbConn->query( "DROP TABLE IF EXISTS $links_temp");
189 - print " done.\n";
 189+ wfOut( " done.\n" );
190190
191 - print "Creating temporary links table...";
 191+ wfOut( "Creating temporary links table..." );
192192 if ( $noKeys ) {
193193 $dbConn->query( "CREATE TABLE $links_temp ( " .
194194 "l_from int(8) unsigned NOT NULL default '0', " .
@@ -199,7 +199,7 @@
200200 "UNIQUE KEY l_from(l_from,l_to), " .
201201 "KEY (l_to))");
202202 }
203 - print " done.\n\n";
 203+ wfOut( " done.\n\n" );
204204 }
205205
206206 function performanceLog( $text ) {
Index: branches/REL1_12/phase3/includes/GlobalFunctions.php
@@ -2405,3 +2405,18 @@
24062406 echo "Waiting for a database server: $lag seconds lagged\n";
24072407 }
24082408 }
 2409+
 2410+/**
 2411+ * Output some plain text in command-line mode or in the installer (updaters.inc).
 2412+ * Do not use it in any other context, its behaviour is subject to change.
 2413+ */
 2414+function wfOut( $s ) {
 2415+ static $lineStarted = false;
 2416+ global $wgCommandLineMode;
 2417+ if ( $wgCommandLineMode && !defined( 'MEDIAWIKI_INSTALL' ) ) {
 2418+ echo $s;
 2419+ } else {
 2420+ echo htmlspecialchars( $s );
 2421+ }
 2422+ flush();
 2423+}
Index: branches/REL1_12/phase3/config/index.php
@@ -72,7 +72,8 @@
7373 <html>
7474 <head>
7575 <meta http-equiv="Content-type" content="text/html; charset=utf-8">
76 - <title>MediaWiki <?php echo( $wgVersion ); ?> Installation</title>
 76+ <meta name="robots" content="noindex,nofollow"/>
 77+ <title>MediaWiki <?php echo htmlspecialchars( $wgVersion ); ?> Installation</title>
7778 <style type="text/css">
7879
7980 @import "../skins/monobook/main.css";
@@ -190,7 +191,7 @@
191192 <div id="content">
192193 <div id="bodyContent">
193194
194 -<h1>MediaWiki <?php print $wgVersion ?> Installation</h1>
 195+<h1>MediaWiki <?php print htmlspecialchars( $wgVersion ) ?> Installation</h1>
195196
196197 <?php
197198
@@ -289,7 +290,7 @@
290291 install_version_checks();
291292 $self = 'Installer'; # Maintenance script name, to please Setup.php
292293
293 -print "<li>PHP " . phpversion() . " installed</li>\n";
 294+print "<li>PHP " . htmlspecialchars( phpversion() ) . " installed</li>\n";
294295
295296 error_reporting( 0 );
296297 $phpdatabases = array();
@@ -388,7 +389,7 @@
389390 $conf->safeMode = false;
390391 }
391392
392 -$sapi = php_sapi_name();
 393+$sapi = htmlspecialchars( php_sapi_name() );
393394 print "<li>PHP server API is $sapi; ";
394395 $script = defined('MW_INSTALL_PHP5_EXT') ? 'index.php5' : 'index.php';
395396 if( $wgUsePathInfo ) {
@@ -571,6 +572,9 @@
572573 : $_SERVER["SERVER_ADMIN"];
573574 $conf->EmergencyContact = importPost( "EmergencyContact", $defaultEmail );
574575 $conf->DBtype = importPost( "DBtype", $DefaultDBtype );
 576+ if ( !isset( $ourdb[$conf->DBtype] ) ) {
 577+ $conf->DBtype = $DefaultDBtype;
 578+ }
575579 ?>
576580
577581 <?php
@@ -738,7 +742,7 @@
739743 $errs["DBtype"] = "Unknown database type '$conf->DBtype'";
740744 continue;
741745 }
742 - print "<li>Database type: {$conf->DBtypename}</li>\n";
 746+ print "<li>Database type: " . htmlspecialchars( $conf->DBtypename ) . "</li>\n";
743747 $dbclass = 'Database'.ucfirst($conf->DBtype);
744748 $wgDBtype = $conf->DBtype;
745749 $wgDBadminuser = "root";
@@ -761,7 +765,7 @@
762766
763767 $wgTitle = Title::newFromText( "Installation script" );
764768 error_reporting( E_ALL );
765 - print "<li>Loading class: $dbclass";
 769+ print "<li>Loading class: " . htmlspecialchars( $dbclass ) . "</li>\n";
766770 $dbc = new $dbclass;
767771
768772 if( $conf->DBtype == 'mysql' ) {
@@ -785,7 +789,7 @@
786790 }
787791
788792 # Attempt to connect
789 - echo( "<li>Attempting to connect to database server as $db_user..." );
 793+ echo( "<li>Attempting to connect to database server as " . htmlspecialchars( $db_user ) . "..." );
790794 $wgDatabase = Database::newFromParams( $wgDBserver, $db_user, $db_pass, '', 1 );
791795
792796 # Check the connection and respond to errors
@@ -820,7 +824,7 @@
821825 case 2003:
822826 default:
823827 # General connection problem
824 - echo( "failed with error [$errno] $errtx.</li>\n" );
 828+ echo( htmlspecialchars( "failed with error [$errno] $errtx." ) . "</li>\n" );
825829 $errs["DBserver"] = "Connection failed";
826830 break;
827831 } # switch
@@ -834,10 +838,11 @@
835839 ## Possible connect as a superuser
836840 if( $useRoot ) {
837841 $wgDBsuperuser = $conf->RootUser;
838 - echo( "<li>Attempting to connect to database \"postgres\" as superuser \"$wgDBsuperuser\"..." );
 842+ echo( "<li>Attempting to connect to database \"postgres\" as superuser \"" .
 843+ htmlspecialchars( $wgDBsuperuser ) . "\"..." );
839844 $wgDatabase = $dbc->newFromParams($wgDBserver, $wgDBsuperuser, $conf->RootPW, "postgres", 1);
840845 if (!$wgDatabase->isOpen()) {
841 - print " error: " . $wgDatabase->lastError() . "</li>\n";
 846+ print " error: " . htmlspecialchars( $wgDatabase->lastError() ) . "</li>\n";
842847 $errs["DBserver"] = "Could not connect to database as superuser";
843848 $errs["RootUser"] = "Check username";
844849 $errs["RootPW"] = "and password";
@@ -845,10 +850,11 @@
846851 }
847852 $wgDatabase->initial_setup($conf->RootPW, 'postgres');
848853 }
849 - echo( "<li>Attempting to connect to database \"$wgDBname\" as \"$wgDBuser\"..." );
 854+ echo( "<li>Attempting to connect to database \"" . htmlspecialchars( $wgDBname ) .
 855+ "\" as \"" . htmlspecialchars( $wgDBuser ) . "\"..." );
850856 $wgDatabase = $dbc->newFromParams($wgDBserver, $wgDBuser, $wgDBpassword, $wgDBname, 1);
851857 if (!$wgDatabase->isOpen()) {
852 - print " error: " . $wgDatabase->lastError() . "</li>\n";
 858+ print " error: " . htmlspecialchars( $wgDatabase->lastError() ) . "</li>\n";
853859 } else {
854860 $myver = $wgDatabase->getServerVersion();
855861 }
@@ -860,7 +866,7 @@
861867 continue;
862868 }
863869
864 - print "<li>Connected to $myver";
 870+ print "<li>Connected to " . htmlspecialchars( $myver );
865871 if ($conf->DBtype == 'mysql') {
866872 if( version_compare( $myver, "4.0.14" ) < 0 ) {
867873 dieout( " -- mysql 4.0.14 or later required. Aborting." );
@@ -946,15 +952,19 @@
947953 }
948954 }
949955 if ( $existingSchema && $existingSchema != $conf->DBschema ) {
950 - print "<li><strong>Warning:</strong> you requested the {$conf->DBschema} schema, " .
951 - "but the existing database has the $existingSchema schema. This upgrade script ".
952 - "can't convert it, so it will remain $existingSchema.</li>\n";
 956+ $encExisting = htmlspecialchars( $existingSchema );
 957+ $encRequested = htmlspecialchars( $conf->DBschema );
 958+ print "<li><strong>Warning:</strong> you requested the $encRequested schema, " .
 959+ "but the existing database has the $encExisting schema. This upgrade script ".
 960+ "can't convert it, so it will remain $encExisting.</li>\n";
953961 $conf->setSchema( $existingSchema, $conf->DBengine );
954962 }
955963 if ( $existingEngine && $existingEngine != $conf->DBengine ) {
956 - print "<li><strong>Warning:</strong> you requested the {$conf->DBengine} storage " .
957 - "engine, but the existing database uses the $existingEngine engine. This upgrade " .
958 - "script can't convert it, so it will remain $existingEngine.</li>\n";
 964+ $encExisting = htmlspecialchars( $existingEngine );
 965+ $encRequested = htmlspecialchars( $conf->DBengine );
 966+ print "<li><strong>Warning:</strong> you requested the $encRequested storage " .
 967+ "engine, but the existing database uses the $encExisting engine. This upgrade " .
 968+ "script can't convert it, so it will remain $encExisting.</li>\n";
959969 $conf->setSchema( $conf->DBschema, $existingEngine );
960970 }
961971 }
@@ -995,7 +1005,8 @@
9961006 }
9971007 $wgDatabase->freeResult( $res );
9981008 if ( !$found && $conf->DBengine != 'MyISAM' ) {
999 - echo "<li><strong>Warning:</strong> {$conf->DBengine} storage engine not available, " .
 1009+ echo "<li><strong>Warning:</strong> " . htmlspecialchars( $conf->DBengine ) .
 1010+ " storage engine not available, " .
10001011 "using MyISAM instead</li>\n";
10011012 $conf->setSchema( $conf->DBschema, 'MyISAM' );
10021013 }
@@ -1034,10 +1045,10 @@
10351046 if( $wgDatabase2->isOpen() ) {
10361047 # Nope, just close the test connection and continue
10371048 $wgDatabase2->close();
1038 - echo( "<li>User $wgDBuser exists. Skipping grants.</li>\n" );
 1049+ echo( "<li>User " . htmlspecialchars( $wgDBuser ) . " exists. Skipping grants.</li>\n" );
10391050 } else {
10401051 # Yes, so run the grants
1041 - echo( "<li>Granting user permissions to $wgDBuser on $wgDBname..." );
 1052+ echo( "<li>" . htmlspecialchars( "Granting user permissions to $wgDBuser on $wgDBname..." ) );
10421053 dbsource( "../maintenance/users.sql", $wgDatabase );
10431054 echo( "success.</li>\n" );
10441055 }
@@ -1151,7 +1162,9 @@
11521163 $list = getLanguageList();
11531164 foreach( $list as $code => $name ) {
11541165 $sel = ($code == $conf->LanguageCode) ? 'selected="selected"' : '';
1155 - echo "\t\t<option value=\"$code\" $sel>$name</option>\n";
 1166+ $encCode = htmlspecialchars( $code );
 1167+ $encName = htmlspecialchars( $name );
 1168+ echo "\n\t\t<option value=\"$encCode\" $sel>$encName</option>";
11561169 }
11571170 ?>
11581171 </select>
@@ -1316,7 +1329,7 @@
13171330 <div class="config-section">
13181331 <div class="config-input">
13191332 <label class='column'>Database type:</label>
1320 -<?php if (isset($errs['DBpicktype'])) print "<span class='error'>$errs[DBpicktype]</span>\n"; ?>
 1333+<?php if (isset($errs['DBpicktype'])) print "<span class='error'>" . htmlspecialchars( $errs['DBpicktype'] ) . "</span>\n"; ?>
13211334 <ul class='plain'><?php database_picker($conf) ?></ul>
13221335 </div>
13231336
@@ -1434,7 +1447,7 @@
14351448 </div>
14361449
14371450 <script type="text/javascript">
1438 -window.onload = toggleDBarea('<?php echo $conf->DBtype; ?>',
 1451+window.onload = toggleDBarea('<?php echo Xml::encodeJsVar( $conf->DBtype ); ?>',
14391452 <?php
14401453 ## If they passed in a root user name, don't populate it on page load
14411454 echo strlen(importPost('RootUser', '')) ? 0 : 1;
@@ -1727,10 +1740,8 @@
17281741 return importVar( $_REQUEST, $name, $default );
17291742 }
17301743
1731 -$radioCount = 0;
1732 -
17331744 function aField( &$conf, $field, $text, $type = "text", $value = "", $onclick = '' ) {
1734 - global $radioCount;
 1745+ static $radioCount = 0;
17351746 if( $type != "" ) {
17361747 $xtype = "type=\"$type\"";
17371748 } else {
@@ -1772,7 +1783,9 @@
17731784 }
17741785
17751786 global $errs;
1776 - if(isset($errs[$field])) echo "<span class='error'>" . $errs[$field] . "</span>\n";
 1787+ if(isset($errs[$field])) {
 1788+ echo "<span class='error'>" . htmlspecialchars( $errs[$field] ) . "</span>\n";
 1789+ }
17771790 }
17781791
17791792 function getLanguageList() {
@@ -1865,7 +1878,7 @@
18661879 fclose( $fp );
18671880 }
18681881 if ( !$errstr ) {
1869 - echo "<li>Connected to memcached on $host:$port successfully";
 1882+ echo "<li>Connected to memcached on " . htmlspecialchars( "$host:$port" ) ." successfully</li>";
18701883 }
18711884 return $errstr;
18721885 }

Past revisions this follows-up on

RevisionCommit summaryAuthorDate
r46840* Fixed a whole lot of XSS vulnerabilities in the installer. All require a li...tstarling08:56, 5 February 2009
r46843(bug 17366) fix for r46840: Xml::encodeJsVar() already escapes and quotes $co...ialex11:59, 5 February 2009
r46889More installer XSStstarling03:46, 6 February 2009

Status & tagging log