r46891 MediaWiki - Code Review archive

Repository:MediaWiki
Revision:r46890‎ | r46891 | r46892 >
Date:04:54, 6 February 2009
Author:tstarling
Status:deferred (Comments)
Tags:
Comment:
Backported r46840, r46843, r46889
Modified paths:
  • /branches/REL1_14/phase3/config/index.php (modified) (history)
  • /branches/REL1_14/phase3/includes/GlobalFunctions.php (modified) (history)
  • /branches/REL1_14/phase3/includes/db/DatabasePostgres.php (modified) (history)
  • /branches/REL1_14/phase3/maintenance/convertLinks.inc (modified) (history)
  • /branches/REL1_14/phase3/maintenance/initStats.inc (modified) (history)
  • /branches/REL1_14/phase3/maintenance/populateCategory.inc (modified) (history)
  • /branches/REL1_14/phase3/maintenance/populateParentId.inc (modified) (history)
  • /branches/REL1_14/phase3/maintenance/updaters.inc (modified) (history)
  • /branches/REL1_14/phase3/maintenance/userDupes.inc (modified) (history)

Diff [purge]

Index: branches/REL1_14/phase3/maintenance/initStats.inc
@@ -7,34 +7,34 @@
88 function wfInitStats( $options=array() ) {
99 $dbr = wfGetDB( DB_SLAVE );
1010
11 - echo "Counting total edits...";
 11+ wfOut( "Counting total edits..." );
1212 $edits = $dbr->selectField( 'revision', 'COUNT(*)', '', __METHOD__ );
1313 $edits += $dbr->selectField( 'archive', 'COUNT(*)', '', __METHOD__ );
14 - echo "{$edits}\nCounting number of articles...";
 14+ wfOut( "{$edits}\nCounting number of articles..." );
1515
1616 global $wgContentNamespaces;
1717 $good = $dbr->selectField( 'page', 'COUNT(*)', array( 'page_namespace' => $wgContentNamespaces, 'page_is_redirect' => 0, 'page_len > 0' ), __METHOD__ );
18 - echo "{$good}\nCounting total pages...";
 18+ wfOut( "{$good}\nCounting total pages..." );
1919
2020 $pages = $dbr->selectField( 'page', 'COUNT(*)', '', __METHOD__ );
21 - echo "{$pages}\nCounting number of users...";
 21+ wfOut( "{$pages}\nCounting number of users..." );
2222
2323 $users = $dbr->selectField( 'user', 'COUNT(*)', '', __METHOD__ );
24 - echo "{$users}\nCounting number of admins...";
 24+ wfOut( "{$users}\nCounting number of admins..." );
2525
2626 $admin = $dbr->selectField( 'user_groups', 'COUNT(*)', array( 'ug_group' => 'sysop' ), __METHOD__ );
27 - echo "{$admin}\nCounting number of images...";
 27+ wfOut( "{$admin}\nCounting number of images..." );
2828
2929 $image = $dbr->selectField( 'image', 'COUNT(*)', '', __METHOD__ );
30 - echo "{$image}\n";
 30+ wfOut( "{$image}\n" );
3131
3232 if( !isset( $options['noviews'] ) ) {
33 - echo "Counting total page views...";
 33+ wfOut( "Counting total page views..." );
3434 $views = $dbr->selectField( 'page', 'SUM(page_counter)', '', __METHOD__ );
35 - echo "{$views}\n";
 35+ wfOut( "{$views}\n" );
3636 }
3737
38 - echo "\nUpdating site statistics...";
 38+ wfOut( "\nUpdating site statistics..." );
3939
4040 $dbw = wfGetDB( DB_MASTER );
4141 $values = array( 'ss_total_edits' => $edits,
@@ -53,5 +53,5 @@
5454 $dbw->insert( 'site_stats', array_merge( $values, $conds, $views ), __METHOD__ );
5555 }
5656
57 - echo( "done.\n" );
 57+ wfOut( "done.\n" );
5858 }
Index: branches/REL1_14/phase3/maintenance/populateCategory.inc
@@ -18,9 +18,9 @@
1919 __FUNCTION__
2020 );
2121 if( $row ) {
22 - echo "Category table already populated. Use php ".
 22+ wfOut( "Category table already populated. Use php ".
2323 "maintenance/populateCategory.php\n--force from the command line ".
24 - "to override.\n";
 24+ "to override.\n" );
2525 return true;
2626 }
2727 }
@@ -56,14 +56,14 @@
5757 # Use the row to update the category count
5858 $cat = Category::newFromName( $name );
5959 if( !is_object( $cat ) ) {
60 - echo "The category named $name is not valid?!\n";
 60+ wfOut( "The category named $name is not valid?!\n" );
6161 } else {
6262 $cat->refreshCounts();
6363 }
6464
6565 ++$i;
6666 if( !($i % REPORTING_INTERVAL) ) {
67 - echo "$name\n";
 67+ wfOut( "$name\n" );
6868 wfWaitForSlaves( $maxlag );
6969 }
7070 usleep( $throttle*1000 );
@@ -76,10 +76,10 @@
7777 'IGNORE'
7878 )
7979 ) {
80 - echo "Category population complete.\n";
 80+ wfOut( "Category population complete.\n" );
8181 return true;
8282 } else {
83 - echo "Could not insert category population row.\n";
 83+ wfOut( "Could not insert category population row.\n" );
8484 return false;
8585 }
8686 }
Index: branches/REL1_14/phase3/maintenance/updaters.inc
@@ -176,11 +176,11 @@
177177 global $wgDatabase;
178178 if ( $wgDatabase->tableExists( $from ) ) {
179179 if ( $wgDatabase->tableExists( $to ) ) {
180 - echo "...can't move table $from to $to, $to already exists.\n";
 180+ wfOut( "...can't move table $from to $to, $to already exists.\n" );
181181 } else {
182 - echo "Moving table $from to $to...";
 182+ wfOut( "Moving table $from to $to..." );
183183 dbsource( archive($patch), $wgDatabase );
184 - echo "ok\n";
 184+ wfOut( "ok\n" );
185185 }
186186 } else {
187187 // Source table does not exist
@@ -192,47 +192,47 @@
193193 function add_table( $name, $patch, $fullpath=false ) {
194194 global $wgDatabase;
195195 if ( $wgDatabase->tableExists( $name ) ) {
196 - echo "...$name table already exists.\n";
 196+ wfOut( "...$name table already exists.\n" );
197197 } else {
198 - echo "Creating $name table...";
 198+ wfOut( "Creating $name table..." );
199199 if( $fullpath ) {
200200 dbsource( $patch, $wgDatabase );
201201 } else {
202202 dbsource( archive($patch), $wgDatabase );
203203 }
204 - echo "ok\n";
 204+ wfOut( "ok\n" );
205205 }
206206 }
207207
208208 function add_field( $table, $field, $patch, $fullpath=false ) {
209209 global $wgDatabase;
210210 if ( !$wgDatabase->tableExists( $table ) ) {
211 - echo "...$table table does not exist, skipping new field patch\n";
 211+ wfOut( "...$table table does not exist, skipping new field patch\n" );
212212 } elseif ( $wgDatabase->fieldExists( $table, $field ) ) {
213 - echo "...have $field field in $table table.\n";
 213+ wfOut( "...have $field field in $table table.\n" );
214214 } else {
215 - echo "Adding $field field to table $table...";
 215+ wfOut( "Adding $field field to table $table..." );
216216 if( $fullpath ) {
217217 dbsource( $patch, $wgDatabase );
218218 } else {
219219 dbsource( archive($patch), $wgDatabase );
220220 }
221 - echo "ok\n";
 221+ wfOut( "ok\n" );
222222 }
223223 }
224224
225225 function add_index( $table, $index, $patch, $fullpath=false ) {
226226 global $wgDatabase;
227227 if( $wgDatabase->indexExists( $table, $index ) ) {
228 - echo "...$index key already set on $table table.\n";
 228+ wfOut( "...$index key already set on $table table.\n" );
229229 } else {
230 - echo "Adding $index key to table $table... ";
 230+ wfOut( "Adding $index key to table $table... " );
231231 if( $fullpath ) {
232232 dbsource( $patch, $wgDatabase );
233233 } else {
234234 dbsource( archive($patch), $wgDatabase );
235235 }
236 - echo "ok\n";
 236+ wfOut( "ok\n" );
237237 }
238238 }
239239
@@ -248,11 +248,11 @@
249249
250250 global $wgDatabase;
251251 $fname = "Update script: update_passwords()";
252 - print "\nIt appears that you need to update the user passwords in your\n" .
 252+ wfOut( "\nIt appears that you need to update the user passwords in your\n" .
253253 "database. If you have already done this (if you've run this update\n" .
254254 "script once before, for example), doing so again will make all your\n" .
255255 "user accounts inaccessible, so be sure you only do this once.\n" .
256 - "Update user passwords? (yes/no)";
 256+ "Update user passwords? (yes/no)" );
257257
258258 $resp = readconsole();
259259 if ( ! ( "Y" == $resp{0} || "y" == $resp{0} ) ) { return; }
@@ -275,15 +275,15 @@
276276 # Check that interwiki table exists; if it doesn't source it
277277 global $wgDatabase, $IP;
278278 if( $wgDatabase->tableExists( "interwiki" ) ) {
279 - echo "...already have interwiki table\n";
 279+ wfOut( "...already have interwiki table\n" );
280280 return true;
281281 }
282 - echo "Creating interwiki table: ";
 282+ wfOut( "Creating interwiki table: " );
283283 dbsource( archive("patch-interwiki.sql") );
284 - echo "ok\n";
285 - echo "Adding default interwiki definitions: ";
 284+ wfOut( "ok\n" );
 285+ wfOut( "Adding default interwiki definitions: " );
286286 dbsource( "$IP/maintenance/interwiki.sql" );
287 - echo "ok\n";
 287+ wfOut( "ok\n" );
288288 }
289289
290290 function do_index_update() {
@@ -291,12 +291,12 @@
292292 global $wgDatabase;
293293 $meta = $wgDatabase->fieldInfo( "recentchanges", "rc_timestamp" );
294294 if( !$meta->isMultipleKey() ) {
295 - echo "Updating indexes to 20031107: ";
 295+ wfOut( "Updating indexes to 20031107: " );
296296 dbsource( archive("patch-indexes.sql") );
297 - echo "ok\n";
 297+ wfOut( "ok\n" );
298298 return true;
299299 }
300 - echo "...indexes seem up to 20031107 standards\n";
 300+ wfOut( "...indexes seem up to 20031107 standards\n" );
301301 return false;
302302 }
303303
@@ -305,67 +305,67 @@
306306
307307 $meta = $wgDatabase->fieldInfo( "image", "img_major_mime" );
308308 if( !$meta->isMultipleKey() ) {
309 - echo "Updating indexes to 20050912: ";
 309+ wfOut( "Updating indexes to 20050912: " );
310310 dbsource( archive("patch-mimesearch-indexes.sql") );
311 - echo "ok\n";
 311+ wfOut( "ok\n" );
312312 return true;
313313 }
314 - echo "...indexes seem up to 20050912 standards\n";
 314+ wfOut( "...indexes seem up to 20050912 standards\n" );
315315 return false;
316316 }
317317
318318 function do_image_name_unique_update() {
319319 global $wgDatabase;
320320 if( $wgDatabase->indexExists( 'image', 'PRIMARY' ) ) {
321 - echo "...image primary key already set.\n";
 321+ wfOut( "...image primary key already set.\n" );
322322 } else {
323 - echo "Making img_name the primary key... ";
 323+ wfOut( "Making img_name the primary key... " );
324324 dbsource( archive("patch-image_name_primary.sql"), $wgDatabase );
325 - echo "ok\n";
 325+ wfOut( "ok\n" );
326326 }
327327 }
328328
329329 function do_logging_timestamp_index() {
330330 global $wgDatabase;
331331 if( $wgDatabase->indexExists( 'logging', 'times' ) ) {
332 - echo "...timestamp key on logging already exists.\n";
 332+ wfOut( "...timestamp key on logging already exists.\n" );
333333 } else {
334 - echo "Adding timestamp key on logging table... ";
 334+ wfOut( "Adding timestamp key on logging table... " );
335335 dbsource( archive("patch-logging-times-index.sql"), $wgDatabase );
336 - echo "ok\n";
 336+ wfOut( "ok\n" );
337337 }
338338 }
339339
340340 function do_archive_user_index() {
341341 global $wgDatabase;
342342 if( $wgDatabase->indexExists( 'archive', 'usertext_timestamp' ) ) {
343 - echo "...usertext,timestamp key on archive already exists.\n";
 343+ wfOut( "...usertext,timestamp key on archive already exists.\n" );
344344 } else {
345 - echo "Adding usertext,timestamp key on archive table... ";
 345+ wfOut( "Adding usertext,timestamp key on archive table... " );
346346 dbsource( archive("patch-archive-user-index.sql"), $wgDatabase );
347 - echo "ok\n";
 347+ wfOut( "ok\n" );
348348 }
349349 }
350350
351351 function do_image_user_index() {
352352 global $wgDatabase;
353353 if( $wgDatabase->indexExists( 'image', 'img_usertext_timestamp' ) ) {
354 - echo "...usertext,timestamp key on image already exists.\n";
 354+ wfOut( "...usertext,timestamp key on image already exists.\n" );
355355 } else {
356 - echo "Adding usertext,timestamp key on image table... ";
 356+ wfOut( "Adding usertext,timestamp key on image table... " );
357357 dbsource( archive("patch-image-user-index.sql"), $wgDatabase );
358 - echo "ok\n";
 358+ wfOut( "ok\n" );
359359 }
360360 }
361361
362362 function do_oldimage_user_index() {
363363 global $wgDatabase;
364364 if( $wgDatabase->indexExists( 'oldimage', 'oi_usertext_timestamp' ) ) {
365 - echo "...usertext,timestamp key on oldimage already exists.\n";
 365+ wfOut( "...usertext,timestamp key on oldimage already exists.\n" );
366366 } else {
367 - echo "Adding usertext,timestamp key on oldimage table... ";
 367+ wfOut( "Adding usertext,timestamp key on oldimage table... " );
368368 dbsource( archive("patch-oldimage-user-index.sql"), $wgDatabase );
369 - echo "ok\n";
 369+ wfOut( "ok\n" );
370370 }
371371 }
372372
@@ -373,18 +373,18 @@
374374 global $wgDatabase;
375375 $fname = 'do_watchlist_update';
376376 if( $wgDatabase->fieldExists( 'watchlist', 'wl_notificationtimestamp' ) ) {
377 - echo "The watchlist table is already set up for email notification.\n";
 377+ wfOut( "The watchlist table is already set up for email notification.\n" );
378378 } else {
379 - echo "Adding wl_notificationtimestamp field for email notification management.";
 379+ wfOut( "Adding wl_notificationtimestamp field for email notification management." );
380380 /* ALTER TABLE watchlist ADD (wl_notificationtimestamp varchar(14) binary NOT NULL default '0'); */
381381 dbsource( archive( 'patch-email-notification.sql' ), $wgDatabase );
382 - echo "ok\n";
 382+ wfOut( "ok\n" );
383383 }
384384 # Check if we need to add talk page rows to the watchlist
385385 $talk = $wgDatabase->selectField( 'watchlist', 'count(*)', 'wl_namespace & 1', $fname );
386386 $nontalk = $wgDatabase->selectField( 'watchlist', 'count(*)', 'NOT (wl_namespace & 1)', $fname );
387387 if ( $talk != $nontalk ) {
388 - echo "Adding missing watchlist talk page rows... ";
 388+ wfOut( "Adding missing watchlist talk page rows... " );
389389 flush();
390390
391391 $wgDatabase->insertSelect( 'watchlist', 'watchlist',
@@ -394,9 +394,9 @@
395395 'wl_title' => 'wl_title',
396396 'wl_notificationtimestamp' => 'wl_notificationtimestamp'
397397 ), array( 'NOT (wl_namespace & 1)' ), $fname, 'IGNORE' );
398 - echo "ok\n";
 398+ wfOut( "ok\n" );
399399 } else {
400 - echo "...watchlist talk page rows already present\n";
 400+ wfOut( "...watchlist talk page rows already present\n" );
401401 }
402402 }
403403
@@ -407,7 +407,7 @@
408408 $res = $wgDatabase->safeQuery( 'SELECT user_id, user_ip FROM !',
409409 $wgDatabase->tableName( 'user_newtalk' ) );
410410 $num_newtalks=$wgDatabase->numRows($res);
411 - echo "Now converting ".$num_newtalks." user_newtalk entries to watchlist table entries ... \n";
 411+ wfOut( "Now converting $num_newtalks user_newtalk entries to watchlist table entries ... \n" );
412412
413413 $user = new User();
414414 for ( $i = 1; $i <= $num_newtalks; $i++ ) {
@@ -435,18 +435,18 @@
436436 );
437437 }
438438 }
439 - echo "Done.\n";
 439+ wfOut( "Done.\n" );
440440 }
441441
442442
443443 function do_user_update() {
444444 global $wgDatabase;
445445 if( $wgDatabase->fieldExists( 'user', 'user_emailauthenticationtimestamp' ) ) {
446 - echo "User table contains old email authentication field. Dropping... ";
 446+ wfOut( "User table contains old email authentication field. Dropping... " );
447447 dbsource( archive( 'patch-email-authentication.sql' ), $wgDatabase );
448 - echo "ok\n";
 448+ wfOut( "ok\n" );
449449 } else {
450 - echo "...user table does not contain old email authentication field.\n";
 450+ wfOut( "...user table does not contain old email authentication field.\n" );
451451 }
452452 }
453453
@@ -464,11 +464,11 @@
465465 $wgDatabase->freeResult( $res );
466466
467467 if( in_array( 'binary', $flags ) ) {
468 - echo "$table table has correct $field encoding.\n";
 468+ wfOut( "$table table has correct $field encoding.\n" );
469469 } else {
470 - echo "Fixing $field encoding on $table table... ";
 470+ wfOut( "Fixing $field encoding on $table table... " );
471471 dbsource( archive( $patchFile ), $wgDatabase );
472 - echo "ok\n";
 472+ wfOut( "ok\n" );
473473 }
474474 }
475475
@@ -476,11 +476,11 @@
477477 global $wgDatabase;
478478 $fname="do_schema_restructuring";
479479 if ( $wgDatabase->tableExists( 'page' ) ) {
480 - echo "...page table already exists.\n";
 480+ wfOut( "...page table already exists.\n" );
481481 } else {
482 - echo "...converting from cur/old to page/revision/text DB structure.\n"; flush();
483 - echo wfTimestamp( TS_DB );
484 - echo "......checking for duplicate entries.\n"; flush();
 482+ wfOut( "...converting from cur/old to page/revision/text DB structure.\n" );
 483+ wfOut( wfTimestamp( TS_DB ) );
 484+ wfOut( "......checking for duplicate entries.\n" );
485485
486486 list ($cur, $old, $page, $revision, $text) = $wgDatabase->tableNamesN( 'cur', 'old', 'page', 'revision', 'text' );
487487
@@ -488,15 +488,15 @@
489489 FROM $cur GROUP BY cur_title, cur_namespace HAVING c>1", $fname );
490490
491491 if ( $wgDatabase->numRows( $rows ) > 0 ) {
492 - echo wfTimestamp( TS_DB );
493 - echo "......<b>Found duplicate entries</b>\n";
494 - echo ( sprintf( "<b> %-60s %3s %5s</b>\n", 'Title', 'NS', 'Count' ) );
 492+ wfOut( wfTimestamp( TS_DB ) );
 493+ wfOut( "......<b>Found duplicate entries</b>\n" );
 494+ wfOut( sprintf( "<b> %-60s %3s %5s</b>\n", 'Title', 'NS', 'Count' ) );
495495 while ( $row = $wgDatabase->fetchObject( $rows ) ) {
496496 if ( ! isset( $duplicate[$row->cur_namespace] ) ) {
497497 $duplicate[$row->cur_namespace] = array();
498498 }
499499 $duplicate[$row->cur_namespace][] = $row->cur_title;
500 - echo ( sprintf( " %-60s %3s %5s\n", $row->cur_title, $row->cur_namespace, $row->c ) );
 500+ wfOut( sprintf( " %-60s %3s %5s\n", $row->cur_title, $row->cur_namespace, $row->c ) );
501501 }
502502 $sql = "SELECT cur_title, cur_namespace, cur_id, cur_timestamp FROM $cur WHERE ";
503503 $firstCond = true;
@@ -536,13 +536,13 @@
537537 }
538538 $sql = "DELETE FROM $cur WHERE cur_id IN ( " . join( ',', $deleteId ) . ')';
539539 $rows = $wgDatabase->query( $sql, $fname );
540 - echo wfTimestamp( TS_DB );
541 - echo "......<b>Deleted</b> ".$wgDatabase->affectedRows()." records.\n";
 540+ wfOut( wfTimestamp( TS_DB ) );
 541+ wfOut( "......<b>Deleted</b> ".$wgDatabase->affectedRows()." records.\n" );
542542 }
543543
544544
545 - echo wfTimestamp( TS_DB );
546 - echo "......Creating tables.\n";
 545+ wfOut( wfTimestamp( TS_DB ) );
 546+ wfOut( "......Creating tables.\n" );
547547 $wgDatabase->query("CREATE TABLE $page (
548548 page_id int(8) unsigned NOT NULL auto_increment,
549549 page_namespace int NOT NULL,
@@ -580,26 +580,26 @@
581581 INDEX usertext_timestamp (rev_user_text,rev_timestamp)
582582 ) ENGINE=InnoDB", $fname );
583583
584 - echo wfTimestamp( TS_DB );
585 - echo "......Locking tables.\n";
 584+ wfOut( wfTimestamp( TS_DB ) );
 585+ wfOut( "......Locking tables.\n" );
586586 $wgDatabase->query( "LOCK TABLES $page WRITE, $revision WRITE, $old WRITE, $cur WRITE", $fname );
587587
588588 $maxold = intval( $wgDatabase->selectField( 'old', 'max(old_id)', '', $fname ) );
589 - echo wfTimestamp( TS_DB );
590 - echo "......maxold is {$maxold}\n";
 589+ wfOut( wfTimestamp( TS_DB ) );
 590+ wfOut( "......maxold is {$maxold}\n" );
591591
592 - echo wfTimestamp( TS_DB );
 592+ wfOut( wfTimestamp( TS_DB ) );
593593 global $wgLegacySchemaConversion;
594594 if( $wgLegacySchemaConversion ) {
595595 // Create HistoryBlobCurStub entries.
596596 // Text will be pulled from the leftover 'cur' table at runtime.
597 - echo "......Moving metadata from cur; using blob references to text in cur table.\n";
 597+ wfOut( "......Moving metadata from cur; using blob references to text in cur table.\n" );
598598 $cur_text = "concat('O:18:\"historyblobcurstub\":1:{s:6:\"mCurId\";i:',cur_id,';}')";
599599 $cur_flags = "'object'";
600600 } else {
601601 // Copy all cur text in immediately: this may take longer but avoids
602602 // having to keep an extra table around.
603 - echo "......Moving text from cur.\n";
 603+ wfOut( "......Moving text from cur.\n" );
604604 $cur_text = 'cur_text';
605605 $cur_flags = "''";
606606 }
@@ -608,16 +608,16 @@
609609 SELECT cur_namespace, cur_title, $cur_text, cur_comment, cur_user, cur_user_text, cur_timestamp, cur_minor_edit, $cur_flags
610610 FROM $cur", $fname );
611611
612 - echo wfTimestamp( TS_DB );
613 - echo "......Setting up revision table.\n";
 612+ wfOut( wfTimestamp( TS_DB ) );
 613+ wfOut( "......Setting up revision table.\n" );
614614 $wgDatabase->query( "INSERT INTO $revision (rev_id, rev_page, rev_comment, rev_user, rev_user_text, rev_timestamp,
615615 rev_minor_edit)
616616 SELECT old_id, cur_id, old_comment, old_user, old_user_text,
617617 old_timestamp, old_minor_edit
618618 FROM $old,$cur WHERE old_namespace=cur_namespace AND old_title=cur_title", $fname );
619619
620 - echo wfTimestamp( TS_DB );
621 - echo "......Setting up page table.\n";
 620+ wfOut( wfTimestamp( TS_DB ) );
 621+ wfOut( "......Setting up page table.\n" );
622622 $wgDatabase->query( "INSERT INTO $page (page_id, page_namespace, page_title, page_restrictions, page_counter,
623623 page_is_redirect, page_is_new, page_random, page_touched, page_latest, page_len)
624624 SELECT cur_id, cur_namespace, cur_title, cur_restrictions, cur_counter, cur_is_redirect, cur_is_new,
@@ -625,38 +625,38 @@
626626 FROM $cur,$revision
627627 WHERE cur_id=rev_page AND rev_timestamp=cur_timestamp AND rev_id > {$maxold}", $fname );
628628
629 - echo wfTimestamp( TS_DB );
630 - echo "......Unlocking tables.\n";
 629+ wfOut( wfTimestamp( TS_DB ) );
 630+ wfOut( "......Unlocking tables.\n" );
631631 $wgDatabase->query( "UNLOCK TABLES", $fname );
632632
633 - echo wfTimestamp( TS_DB );
634 - echo "......Renaming old.\n";
 633+ wfOut( wfTimestamp( TS_DB ) );
 634+ wfOut( "......Renaming old.\n" );
635635 $wgDatabase->query( "ALTER TABLE $old RENAME TO $text", $fname );
636636
637 - echo wfTimestamp( TS_DB );
638 - echo "...done.\n";
 637+ wfOut( wfTimestamp( TS_DB ) );
 638+ wfOut( "...done.\n" );
639639 }
640640 }
641641
642642 function do_inverse_timestamp() {
643643 global $wgDatabase;
644644 if( $wgDatabase->fieldExists( 'revision', 'inverse_timestamp' ) ) {
645 - echo "Removing revision.inverse_timestamp and fixing indexes... ";
 645+ wfOut( "Removing revision.inverse_timestamp and fixing indexes... " );
646646 dbsource( archive( 'patch-inverse_timestamp.sql' ), $wgDatabase );
647 - echo "ok\n";
 647+ wfOut( "ok\n" );
648648 } else {
649 - echo "revision timestamp indexes already up to 2005-03-13\n";
 649+ wfOut( "revision timestamp indexes already up to 2005-03-13\n" );
650650 }
651651 }
652652
653653 function do_text_id() {
654654 global $wgDatabase;
655655 if( $wgDatabase->fieldExists( 'revision', 'rev_text_id' ) ) {
656 - echo "...rev_text_id already in place.\n";
 656+ wfOut( "...rev_text_id already in place.\n" );
657657 } else {
658 - echo "Adding rev_text_id field... ";
 658+ wfOut( "Adding rev_text_id field... " );
659659 dbsource( archive( 'patch-rev_text_id.sql' ), $wgDatabase );
660 - echo "ok\n";
 660+ wfOut( "ok\n" );
661661 }
662662 }
663663
@@ -687,25 +687,25 @@
688688 $wgDatabase->freeResult( $result );
689689
690690 if( substr( $info->Type, 0, 3 ) == 'int' ) {
691 - echo "...$field is already a full int ($info->Type).\n";
 691+ wfOut( "...$field is already a full int ($info->Type).\n" );
692692 } else {
693 - echo "Promoting $field from $info->Type to int... ";
 693+ wfOut( "Promoting $field from $info->Type to int... " );
694694
695695 $sql = "ALTER TABLE $tablename MODIFY $field int NOT NULL";
696696 $wgDatabase->query( $sql );
697697
698 - echo "ok\n";
 698+ wfOut( "ok\n" );
699699 }
700700 }
701701
702702 function do_pagelinks_update() {
703703 global $wgDatabase;
704704 if( $wgDatabase->tableExists( 'pagelinks' ) ) {
705 - echo "...already have pagelinks table.\n";
 705+ wfOut( "...already have pagelinks table.\n" );
706706 } else {
707 - echo "Converting links and brokenlinks tables to pagelinks... ";
 707+ wfOut( "Converting links and brokenlinks tables to pagelinks... " );
708708 dbsource( archive( 'patch-pagelinks.sql' ), $wgDatabase );
709 - echo "ok\n";
 709+ wfOut( "ok\n" );
710710 flush();
711711
712712 global $wgCanonicalNamespaceNames;
@@ -721,7 +721,7 @@
722722 global $wgDatabase, $wgContLang;
723723
724724 $ns = intval( $namespace );
725 - echo "Cleaning up broken links for namespace $ns... ";
 725+ wfOut( "Cleaning up broken links for namespace $ns... " );
726726
727727 $pagelinks = $wgDatabase->tableName( 'pagelinks' );
728728 $name = $wgContLang->getNsText( $ns );
@@ -735,25 +735,25 @@
736736 AND pl_title LIKE '$likeprefix:%'";
737737
738738 $wgDatabase->query( $sql, 'do_pagelinks_namespace' );
739 - echo "ok\n";
 739+ wfOut( "ok\n" );
740740 }
741741
742742 function do_drop_img_type() {
743743 global $wgDatabase;
744744
745745 if( $wgDatabase->fieldExists( 'image', 'img_type' ) ) {
746 - echo "Dropping unused img_type field in image table... ";
 746+ wfOut( "Dropping unused img_type field in image table... " );
747747 dbsource( archive( 'patch-drop_img_type.sql' ), $wgDatabase );
748 - echo "ok\n";
 748+ wfOut( "ok\n" );
749749 } else {
750 - echo "No img_type field in image table; Good.\n";
 750+ wfOut( "No img_type field in image table; Good.\n" );
751751 }
752752 }
753753
754754 function do_old_links_update() {
755755 global $wgDatabase;
756756 if( $wgDatabase->tableExists( 'pagelinks' ) ) {
757 - echo "Already have pagelinks; skipping old links table updates.\n";
 757+ wfOut( "Already have pagelinks; skipping old links table updates.\n" );
758758 } else {
759759 convertLinks(); flush();
760760 }
@@ -763,14 +763,14 @@
764764 global $wgDatabase;
765765 $duper = new UserDupes( $wgDatabase );
766766 if( $duper->hasUniqueIndex() ) {
767 - echo "Already have unique user_name index.\n";
 767+ wfOut( "Already have unique user_name index.\n" );
768768 } else {
769769 if( !$duper->clearDupes() ) {
770 - echo "WARNING: This next step will probably fail due to unfixed duplicates...\n";
 770+ wfOut( "WARNING: This next step will probably fail due to unfixed duplicates...\n" );
771771 }
772 - echo "Adding unique index on user_name... ";
 772+ wfOut( "Adding unique index on user_name... " );
773773 dbsource( archive( 'patch-user_nameindex.sql' ), $wgDatabase );
774 - echo "ok\n";
 774+ wfOut( "ok\n" );
775775 }
776776 }
777777
@@ -779,28 +779,28 @@
780780 global $wgDatabase;
781781
782782 if( $wgDatabase->tableExists( 'user_groups' ) ) {
783 - echo "...user_groups table already exists.\n";
 783+ wfOut( "...user_groups table already exists.\n" );
784784 return do_user_groups_reformat();
785785 }
786786
787 - echo "Adding user_groups table... ";
 787+ wfOut( "Adding user_groups table... " );
788788 dbsource( archive( 'patch-user_groups.sql' ), $wgDatabase );
789 - echo "ok\n";
 789+ wfOut( "ok\n" );
790790
791791 if( !$wgDatabase->tableExists( 'user_rights' ) ) {
792792 if( $wgDatabase->fieldExists( 'user', 'user_rights' ) ) {
793 - echo "Upgrading from a 1.3 or older database? Breaking out user_rights for conversion...";
 793+ wfOut( "Upgrading from a 1.3 or older database? Breaking out user_rights for conversion..." );
794794 dbsource( archive( 'patch-user_rights.sql' ), $wgDatabase );
795 - echo "ok\n";
 795+ wfOut( "ok\n" );
796796 } else {
797 - echo "*** WARNING: couldn't locate user_rights table or field for upgrade.\n";
798 - echo "*** You may need to manually configure some sysops by manipulating\n";
799 - echo "*** the user_groups table.\n";
 797+ wfOut( "*** WARNING: couldn't locate user_rights table or field for upgrade.\n" );
 798+ wfOut( "*** You may need to manually configure some sysops by manipulating\n" );
 799+ wfOut( "*** the user_groups table.\n" );
800800 return;
801801 }
802802 }
803803
804 - echo "Converting user_rights table to user_groups... ";
 804+ wfOut( "Converting user_rights table to user_groups... " );
805805 $result = $wgDatabase->select( 'user_rights',
806806 array( 'ur_user', 'ur_rights' ),
807807 array( "ur_rights != ''" ),
@@ -820,7 +820,7 @@
821821 }
822822 }
823823 $wgDatabase->freeResult( $result );
824 - echo "ok\n";
 824+ wfOut( "ok\n" );
825825 }
826826
827827 function do_user_groups_reformat() {
@@ -831,20 +831,20 @@
832832 if( $info->type() == 'int' ) {
833833 $oldug = $wgDatabase->tableName( 'user_groups' );
834834 $newug = $wgDatabase->tableName( 'user_groups_bogus' );
835 - echo "user_groups is in bogus intermediate format. Renaming to $newug... ";
 835+ wfOut( "user_groups is in bogus intermediate format. Renaming to $newug... " );
836836 $wgDatabase->query( "ALTER TABLE $oldug RENAME TO $newug" );
837 - echo "ok\n";
 837+ wfOut( "ok\n" );
838838
839 - echo "Re-adding fresh user_groups table... ";
 839+ wfOut( "Re-adding fresh user_groups table... " );
840840 dbsource( archive( 'patch-user_groups.sql' ), $wgDatabase );
841 - echo "ok\n";
 841+ wfOut( "ok\n" );
842842
843 - echo "***\n";
844 - echo "*** WARNING: You will need to manually fix up user permissions in the user_groups\n";
845 - echo "*** table. Old 1.5 alpha versions did some pretty funky stuff...\n";
846 - echo "***\n";
 843+ wfOut( "***\n" );
 844+ wfOut( "*** WARNING: You will need to manually fix up user permissions in the user_groups\n" );
 845+ wfOut( "*** table. Old 1.5 alpha versions did some pretty funky stuff...\n" );
 846+ wfOut( "***\n" );
847847 } else {
848 - echo "...user_groups is in current format.\n";
 848+ wfOut( "...user_groups is in current format.\n" );
849849 }
850850
851851 }
@@ -856,11 +856,11 @@
857857 $info = $wgDatabase->fieldInfo( 'watchlist', 'wl_notificationtimestamp' );
858858
859859 if( !$info->nullable() ) {
860 - echo "Making wl_notificationtimestamp nullable... ";
 860+ wfOut( "Making wl_notificationtimestamp nullable... " );
861861 dbsource( archive( 'patch-watchlist-null.sql' ), $wgDatabase );
862 - echo "ok\n";
 862+ wfOut( "ok\n" );
863863 } else {
864 - echo "...wl_notificationtimestamp is already nullable.\n";
 864+ wfOut( "...wl_notificationtimestamp is already nullable.\n" );
865865 }
866866
867867 }
@@ -871,13 +871,13 @@
872872 function do_page_random_update() {
873873 global $wgDatabase;
874874
875 - echo "Setting page_random to a random value on rows where it equals 0...";
 875+ wfOut( "Setting page_random to a random value on rows where it equals 0..." );
876876
877877 $page = $wgDatabase->tableName( 'page' );
878878 $wgDatabase->query( "UPDATE $page SET page_random = RAND() WHERE page_random = 0", 'do_page_random_update' );
879879 $rows = $wgDatabase->affectedRows();
880880
881 - echo "changed $rows rows\n";
 881+ wfOut( "changed $rows rows\n" );
882882 }
883883
884884 function do_templatelinks_update() {
@@ -885,12 +885,12 @@
886886 $fname = 'do_templatelinks_update';
887887
888888 if ( $wgDatabase->tableExists( 'templatelinks' ) ) {
889 - echo "...templatelinks table already exists\n";
 889+ wfOut( "...templatelinks table already exists\n" );
890890 return;
891891 }
892 - echo "Creating templatelinks table...\n";
 892+ wfOut( "Creating templatelinks table...\n" );
893893 dbsource( archive('patch-templatelinks.sql'), $wgDatabase );
894 - echo "Populating...\n";
 894+ wfOut( "Populating...\n" );
895895 if ( isset( $wgLoadBalancer ) && $wgLoadBalancer->getServerCount() > 1 ) {
896896 // Slow, replication-friendly update
897897 $res = $wgDatabase->select( 'pagelinks', array( 'pl_from', 'pl_namespace', 'pl_title' ),
@@ -927,14 +927,14 @@
928928 ), $fname
929929 );
930930 }
931 - echo "Done. Please run maintenance/refreshLinks.php for a more thorough templatelinks update.\n";
 931+ wfOut( "Done. Please run maintenance/refreshLinks.php for a more thorough templatelinks update.\n" );
932932 }
933933
934934 // Add index on ( rc_namespace, rc_user_text ) [Jul. 2006]
935935 // Add index on ( rc_user_text, rc_timestamp ) [Nov. 2006]
936936 function do_rc_indices_update() {
937937 global $wgDatabase;
938 - echo( "Checking for additional recent changes indices...\n" );
 938+ wfOut( "Checking for additional recent changes indices...\n" );
939939
940940 $indexes = array(
941941 'rc_ns_usertext' => 'patch-recentchanges-utindex.sql',
@@ -944,59 +944,59 @@
945945 foreach( $indexes as $index => $patch ) {
946946 $info = $wgDatabase->indexInfo( 'recentchanges', $index, __METHOD__ );
947947 if( !$info ) {
948 - echo( "...index `{$index}` not found; adding..." );
 948+ wfOut( "...index `{$index}` not found; adding..." );
949949 dbsource( archive( $patch ) );
950 - echo( "done.\n" );
 950+ wfOut( "done.\n" );
951951 } else {
952 - echo( "...index `{$index}` seems ok.\n" );
 952+ wfOut( "...index `{$index}` seems ok.\n" );
953953 }
954954 }
955955 }
956956
957957 function index_has_field($table, $index, $field) {
958958 global $wgDatabase;
959 - echo( "Checking if $table index $index includes field $field...\n" );
 959+ wfOut( "Checking if $table index $index includes field $field...\n" );
960960 $info = $wgDatabase->indexInfo( $table, $index, __METHOD__ );
961961 if( $info ) {
962962 foreach($info as $row) {
963963 if($row->Column_name == $field) {
964 - echo( "...index $index on table $table seems to be ok\n" );
 964+ wfOut( "...index $index on table $table seems to be ok\n" );
965965 return true;
966966 }
967967 }
968968 }
969 - echo( "...index $index on table $table has no field $field; adding\n" );
 969+ wfOut( "...index $index on table $table has no field $field; adding\n" );
970970 return false;
971971 }
972972
973973 function do_backlinking_indices_update() {
974 - echo( "Checking for backlinking indices...\n" );
 974+ wfOut( "Checking for backlinking indices...\n" );
975975 if (!index_has_field('pagelinks', 'pl_namespace', 'pl_from') ||
976976 !index_has_field('templatelinks', 'tl_namespace', 'tl_from') ||
977977 !index_has_field('imagelinks', 'il_to', 'il_from'))
978978 {
979979 dbsource( archive( 'patch-backlinkindexes.sql' ) );
980 - echo( "...backlinking indices updated\n" );
 980+ wfOut( "...backlinking indices updated\n" );
981981 }
982982 }
983983
984984 function do_categorylinks_indices_update() {
985 - echo( "Checking for categorylinks indices...\n" );
 985+ wfOut( "Checking for categorylinks indices...\n" );
986986 if (!index_has_field('categorylinks', 'cl_sortkey', 'cl_from'))
987987 {
988988 dbsource( archive( 'patch-categorylinksindex.sql' ) );
989 - echo( "...categorylinks indices updated\n" );
 989+ wfOut( "...categorylinks indices updated\n" );
990990 }
991991 }
992992
993993 function do_filearchive_indices_update() {
994994 global $wgDatabase;
995 - echo( "Checking filearchive indices...\n" );
 995+ wfOut( "Checking filearchive indices...\n" );
996996 $info = $wgDatabase->indexInfo( 'filearchive', 'fa_user_timestamp', __METHOD__ );
997997 if ( !$info )
998998 {
999999 dbsource( archive( 'patch-filearhive-user-index.sql' ) );
1000 - echo( "...filearchive indices updated\n" );
 1000+ wfOut( "...filearchive indices updated\n" );
10011001 }
10021002 }
10031003
@@ -1005,25 +1005,25 @@
10061006 if ( !$wgDatabase->tableExists( 'profiling' ) ) {
10071007 // Simply ignore
10081008 } elseif ( $wgDatabase->fieldExists( 'profiling', 'pf_memory' ) ) {
1009 - echo "profiling table has pf_memory field.\n";
 1009+ wfOut( "profiling table has pf_memory field.\n" );
10101010 } else {
1011 - echo "Adding pf_memory field to table profiling...";
 1011+ wfOut( "Adding pf_memory field to table profiling..." );
10121012 dbsource( archive( 'patch-profiling-memory.sql' ), $wgDatabase );
1013 - echo "ok\n";
 1013+ wfOut( "ok\n" );
10141014 }
10151015 }
10161016
10171017 function do_stats_init() {
10181018 // Sometimes site_stats table is not properly populated.
10191019 global $wgDatabase;
1020 - echo "Checking site_stats row...";
 1020+ wfOut( "Checking site_stats row..." );
10211021 $row = $wgDatabase->selectRow( 'site_stats', '*', array( 'ss_row_id' => 1 ), __METHOD__ );
10221022 if( $row === false ) {
1023 - echo "data is missing! rebuilding...\n";
 1023+ wfOut( "data is missing! rebuilding...\n" );
10241024 } elseif ( isset( $row->site_stats ) && $row->ss_total_pages == -1 ) {
1025 - echo "missing ss_total_pages, rebuilding...\n";
 1025+ wfOut( "missing ss_total_pages, rebuilding...\n" );
10261026 } else {
1027 - echo "ok.\n";
 1027+ wfOut( "ok.\n" );
10281028 return;
10291029 }
10301030
@@ -1045,16 +1045,16 @@
10461046 array( 'ss_row_id' => 1 ), __METHOD__, array( 'LIMIT' => 1 )
10471047 );
10481048 }
1049 - echo( "...ss_active_users user count set...\n" );
 1049+ wfOut( "...ss_active_users user count set...\n" );
10501050 }
10511051
10521052 function purge_cache() {
10531053 global $wgDatabase;
10541054 # We can't guarantee that the user will be able to use TRUNCATE,
10551055 # but we know that DELETE is available to us
1056 - echo( "Purging caches..." );
 1056+ wfOut( "Purging caches..." );
10571057 $wgDatabase->delete( 'objectcache', '*', __METHOD__ );
1058 - echo( "done.\n" );
 1058+ wfOut( "done.\n" );
10591059 }
10601060
10611061 function do_all_updates( $shared = false, $purge = true ) {
@@ -1098,15 +1098,14 @@
10991099 }
11001100
11011101
1102 - echo "Deleting old default messages (this may take a long time!)..."; flush();
 1102+ wfOut( "Deleting old default messages (this may take a long time!)..." );
11031103 deleteDefaultMessages();
1104 - echo "Done\n"; flush();
 1104+ wfOut( "Done\n" );
11051105
1106 - do_stats_init(); flush();
 1106+ do_stats_init();
11071107
11081108 if( $purge ) {
11091109 purge_cache();
1110 - flush();
11111110 }
11121111 }
11131112
@@ -1132,14 +1131,14 @@
11331132 $patch2 = 'patch-page_restrictions_sortkey.sql';
11341133
11351134 if ( $wgDatabase->tableExists( $name ) ) {
1136 - echo "...$name table already exists.\n";
 1135+ wfOut( "...$name table already exists.\n" );
11371136 } else {
1138 - echo "Creating $name table...";
 1137+ wfOut( "Creating $name table..." );
11391138 dbsource( archive($patch), $wgDatabase );
11401139 dbsource( archive($patch2), $wgDatabase );
1141 - echo "ok\n";
 1140+ wfOut( "ok\n" );
11421141
1143 - echo "Migrating old restrictions to new table...";
 1142+ wfOut( "Migrating old restrictions to new table..." );
11441143
11451144 $res = $wgDatabase->select( 'page', array( 'page_id', 'page_restrictions' ), array("page_restrictions!=''", "page_restrictions!='edit=:move='"), __METHOD__ );
11461145
@@ -1191,27 +1190,27 @@
11921191 __METHOD__ );
11931192 }
11941193 }
1195 - print "ok\n";
 1194+ wfOut( "ok\n" );
11961195 }
11971196 }
11981197
11991198 function do_category_population() {
12001199 if( update_row_exists( 'populate category' ) ) {
1201 - echo "...category table already populated.\n";
 1200+ wfOut( "...category table already populated.\n" );
12021201 return;
12031202 }
12041203 require_once( 'populateCategory.inc' );
1205 - echo "Populating category table, printing progress markers. ".
 1204+ wfOut( "Populating category table, printing progress markers. " ).
12061205 "For large databases, you\n".
12071206 "may want to hit Ctrl-C and do this manually with maintenance/\n".
12081207 "populateCategory.php.\n";
12091208 populateCategory( '', 10, 0, true );
1210 - echo "Done populating category table.\n";
 1209+ wfOut( "Done populating category table.\n" );
12111210 }
12121211
12131212 function do_populate_parent_id() {
12141213 if( update_row_exists( 'populate rev_parent_id' ) ) {
1215 - echo "...rev_parent_id column already populated.\n";
 1214+ wfOut( "...rev_parent_id column already populated.\n" );
12161215 return;
12171216 }
12181217 require_once( 'populateParentId.inc' );
@@ -1222,11 +1221,11 @@
12231222
12241223 function update_password_format() {
12251224 if ( update_row_exists( 'password format' ) ) {
1226 - echo "...password hash format already changed\n";
 1225+ wfOut( "...password hash format already changed\n" );
12271226 return;
12281227 }
12291228
1230 - echo "Updating password hash format...";
 1229+ wfOut( "Updating password hash format..." );
12311230
12321231 global $wgDatabase, $wgPasswordSalt;
12331232 $user = $wgDatabase->tableName( 'user' );
@@ -1240,7 +1239,7 @@
12411240 $wgDatabase->query( $sql, __METHOD__ );
12421241 $wgDatabase->insert( 'updatelog', array( 'ul_key' => 'password format' ), __METHOD__ );
12431242
1244 - echo "done\n";
 1243+ wfOut( "done\n" );
12451244 }
12461245
12471246 function
@@ -1400,11 +1399,11 @@
14011400 $search_path = $conf['search_path'];
14021401 }
14031402 if( strpos( $search_path, $wgDBmwschema ) === false ) {
1404 - echo "Adding in schema \"$wgDBmwschema\" to search_path for user \"$wgDBuser\"\n";
 1403+ wfOut( "Adding in schema \"$wgDBmwschema\" to search_path for user \"$wgDBuser\"\n" );
14051404 $search_path = "$wgDBmwschema, $search_path";
14061405 }
14071406 if( strpos( $search_path, $wgDBts2schema ) === false ) {
1408 - echo "Adding in schema \"$wgDBts2schema\" to search_path for user \"$wgDBuser\"\n";
 1407+ wfOut( "Adding in schema \"$wgDBts2schema\" to search_path for user \"$wgDBuser\"\n" );
14091408 $search_path = "$search_path, $wgDBts2schema";
14101409 }
14111410 if( array_key_exists( 'search_path', $conf ) === false || $search_path != $conf['search_path'] ) {
@@ -1413,7 +1412,7 @@
14141413 }
14151414 else {
14161415 $path = $conf['search_path'];
1417 - echo "... search_path for user \"$wgDBuser\" looks correct ($path)\n";
 1416+ wfOut( "... search_path for user \"$wgDBuser\" looks correct ($path)\n" );
14181417 }
14191418 $goodconf = array(
14201419 'client_min_messages' => 'error',
@@ -1423,12 +1422,12 @@
14241423 foreach( array_keys( $goodconf ) AS $key ) {
14251424 $value = $goodconf[$key];
14261425 if( !array_key_exists( $key, $conf ) or $conf[$key] !== $value ) {
1427 - echo "Setting $key to '$value' for user \"$wgDBuser\"\n";
 1426+ wfOut( "Setting $key to '$value' for user \"$wgDBuser\"\n" );
14281427 $wgDatabase->doQuery( "ALTER USER $wgDBuser SET $key = '$value'" );
14291428 $wgDatabase->doQuery( "SET $key = '$value'" );
14301429 }
14311430 else {
1432 - echo "... default value of \"$key\" is correctly set to \"$value\" for user \"$wgDBuser\"\n";
 1431+ wfOut( "... default value of \"$key\" is correctly set to \"$value\" for user \"$wgDBuser\"\n" );
14331432 }
14341433 }
14351434
@@ -1557,62 +1556,62 @@
15581557
15591558 foreach ($newsequences as $ns) {
15601559 if ($wgDatabase->sequenceExists($ns)) {
1561 - echo "... sequence \"$ns\" already exists\n";
 1560+ wfOut( "... sequence \"$ns\" already exists\n" );
15621561 continue;
15631562 }
15641563
1565 - echo "Creating sequence \"$ns\"\n";
 1564+ wfOut( "Creating sequence \"$ns\"\n" );
15661565 $wgDatabase->query("CREATE SEQUENCE $ns");
15671566 }
15681567
15691568 foreach ($newtables as $nt) {
15701569 if ($wgDatabase->tableExists($nt[0])) {
1571 - echo "... table \"$nt[0]\" already exists\n";
 1570+ wfOut( "... table \"$nt[0]\" already exists\n" );
15721571 continue;
15731572 }
15741573
1575 - echo "Creating table \"$nt[0]\"\n";
 1574+ wfOut( "Creating table \"$nt[0]\"\n" );
15761575 dbsource(archive($nt[1]));
15771576 }
15781577
15791578 ## Needed before newcols
15801579 if ($wgDatabase->tableExists("archive2")) {
1581 - echo "Converting \"archive2\" back to normal archive table\n";
 1580+ wfOut( "Converting \"archive2\" back to normal archive table\n" );
15821581 if ($wgDatabase->ruleExists("archive", "archive_insert")) {
1583 - echo "Dropping rule \"archive_insert\"\n";
 1582+ wfOut( "Dropping rule \"archive_insert\"\n" );
15841583 $wgDatabase->query("DROP RULE archive_insert ON archive");
15851584 }
15861585 if ($wgDatabase->ruleExists("archive", "archive_delete")) {
1587 - echo "Dropping rule \"archive_delete\"\n";
 1586+ wfOut( "Dropping rule \"archive_delete\"\n" );
15881587 $wgDatabase->query("DROP RULE archive_delete ON archive");
15891588 }
15901589 dbsource(archive("patch-remove-archive2.sql"));
15911590 }
15921591 else
1593 - echo "... obsolete table \"archive2\" does not exist\n";
 1592+ wfOut( "... obsolete table \"archive2\" does not exist\n" );
15941593
15951594 foreach ($newcols as $nc) {
15961595 $fi = $wgDatabase->fieldInfo($nc[0], $nc[1]);
15971596 if (!is_null($fi)) {
1598 - echo "... column \"$nc[0].$nc[1]\" already exists\n";
 1597+ wfOut( "... column \"$nc[0].$nc[1]\" already exists\n" );
15991598 continue;
16001599 }
16011600
1602 - echo "Adding column \"$nc[0].$nc[1]\"\n";
 1601+ wfOut( "Adding column \"$nc[0].$nc[1]\"\n" );
16031602 $wgDatabase->query("ALTER TABLE $nc[0] ADD $nc[1] $nc[2]");
16041603 }
16051604
16061605 foreach ($typechanges as $tc) {
16071606 $fi = $wgDatabase->fieldInfo($tc[0], $tc[1]);
16081607 if (is_null($fi)) {
1609 - echo "... error: expected column $tc[0].$tc[1] to exist\n";
 1608+ wfOut( "... error: expected column $tc[0].$tc[1] to exist\n" );
16101609 exit(1);
16111610 }
16121611
16131612 if ($fi->type() === $tc[2])
1614 - echo "... column \"$tc[0].$tc[1]\" is already of type \"$tc[2]\"\n";
 1613+ wfOut( "... column \"$tc[0].$tc[1]\" is already of type \"$tc[2]\"\n" );
16151614 else {
1616 - echo "Changing column type of \"$tc[0].$tc[1]\" from \"{$fi->type()}\" to \"$tc[2]\"\n";
 1615+ wfOut( "Changing column type of \"$tc[0].$tc[1]\" from \"{$fi->type()}\" to \"$tc[2]\"\n" );
16171616 $sql = "ALTER TABLE $tc[0] ALTER $tc[1] TYPE $tc[2]";
16181617 if (strlen($tc[3])) {
16191618 $default = array();
@@ -1629,91 +1628,91 @@
16301629 }
16311630
16321631 if ($wgDatabase->fieldInfo('oldimage','oi_deleted')->type() !== 'smallint') {
1633 - echo "Changing \"oldimage.oi_deleted\" to type \"smallint\"\n";
 1632+ wfOut( "Changing \"oldimage.oi_deleted\" to type \"smallint\"\n" );
16341633 $wgDatabase->query( "ALTER TABLE oldimage ALTER oi_deleted DROP DEFAULT" );
16351634 $wgDatabase->query( "ALTER TABLE oldimage ALTER oi_deleted TYPE SMALLINT USING (oi_deleted::smallint)" );
16361635 $wgDatabase->query( "ALTER TABLE oldimage ALTER oi_deleted SET DEFAULT 0" );
16371636 }
16381637 else
1639 - echo "... column \"oldimage.oi_deleted\" is already of type \"smallint\"\n";
 1638+ wfOut( "... column \"oldimage.oi_deleted\" is already of type \"smallint\"\n" );
16401639
16411640
16421641 foreach ($newindexes as $ni) {
16431642 if (pg_index_exists($ni[0], $ni[1])) {
1644 - echo "... index \"$ni[1]\" on table \"$ni[0]\" already exists\n";
 1643+ wfOut( "... index \"$ni[1]\" on table \"$ni[0]\" already exists\n" );
16451644 continue;
16461645 }
1647 - echo "Creating index \"$ni[1]\" on table \"$ni[0]\" $ni[2]\n";
 1646+ wfOut( "Creating index \"$ni[1]\" on table \"$ni[0]\" $ni[2]\n" );
16481647 $wgDatabase->query( "CREATE INDEX $ni[1] ON $ni[0] $ni[2]" );
16491648 }
16501649
16511650 foreach ($newrules as $nr) {
16521651 if ($wgDatabase->ruleExists($nr[0], $nr[1])) {
1653 - echo "... rule \"$nr[1]\" on table \"$nr[0]\" already exists\n";
 1652+ wfOut( "... rule \"$nr[1]\" on table \"$nr[0]\" already exists\n" );
16541653 continue;
16551654 }
1656 - echo "Adding rule \"$nr[1]\" to table \"$nr[0]\"\n";
 1655+ wfOut( "Adding rule \"$nr[1]\" to table \"$nr[0]\"\n" );
16571656 dbsource(archive($nr[2]));
16581657 }
16591658
16601659 if ($wgDatabase->hasConstraint("oldimage_oi_name_fkey")) {
1661 - echo "Making foriegn key on table \"oldimage\" (to image) a cascade delete\n";
 1660+ wfOut( "Making foriegn key on table \"oldimage\" (to image) a cascade delete\n" );
16621661 $wgDatabase->query( "ALTER TABLE oldimage DROP CONSTRAINT oldimage_oi_name_fkey" );
16631662 $wgDatabase->query( "ALTER TABLE oldimage ADD CONSTRAINT oldimage_oi_name_fkey_cascade ".
16641663 "FOREIGN KEY (oi_name) REFERENCES image(img_name) ON DELETE CASCADE" );
16651664 }
16661665 else
1667 - echo "... table \"oldimage\" has correct cascade delete foreign key to image\n";
 1666+ wfOut( "... table \"oldimage\" has correct cascade delete foreign key to image\n" );
16681667
16691668 if (!$wgDatabase->triggerExists("page", "page_deleted")) {
1670 - echo "Adding function and trigger \"page_deleted\" to table \"page\"\n";
 1669+ wfOut( "Adding function and trigger \"page_deleted\" to table \"page\"\n" );
16711670 dbsource(archive('patch-page_deleted.sql'));
16721671 }
16731672 else
1674 - echo "... table \"page\" has \"page_deleted\" trigger\n";
 1673+ wfOut( "... table \"page\" has \"page_deleted\" trigger\n" );
16751674
16761675 $fi = $wgDatabase->fieldInfo("recentchanges", "rc_cur_id");
16771676 if (!$fi->nullable()) {
1678 - echo "Removing NOT NULL constraint from \"recentchanges.rc_cur_id\"\n";
 1677+ wfOut( "Removing NOT NULL constraint from \"recentchanges.rc_cur_id\"\n" );
16791678 dbsource(archive('patch-rc_cur_id-not-null.sql'));
16801679 }
16811680 else
1682 - echo "... column \"recentchanges.rc_cur_id\" has a NOT NULL constraint\n";
 1681+ wfOut( "... column \"recentchanges.rc_cur_id\" has a NOT NULL constraint\n" );
16831682
16841683 $pu = pg_describe_index("pagelink_unique");
16851684 if (!is_null($pu) && ($pu[0] != "pl_from" || $pu[1] != "pl_namespace" || $pu[2] != "pl_title")) {
1686 - echo "Dropping obsolete version of index \"pagelink_unique index\"\n";
 1685+ wfOut( "Dropping obsolete version of index \"pagelink_unique index\"\n" );
16871686 $wgDatabase->query("DROP INDEX pagelink_unique");
16881687 $pu = null;
16891688 }
16901689 else
1691 - echo "... obsolete version of index \"pagelink_unique index\" does not exist\n";
 1690+ wfOut( "... obsolete version of index \"pagelink_unique index\" does not exist\n" );
16921691
16931692 if (is_null($pu)) {
1694 - echo "Creating index \"pagelink_unique index\"\n";
 1693+ wfOut( "Creating index \"pagelink_unique index\"\n" );
16951694 $wgDatabase->query("CREATE UNIQUE INDEX pagelink_unique ON pagelinks (pl_from,pl_namespace,pl_title)");
16961695 }
16971696 else
1698 - echo "... index \"pagelink_unique_index\" already exists\n";
 1697+ wfOut( "... index \"pagelink_unique_index\" already exists\n" );
16991698
17001699 if (pg_fkey_deltype("revision_rev_user_fkey") == 'r') {
1701 - echo "... constraint \"revision_rev_user_fkey\" is ON DELETE RESTRICT\n";
 1700+ wfOut( "... constraint \"revision_rev_user_fkey\" is ON DELETE RESTRICT\n" );
17021701 }
17031702 else {
1704 - echo "Changing constraint \"revision_rev_user_fkey\" to ON DELETE RESTRICT\n";
 1703+ wfOut( "Changing constraint \"revision_rev_user_fkey\" to ON DELETE RESTRICT\n" );
17051704 dbsource(archive('patch-revision_rev_user_fkey.sql'));
17061705 }
17071706
17081707 # Fix ipb_address index
17091708 if (pg_index_exists('ipblocks', 'ipb_address' )) {
1710 - echo "Removing deprecated index 'ipb_address'...\n";
 1709+ wfOut( "Removing deprecated index 'ipb_address'...\n" );
17111710 $wgDatabase->query('DROP INDEX ipb_address');
17121711 }
17131712 if (pg_index_exists('ipblocks', 'ipb_address_unique' )) {
1714 - echo "... have ipb_address_unique\n";
 1713+ wfOut( "... have ipb_address_unique\n" );
17151714 }
17161715 else {
1717 - echo "Adding ipb_address_unique index\n";
 1716+ wfOut( "Adding ipb_address_unique index\n" );
17181717 dbsource(archive('patch-ipb_address_unique.sql'));
17191718 }
17201719
@@ -1721,29 +1720,29 @@
17221721 # Add missing extension tables
17231722 foreach ( $wgExtNewTables as $nt ) {
17241723 if ($wgDatabase->tableExists($nt[0])) {
1725 - echo "... table \"$nt[0]\" already exists\n";
 1724+ wfOut( "... table \"$nt[0]\" already exists\n" );
17261725 continue;
17271726 }
1728 - echo "Creating table \"$nt[0]\"\n";
 1727+ wfOut( "Creating table \"$nt[0]\"\n" );
17291728 dbsource($nt[1]);
17301729 }
17311730 # Add missing extension fields
17321731 foreach ( $wgExtPGNewFields as $nc ) {
17331732 $fi = $wgDatabase->fieldInfo($nc[0], $nc[1]);
17341733 if (!is_null($fi)) {
1735 - echo "... column \"$nc[0].$nc[1]\" already exists\n";
 1734+ wfOut( "... column \"$nc[0].$nc[1]\" already exists\n" );
17361735 continue;
17371736 }
1738 - echo "Adding column \"$nc[0].$nc[1]\"\n";
 1737+ wfOut( "Adding column \"$nc[0].$nc[1]\"\n" );
17391738 $wgDatabase->query( "ALTER TABLE $nc[0] ADD $nc[1] $nc[2]" );
17401739 }
17411740 # Add missing extension indexes
17421741 foreach ( $wgExtNewIndexes as $ni ) {
17431742 if (pg_index_exists($ni[0], $ni[1])) {
1744 - echo "... index \"$ni[1]\" on table \"$ni[0]\" already exists\n";
 1743+ wfOut( "... index \"$ni[1]\" on table \"$ni[0]\" already exists\n" );
17451744 continue;
17461745 }
1747 - echo "Creating index \"$ni[1]\" on table \"$ni[0]\"\n";
 1746+ wfOut( "Creating index \"$ni[1]\" on table \"$ni[0]\"\n" );
17481747 dbsource($ni[2]);
17491748 }
17501749
Index: branches/REL1_14/phase3/maintenance/userDupes.inc
@@ -45,7 +45,7 @@
4646 $fname = 'UserDupes::hasUniqueIndex';
4747 $info = $this->db->indexInfo( 'user', 'user_name', $fname );
4848 if( !$info ) {
49 - echo "WARNING: doesn't seem to have user_name index at all!\n";
 49+ wfOut( "WARNING: doesn't seem to have user_name index at all!\n" );
5050 return false;
5151 }
5252
@@ -92,11 +92,11 @@
9393
9494 $this->lock();
9595
96 - echo "Checking for duplicate accounts...\n";
 96+ wfOut( "Checking for duplicate accounts...\n" );
9797 $dupes = $this->getDupes();
9898 $count = count( $dupes );
9999
100 - echo "Found $count accounts with duplicate records on ".wfWikiID().".\n";
 100+ wfOut( "Found $count accounts with duplicate records on ".wfWikiID().".\n" );
101101 $this->trimmed = 0;
102102 $this->reassigned = 0;
103103 $this->failed = 0;
@@ -106,34 +106,34 @@
107107
108108 $this->unlock();
109109
110 - echo "\n";
 110+ wfOut( "\n" );
111111
112112 if( $this->reassigned > 0 ) {
113113 if( $doDelete ) {
114 - echo "$this->reassigned duplicate accounts had edits reassigned to a canonical record id.\n";
 114+ wfOut( "$this->reassigned duplicate accounts had edits reassigned to a canonical record id.\n" );
115115 } else {
116 - echo "$this->reassigned duplicate accounts need to have edits reassigned.\n";
 116+ wfOut( "$this->reassigned duplicate accounts need to have edits reassigned.\n" );
117117 }
118118 }
119119
120120 if( $this->trimmed > 0 ) {
121121 if( $doDelete ) {
122 - echo "$this->trimmed duplicate user records were deleted from ".wfWikiID().".\n";
 122+ wfOut( "$this->trimmed duplicate user records were deleted from ".wfWikiID().".\n" );
123123 } else {
124 - echo "$this->trimmed duplicate user accounts were found on ".wfWikiID()." which can be removed safely.\n";
 124+ wfOut( "$this->trimmed duplicate user accounts were found on ".wfWikiID()." which can be removed safely.\n" );
125125 }
126126 }
127127
128128 if( $this->failed > 0 ) {
129 - echo "Something terribly awry; $this->failed duplicate accounts were not removed.\n";
 129+ wfOut( "Something terribly awry; $this->failed duplicate accounts were not removed.\n" );
130130 return false;
131131 }
132132
133133 if( $this->trimmed == 0 || $doDelete ) {
134 - echo "It is now safe to apply the unique index on user_name.\n";
 134+ wfOut( "It is now safe to apply the unique index on user_name.\n" );
135135 return true;
136136 } else {
137 - echo "Run this script again with the --fix option to automatically delete them.\n";
 137+ wfOut( "Run this script again with the --fix option to automatically delete them.\n" );
138138 return false;
139139 }
140140 }
@@ -215,36 +215,36 @@
216216
217217 $firstRow = $this->db->fetchObject( $result );
218218 $firstId = $firstRow->user_id;
219 - echo "Record that will be used for '$name' is user_id=$firstId\n";
 219+ wfOut( "Record that will be used for '$name' is user_id=$firstId\n" );
220220
221221 while( $row = $this->db->fetchObject( $result ) ) {
222222 $dupeId = $row->user_id;
223 - echo "... dupe id $dupeId: ";
 223+ wfOut( "... dupe id $dupeId: " );
224224 $edits = $this->editCount( $dupeId );
225225 if( $edits > 0 ) {
226226 $this->reassigned++;
227 - echo "has $edits edits! ";
 227+ wfOut( "has $edits edits! " );
228228 if( $doDelete ) {
229229 $this->reassignEdits( $dupeId, $firstId );
230230 $newEdits = $this->editCount( $dupeId );
231231 if( $newEdits == 0 ) {
232 - echo "confirmed cleaned. ";
 232+ wfOut( "confirmed cleaned. " );
233233 } else {
234234 $this->failed++;
235 - echo "WARNING! $newEdits remaining edits for $dupeId; NOT deleting user.\n";
 235+ wfOut( "WARNING! $newEdits remaining edits for $dupeId; NOT deleting user.\n" );
236236 continue;
237237 }
238238 } else {
239 - echo "(will need to reassign edits on fix)";
 239+ wfOut( "(will need to reassign edits on fix)" );
240240 }
241241 } else {
242 - echo "ok, no edits. ";
 242+ wfOut( "ok, no edits. " );
243243 }
244244 $this->trimmed++;
245245 if( $doDelete ) {
246246 $this->trimAccount( $dupeId );
247247 }
248 - echo "\n";
 248+ wfOut( "\n" );
249249 }
250250 $this->db->freeResult( $result );
251251 }
@@ -306,12 +306,12 @@
307307 */
308308 function reassignEditsOn( $table, $field, $from, $to ) {
309309 $fname = 'UserDupes::reassignEditsOn';
310 - echo "reassigning on $table... ";
 310+ wfOut( "reassigning on $table... " );
311311 $this->db->update( $table,
312312 array( $field => $to ),
313313 array( $field => $from ),
314314 $fname );
315 - echo "ok. ";
 315+ wfOut( "ok. " );
316316 }
317317
318318 /**
@@ -321,9 +321,9 @@
322322 */
323323 function trimAccount( $userid ) {
324324 $fname = 'UserDupes::trimAccount';
325 - echo "deleting...";
 325+ wfOut( "deleting..." );
326326 $this->db->delete( 'user', array( 'user_id' => $userid ), $fname );
327 - echo " ok";
 327+ wfOut( " ok" );
328328 }
329329
330330 }
Index: branches/REL1_14/phase3/maintenance/populateParentId.inc
@@ -3,11 +3,11 @@
44 define( 'BATCH_SIZE', 200 );
55
66 function populate_rev_parent_id( $db ) {
7 - echo "Populating rev_parent_id column\n";
 7+ wfOut( "Populating rev_parent_id column\n" );
88 $start = $db->selectField( 'revision', 'MIN(rev_id)', false, __FUNCTION__ );
99 $end = $db->selectField( 'revision', 'MAX(rev_id)', false, __FUNCTION__ );
1010 if( is_null( $start ) || is_null( $end ) ){
11 - echo "...revision table seems to be empty.\n";
 11+ wfOut( "...revision table seems to be empty.\n" );
1212 $db->insert( 'updatelog',
1313 array( 'ul_key' => 'populate rev_parent_id' ),
1414 __FUNCTION__,
@@ -16,12 +16,12 @@
1717 }
1818 # Do remaining chunk
1919 $end += BATCH_SIZE - 1;
20 - $blockStart = $start;
21 - $blockEnd = $start + BATCH_SIZE - 1;
 20+ $blockStart = intval( $start );
 21+ $blockEnd = intval( $start ) + BATCH_SIZE - 1;
2222 $count = 0;
2323 $changed = 0;
2424 while( $blockEnd <= $end ) {
25 - echo "...doing rev_id from $blockStart to $blockEnd\n";
 25+ wfOut( "...doing rev_id from $blockStart to $blockEnd\n" );
2626 $cond = "rev_id BETWEEN $blockStart AND $blockEnd";
2727 $res = $db->select( 'revision',
2828 array('rev_id','rev_page','rev_timestamp','rev_parent_id'),
@@ -36,14 +36,14 @@
3737 # as timestamp can only decrease and never loops with IDs (from parent to parent)
3838 $previousID = $db->selectField( 'revision', 'rev_id',
3939 array( 'rev_page' => $row->rev_page, 'rev_timestamp' => $row->rev_timestamp,
40 - "rev_id < {$row->rev_id}" ),
 40+ "rev_id < " . intval( $row->rev_id ) ),
4141 __FUNCTION__,
4242 array( 'ORDER BY' => 'rev_id DESC' ) );
4343 # If there are none, check the the highest ID with a lower timestamp
4444 if( !$previousID ) {
4545 # Get the highest older timestamp
4646 $lastTimestamp = $db->selectField( 'revision', 'rev_timestamp',
47 - array( 'rev_page' => $row->rev_page, "rev_timestamp < '{$row->rev_timestamp}'" ),
 47+ array( 'rev_page' => $row->rev_page, "rev_timestamp < " . $db->addQuotes( $row->rev_timestamp ) ),
4848 __FUNCTION__,
4949 array( 'ORDER BY' => 'rev_timestamp DESC' ) );
5050 # If there is one, let the highest rev ID win
@@ -73,10 +73,10 @@
7474 __FUNCTION__,
7575 'IGNORE' );
7676 if( $logged ) {
77 - echo "rev_parent_id population complete ... {$count} rows [{$changed} changed]\n";
 77+ wfOut( "rev_parent_id population complete ... {$count} rows [{$changed} changed]\n" );
7878 return true;
7979 } else {
80 - echo "Could not insert rev_parent_id population row.\n";
 80+ wfOut( "Could not insert rev_parent_id population row.\n" );
8181 return false;
8282 }
8383 }
Index: branches/REL1_14/phase3/maintenance/convertLinks.inc
@@ -9,11 +9,11 @@
1010 function convertLinks() {
1111 global $wgDBtype;
1212 if( $wgDBtype == 'postgres' ) {
13 - print "Links table already ok on Postgres.\n";
 13+ wfOut( "Links table already ok on Postgres.\n" );
1414 return;
1515 }
1616
17 - print "Converting links table to ID-ID...\n";
 17+ wfOut( "Converting links table to ID-ID...\n" );
1818
1919 global $wgLang, $wgDBserver, $wgDBadminuser, $wgDBadminpassword, $wgDBname;
2020 global $noKeys, $logPerformance, $fh;
@@ -48,7 +48,7 @@
4949
5050 $res = $dbw->query( "SELECT l_from FROM $links LIMIT 1" );
5151 if ( $dbw->fieldType( $res, 0 ) == "int" ) {
52 - print "Schema already converted\n";
 52+ wfOut( "Schema already converted\n" );
5353 return;
5454 }
5555
@@ -58,13 +58,13 @@
5959 $dbw->freeResult( $res );
6060
6161 if ( $numRows == 0 ) {
62 - print "Updating schema (no rows to convert)...\n";
 62+ wfOut( "Updating schema (no rows to convert)...\n" );
6363 createTempTable();
6464 } else {
6565 if ( $logPerformance ) { $fh = fopen ( $perfLogFilename, "w" ); }
6666 $baseTime = $startTime = getMicroTime();
6767 # Create a title -> cur_id map
68 - print "Loading IDs from $cur table...\n";
 68+ wfOut( "Loading IDs from $cur table...\n" );
6969 performanceLog ( "Reading $numRows rows from cur table...\n" );
7070 performanceLog ( "rows read vs seconds elapsed:\n" );
7171
@@ -82,13 +82,13 @@
8383 if ($reportCurReadProgress) {
8484 if (($curRowsRead % $curReadReportInterval) == 0) {
8585 performanceLog( $curRowsRead . " " . (getMicroTime() - $baseTime) . "\n" );
86 - print "\t$curRowsRead rows of $cur table read.\n";
 86+ wfOut( "\t$curRowsRead rows of $cur table read.\n" );
8787 }
8888 }
8989 }
9090 $dbw->freeResult( $res );
9191 $dbw->bufferResults( true );
92 - print "Finished loading IDs.\n\n";
 92+ wfOut( "Finished loading IDs.\n\n" );
9393 performanceLog( "Took " . (getMicroTime() - $baseTime) . " seconds to load IDs.\n\n" );
9494 #--------------------------------------------------------------------
9595
@@ -97,7 +97,7 @@
9898 createTempTable();
9999 performanceLog( "Resetting timer.\n\n" );
100100 $baseTime = getMicroTime();
101 - print "Processing $numRows rows from $links table...\n";
 101+ wfOut( "Processing $numRows rows from $links table...\n" );
102102 performanceLog( "Processing $numRows rows from $links table...\n" );
103103 performanceLog( "rows inserted vs seconds elapsed:\n" );
104104
@@ -127,19 +127,19 @@
128128 }
129129 }
130130 $dbw->freeResult($res);
131 - #print "rowOffset: $rowOffset\ttuplesAdded: $tuplesAdded\tnumBadLinks: $numBadLinks\n";
 131+ #wfOut( "rowOffset: $rowOffset\ttuplesAdded: $tuplesAdded\tnumBadLinks: $numBadLinks\n" );
132132 if ( $tuplesAdded != 0 ) {
133133 if ($reportLinksConvProgress) {
134 - print "Inserting $tuplesAdded tuples into $links_temp...";
 134+ wfOut( "Inserting $tuplesAdded tuples into $links_temp..." );
135135 }
136136 $dbw->query( implode("",$sqlWrite) );
137137 $totalTuplesInserted += $tuplesAdded;
138138 if ($reportLinksConvProgress)
139 - print " done. Total $totalTuplesInserted tuples inserted.\n";
 139+ wfOut( " done. Total $totalTuplesInserted tuples inserted.\n" );
140140 performanceLog( $totalTuplesInserted . " " . (getMicroTime() - $baseTime) . "\n" );
141141 }
142142 }
143 - print "$totalTuplesInserted valid titles and $numBadLinks invalid titles were processed.\n\n";
 143+ wfOut( "$totalTuplesInserted valid titles and $numBadLinks invalid titles were processed.\n\n" );
144144 performanceLog( "$totalTuplesInserted valid titles and $numBadLinks invalid titles were processed.\n" );
145145 performanceLog( "Total execution time: " . (getMicroTime() - $startTime) . " seconds.\n" );
146146 if ( $logPerformance ) { fclose ( $fh ); }
@@ -149,25 +149,25 @@
150150 if ( $overwriteLinksTable ) {
151151 $dbConn = Database::newFromParams( $wgDBserver, $wgDBadminuser, $wgDBadminpassword, $wgDBname );
152152 if (!($dbConn->isOpen())) {
153 - print "Opening connection to database failed.\n";
 153+ wfOut( "Opening connection to database failed.\n" );
154154 return;
155155 }
156156 # Check for existing links_backup, and delete it if it exists.
157 - print "Dropping backup links table if it exists...";
 157+ wfOut( "Dropping backup links table if it exists..." );
158158 $dbConn->query( "DROP TABLE IF EXISTS $links_backup", DB_MASTER);
159 - print " done.\n";
 159+ wfOut( " done.\n" );
160160
161161 # Swap in the new table, and move old links table to links_backup
162 - print "Swapping tables '$links' to '$links_backup'; '$links_temp' to '$links'...";
 162+ wfOut( "Swapping tables '$links' to '$links_backup'; '$links_temp' to '$links'..." );
163163 $dbConn->query( "RENAME TABLE links TO $links_backup, $links_temp TO $links", DB_MASTER );
164 - print " done.\n\n";
 164+ wfOut( " done.\n\n" );
165165
166166 $dbConn->close();
167 - print "Conversion complete. The old table remains at $links_backup;\n";
168 - print "delete at your leisure.\n";
 167+ wfOut( "Conversion complete. The old table remains at $links_backup;\n" );
 168+ wfOut( "delete at your leisure.\n" );
169169 } else {
170 - print "Conversion complete. The converted table is at $links_temp;\n";
171 - print "the original links table is unchanged.\n";
 170+ wfOut( "Conversion complete. The converted table is at $links_temp;\n" );
 171+ wfOut( "the original links table is unchanged.\n" );
172172 }
173173 }
174174
@@ -179,16 +179,16 @@
180180 $dbConn = Database::newFromParams( $wgDBserver, $wgDBadminuser, $wgDBadminpassword, $wgDBname );
181181
182182 if (!($dbConn->isOpen())) {
183 - print "Opening connection to database failed.\n";
 183+ wfOut( "Opening connection to database failed.\n" );
184184 return;
185185 }
186186 $links_temp = $dbConn->tableName( 'links_temp' );
187187
188 - print "Dropping temporary links table if it exists...";
 188+ wfOut( "Dropping temporary links table if it exists..." );
189189 $dbConn->query( "DROP TABLE IF EXISTS $links_temp");
190 - print " done.\n";
 190+ wfOut( " done.\n" );
191191
192 - print "Creating temporary links table...";
 192+ wfOut( "Creating temporary links table..." );
193193 if ( $noKeys ) {
194194 $dbConn->query( "CREATE TABLE $links_temp ( " .
195195 "l_from int(8) unsigned NOT NULL default '0', " .
@@ -200,7 +200,7 @@
201201 "UNIQUE KEY l_from(l_from,l_to), " .
202202 "KEY (l_to))");
203203 }
204 - print " done.\n\n";
 204+ wfOut( " done.\n\n" );
205205 }
206206
207207 function performanceLog( $text ) {
Index: branches/REL1_14/phase3/includes/GlobalFunctions.php
@@ -2904,6 +2904,21 @@
29052905 }
29062906 }
29072907
 2908+/**
 2909+ * Output some plain text in command-line mode or in the installer (updaters.inc).
 2910+ * Do not use it in any other context, its behaviour is subject to change.
 2911+ */
 2912+function wfOut( $s ) {
 2913+ static $lineStarted = false;
 2914+ global $wgCommandLineMode;
 2915+ if ( $wgCommandLineMode && !defined( 'MEDIAWIKI_INSTALL' ) ) {
 2916+ echo $s;
 2917+ } else {
 2918+ echo htmlspecialchars( $s );
 2919+ }
 2920+ flush();
 2921+}
 2922+
29082923 /** Generate a random 32-character hexadecimal token.
29092924 * @param mixed $salt Some sort of salt, if necessary, to add to random characters before hashing.
29102925 */
Index: branches/REL1_14/phase3/includes/db/DatabasePostgres.php
@@ -208,10 +208,10 @@
209209 $version = $this->getServerVersion();
210210 $PGMINVER = '8.1';
211211 if ($version < $PGMINVER) {
212 - print "<b>FAILED</b>. Required version is $PGMINVER. You have $version</li>\n";
 212+ print "<b>FAILED</b>. Required version is $PGMINVER. You have " . htmlspecialchars( $version ) . "</li>\n";
213213 dieout("</ul>");
214214 }
215 - print "version $this->numeric_version is OK.</li>\n";
 215+ print "version " . htmlspecialchars( $this->numeric_version ) . " is OK.</li>\n";
216216
217217 $safeuser = $this->quote_ident($wgDBuser);
218218 // Are we connecting as a superuser for the first time?
@@ -225,7 +225,7 @@
226226 FROM pg_catalog.pg_user WHERE usename = " . $this->addQuotes($wgDBsuperuser);
227227 $rows = $this->numRows($res = $this->doQuery($SQL));
228228 if (!$rows) {
229 - print "<li>ERROR: Could not read permissions for user \"$wgDBsuperuser\"</li>\n";
 229+ print "<li>ERROR: Could not read permissions for user \"" . htmlspecialchars( $wgDBsuperuser ) . "\"</li>\n";
230230 dieout('</ul>');
231231 }
232232 $perms = pg_fetch_result($res, 0, 0);
@@ -233,15 +233,15 @@
234234 $SQL = "SELECT 1 FROM pg_catalog.pg_user WHERE usename = " . $this->addQuotes($wgDBuser);
235235 $rows = $this->numRows($this->doQuery($SQL));
236236 if ($rows) {
237 - print "<li>User \"$wgDBuser\" already exists, skipping account creation.</li>";
 237+ print "<li>User \"" . htmlspecialchars( $wgDBuser ) . "\" already exists, skipping account creation.</li>";
238238 }
239239 else {
240240 if ($perms != 1 and $perms != 3) {
241 - print "<li>ERROR: the user \"$wgDBsuperuser\" cannot create other users. ";
 241+ print "<li>ERROR: the user \"" . htmlspecialchars( $wgDBsuperuser ) . "\" cannot create other users. ";
242242 print 'Please use a different Postgres user.</li>';
243243 dieout('</ul>');
244244 }
245 - print "<li>Creating user <b>$wgDBuser</b>...";
 245+ print "<li>Creating user <b>" . htmlspecialchars( $wgDBuser ) . "</b>...";
246246 $safepass = $this->addQuotes($wgDBpassword);
247247 $SQL = "CREATE USER $safeuser NOCREATEDB PASSWORD $safepass";
248248 $this->doQuery($SQL);
@@ -252,15 +252,15 @@
253253 $SQL = "SELECT 1 FROM pg_catalog.pg_database WHERE datname = " . $this->addQuotes($wgDBname);
254254 $rows = $this->numRows($this->doQuery($SQL));
255255 if ($rows) {
256 - print "<li>Database \"$wgDBname\" already exists, skipping database creation.</li>";
 256+ print "<li>Database \"" . htmlspecialchars( $wgDBname ) . "\" already exists, skipping database creation.</li>";
257257 }
258258 else {
259259 if ($perms < 2) {
260 - print "<li>ERROR: the user \"$wgDBsuperuser\" cannot create databases. ";
 260+ print "<li>ERROR: the user \"" . htmlspecialchars( $wgDBsuperuser ) . "\" cannot create databases. ";
261261 print 'Please use a different Postgres user.</li>';
262262 dieout('</ul>');
263263 }
264 - print "<li>Creating database <b>$wgDBname</b>...";
 264+ print "<li>Creating database <b>" . htmlspecialchars( $wgDBname ) . "</b>...";
265265 $safename = $this->quote_ident($wgDBname);
266266 $SQL = "CREATE DATABASE $safename OWNER $safeuser ";
267267 $this->doQuery($SQL);
@@ -269,17 +269,21 @@
270270 }
271271
272272 // Reconnect to check out tsearch2 rights for this user
273 - print "<li>Connecting to \"$wgDBname\" as superuser \"$wgDBsuperuser\" to check rights...";
 273+ print "<li>Connecting to \"" . htmlspecialchars( $wgDBname ) . "\" as superuser \"" .
 274+ htmlspecialchars( $wgDBsuperuser ) . "\" to check rights...";
274275
275 - $hstring="";
 276+ $connectVars = array();
276277 if ($this->mServer!=false && $this->mServer!="") {
277 - $hstring="host=$this->mServer ";
 278+ $connectVars['host'] = $this->mServer;
278279 }
279280 if ($this->mPort!=false && $this->mPort!="") {
280 - $hstring .= "port=$this->mPort ";
 281+ $connectVars['port'] = $this->mPort;
281282 }
 283+ $connectVars['dbname'] = $wgDBname;
 284+ $connectVars['user'] = $wgDBsuperuser;
 285+ $connectVars['password'] = $password;
282286
283 - @$this->mConn = pg_connect("$hstring dbname=$wgDBname user=$wgDBsuperuser password=$password");
 287+ @$this->mConn = pg_connect( $this->makeConnectionString( $connectVars ) );
284288 if ( $this->mConn == false ) {
285289 print "<b>FAILED TO CONNECT!</b></li>";
286290 dieout("</ul>");
@@ -289,15 +293,18 @@
290294
291295 if ($this->numeric_version < 8.3) {
292296 // Tsearch2 checks
293 - print "<li>Checking that tsearch2 is installed in the database \"$wgDBname\"...";
 297+ print "<li>Checking that tsearch2 is installed in the database \"" .
 298+ htmlspecialchars( $wgDBname ) . "\"...";
294299 if (! $this->tableExists("pg_ts_cfg", $wgDBts2schema)) {
295 - print "<b>FAILED</b>. tsearch2 must be installed in the database \"$wgDBname\".";
 300+ print "<b>FAILED</b>. tsearch2 must be installed in the database \"" .
 301+ htmlspecialchars( $wgDBname ) . "\".";
296302 print "Please see <a href='http://www.devx.com/opensource/Article/21674/0/page/2'>this article</a>";
297303 print " for instructions or ask on #postgresql on irc.freenode.net</li>\n";
298304 dieout("</ul>");
299305 }
300306 print "OK</li>\n";
301 - print "<li>Ensuring that user \"$wgDBuser\" has select rights on the tsearch2 tables...";
 307+ print "<li>Ensuring that user \"" . htmlspecialchars( $wgDBuser ) .
 308+ "\" has select rights on the tsearch2 tables...";
302309 foreach (array('cfg','cfgmap','dict','parser') as $table) {
303310 $SQL = "GRANT SELECT ON pg_ts_$table TO $safeuser";
304311 $this->doQuery($SQL);
@@ -309,7 +316,7 @@
310317 $result = $this->schemaExists($wgDBmwschema);
311318 $safeschema = $this->quote_ident($wgDBmwschema);
312319 if (!$result) {
313 - print "<li>Creating schema <b>$wgDBmwschema</b> ...";
 320+ print "<li>Creating schema <b>" . htmlspecialchars( $wgDBmwschema ) . "</b> ...";
314321 $result = $this->doQuery("CREATE SCHEMA $safeschema AUTHORIZATION $safeuser");
315322 if (!$result) {
316323 print "<b>FAILED</b>.</li>\n";
@@ -355,7 +362,7 @@
356363
357364 if ($this->numeric_version < 8.3) {
358365 // Do we have the basic tsearch2 table?
359 - print "<li>Checking for tsearch2 in the schema \"$wgDBts2schema\"...";
 366+ print "<li>Checking for tsearch2 in the schema \"" . htmlspecialchars( $wgDBts2schema ) . "\"...";
360367 if (! $this->tableExists("pg_ts_dict", $wgDBts2schema)) {
361368 print "<b>FAILED</b>. Make sure tsearch2 is installed. See <a href=";
362369 print "'http://www.devx.com/opensource/Article/21674/0/page/2'>this article</a>";
@@ -375,12 +382,13 @@
376383 $SQL = "SELECT count(*) FROM $safetsschema.pg_ts_$tname";
377384 $res = $this->doQuery($SQL);
378385 if (!$res) {
379 - print "<b>FAILED</b> to access pg_ts_$tname. Make sure that the user ".
380 - "\"$wgDBuser\" has SELECT access to all four tsearch2 tables</li>\n";
 386+ print "<b>FAILED</b> to access " . htmlspecialchars( "pg_ts_$tname" ) .
 387+ ". Make sure that the user \"". htmlspecialchars( $wgDBuser ) .
 388+ "\" has SELECT access to all four tsearch2 tables</li>\n";
381389 dieout("</ul>");
382390 }
383391 }
384 - $SQL = "SELECT ts_name FROM $safetsschema.pg_ts_cfg WHERE locale = '$ctype'";
 392+ $SQL = "SELECT ts_name FROM $safetsschema.pg_ts_cfg WHERE locale = " . $this->addQuotes( $ctype ) ;
385393 $SQL .= " ORDER BY CASE WHEN ts_name <> 'default' THEN 1 ELSE 0 END";
386394 $res = $this->doQuery($SQL);
387395 error_reporting( E_ALL );
@@ -391,28 +399,30 @@
392400 print "OK</li>";
393401
394402 // Will the current locale work? Can we force it to?
395 - print "<li>Verifying tsearch2 locale with $ctype...";
 403+ print "<li>Verifying tsearch2 locale with " . htmlspecialchars( $ctype ) . "...";
396404 $rows = $this->numRows($res);
397405 $resetlocale = 0;
398406 if (!$rows) {
399407 print "<b>not found</b></li>\n";
400 - print "<li>Attempting to set default tsearch2 locale to \"$ctype\"...";
 408+ print "<li>Attempting to set default tsearch2 locale to \"" . htmlspecialchars( $ctype ) . "\"...";
401409 $resetlocale = 1;
402410 }
403411 else {
404412 $tsname = pg_fetch_result($res, 0, 0);
405413 if ($tsname != 'default') {
406 - print "<b>not set to default ($tsname)</b>";
407 - print "<li>Attempting to change tsearch2 default locale to \"$ctype\"...";
 414+ print "<b>not set to default (" . htmlspecialchars( $tsname ) . ")</b>";
 415+ print "<li>Attempting to change tsearch2 default locale to \"" .
 416+ htmlspecialchars( $ctype ) . "\"...";
408417 $resetlocale = 1;
409418 }
410419 }
411420 if ($resetlocale) {
412 - $SQL = "UPDATE $safetsschema.pg_ts_cfg SET locale = '$ctype' WHERE ts_name = 'default'";
 421+ $SQL = "UPDATE $safetsschema.pg_ts_cfg SET locale = " . $this->addQuotes( $ctype ) . " WHERE ts_name = 'default'";
413422 $res = $this->doQuery($SQL);
414423 if (!$res) {
415424 print "<b>FAILED</b>. ";
416 - print "Please make sure that the locale in pg_ts_cfg for \"default\" is set to \"$ctype\"</li>\n";
 425+ print "Please make sure that the locale in pg_ts_cfg for \"default\" is set to \"" .
 426+ htmlspecialchars( $ctype ) . "\"</li>\n";
417427 dieout("</ul>");
418428 }
419429 print "OK</li>";
@@ -422,7 +432,7 @@
423433 $SQL = "SELECT $safetsschema.to_tsvector('default','MediaWiki tsearch2 testing')";
424434 $res = $this->doQuery($SQL);
425435 if (!$res) {
426 - print "<b>FAILED</b>. Specifically, \"$SQL\" did not work.</li>";
 436+ print "<b>FAILED</b>. Specifically, \"" . htmlspecialchars( $SQL ) . "\" did not work.</li>";
427437 dieout("</ul>");
428438 }
429439 print "OK</li>";
@@ -434,28 +444,32 @@
435445 // Does the schema already exist? Who owns it?
436446 $result = $this->schemaExists($wgDBmwschema);
437447 if (!$result) {
438 - print "<li>Creating schema <b>$wgDBmwschema</b> ...";
 448+ print "<li>Creating schema <b>" . htmlspecialchars( $wgDBmwschema ) . "</b> ...";
439449 error_reporting( 0 );
440450 $safeschema = $this->quote_ident($wgDBmwschema);
441451 $result = $this->doQuery("CREATE SCHEMA $safeschema");
442452 error_reporting( E_ALL );
443453 if (!$result) {
444 - print "<b>FAILED</b>. The user \"$wgDBuser\" must be able to access the schema. ".
 454+ print "<b>FAILED</b>. The user \"" . htmlspecialchars( $wgDBuser ) .
 455+ "\" must be able to access the schema. ".
445456 "You can try making them the owner of the database, or try creating the schema with a ".
446 - "different user, and then grant access to the \"$wgDBuser\" user.</li>\n";
 457+ "different user, and then grant access to the \"" .
 458+ htmlspecialchars( $wgDBuser ) . "\" user.</li>\n";
447459 dieout("</ul>");
448460 }
449461 print "OK</li>\n";
450462 }
451463 else if ($result != $wgDBuser) {
452 - print "<li>Schema \"$wgDBmwschema\" exists but is not owned by \"$wgDBuser\". Not ideal.</li>\n";
 464+ print "<li>Schema \"" . htmlspecialchars( $wgDBmwschema ) . "\" exists but is not owned by \"" .
 465+ htmlspecialchars( $wgDBuser ) . "\". Not ideal.</li>\n";
453466 }
454467 else {
455 - print "<li>Schema \"$wgDBmwschema\" exists and is owned by \"$wgDBuser\". Excellent.</li>\n";
 468+ print "<li>Schema \"" . htmlspecialchars( $wgDBmwschema ) . "\" exists and is owned by \"" .
 469+ htmlspecialchars( $wgDBuser ) . "\". Excellent.</li>\n";
456470 }
457471
458472 // Always return GMT time to accomodate the existing integer-based timestamp assumption
459 - print "<li>Setting the timezone to GMT for user \"$wgDBuser\" ...";
 473+ print "<li>Setting the timezone to GMT for user \"" . htmlspecialchars( $wgDBuser ) . "\" ...";
460474 $SQL = "ALTER USER $safeuser SET timezone = 'GMT'";
461475 $result = pg_query($this->mConn, $SQL);
462476 if (!$result) {
@@ -471,7 +485,7 @@
472486 dieout("</ul>");
473487 }
474488
475 - print "<li>Setting the datestyle to ISO, YMD for user \"$wgDBuser\" ...";
 489+ print "<li>Setting the datestyle to ISO, YMD for user \"" . htmlspecialchars( $wgDBuser ) . "\" ...";
476490 $SQL = "ALTER USER $safeuser SET datestyle = 'ISO, YMD'";
477491 $result = pg_query($this->mConn, $SQL);
478492 if (!$result) {
@@ -488,7 +502,7 @@
489503 }
490504
491505 // Fix up the search paths if needed
492 - print "<li>Setting the search path for user \"$wgDBuser\" ...";
 506+ print "<li>Setting the search path for user \"" . htmlspecialchars( $wgDBuser ) . "\" ...";
493507 $path = $this->quote_ident($wgDBmwschema);
494508 if ($wgDBts2schema !== $wgDBmwschema)
495509 $path .= ", ". $this->quote_ident($wgDBts2schema);
@@ -529,12 +543,14 @@
530544 $result = $this->doQuery("CREATE LANGUAGE plpgsql");
531545 error_reporting($olde);
532546 if (!$result) {
533 - print "<b>FAILED</b>. You need to install the language plpgsql in the database <tt>$wgDBname</tt></li>";
 547+ print "<b>FAILED</b>. You need to install the language plpgsql in the database <tt>" .
 548+ htmlspecialchars( $wgDBname ) . "</tt></li>";
534549 dieout("</ul>");
535550 }
536551 }
537552 else {
538 - print "<b>FAILED</b>. You need to install the language plpgsql in the database <tt>$wgDBname</tt></li>";
 553+ print "<b>FAILED</b>. You need to install the language plpgsql in the database <tt>" .
 554+ htmlspecialchars( $wgDBname ) . "</tt></li>";
539555 dieout("</ul>");
540556 }
541557 }
@@ -1227,7 +1243,8 @@
12281244 $res = $this->doQuery($SQL);
12291245 error_reporting( $olde );
12301246 if (!$res) {
1231 - print "<b>FAILED</b>. Make sure that the user \"$wgDBuser\" can write to the schema \"$wgDBmwschema\"</li>\n";
 1247+ print "<b>FAILED</b>. Make sure that the user \"" . htmlspecialchars( $wgDBuser ) .
 1248+ "\" can write to the schema \"" . htmlspecialchars( $wgDBmwschema ) . "\"</li>\n";
12321249 dieout("</ul>");
12331250 }
12341251 $this->doQuery("DROP TABLE $safeschema.$ctest");
@@ -1242,11 +1259,11 @@
12431260 $tss = $this->addQuotes($wgDBts2schema);
12441261 $pgp = $this->addQuotes($wgDBport);
12451262 $dbn = $this->addQuotes($this->mDBname);
1246 - $ctype = pg_fetch_result($this->doQuery("SHOW lc_ctype"),0,0);
 1263+ $ctype = $this->addQuotes( pg_fetch_result($this->doQuery("SHOW lc_ctype"),0,0) );
12471264
12481265 $SQL = "UPDATE mediawiki_version SET mw_version=$mwv, pg_version=$pgv, pg_user=$pgu, ".
12491266 "mw_schema = $mws, ts2_schema = $tss, pg_port=$pgp, pg_dbname=$dbn, ".
1250 - "ctype = '$ctype' ".
 1267+ "ctype = $ctype ".
12511268 "WHERE type = 'Creation'";
12521269 $this->query($SQL);
12531270
Index: branches/REL1_14/phase3/config/index.php
@@ -86,7 +86,8 @@
8787 <html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en" lang="en" dir="ltr">
8888 <head>
8989 <meta http-equiv="Content-type" content="text/html; charset=utf-8" />
90 - <title>MediaWiki <?php echo( $wgVersion ); ?> Installation</title>
 90+ <meta name="robots" content="noindex,nofollow"/>
 91+ <title>MediaWiki <?php echo htmlspecialchars( $wgVersion ); ?> Installation</title>
9192 <style type="text/css">
9293
9394 @import "../skins/monobook/main.css";
@@ -204,7 +205,7 @@
205206 <div id="content">
206207 <div id="bodyContent">
207208
208 -<h1>MediaWiki <?php print $wgVersion ?> Installation</h1>
 209+<h1>MediaWiki <?php print htmlspecialchars( $wgVersion ) ?> Installation</h1>
209210
210211 <?php
211212 $mainListOpened = false; # Is the main list (environement checking) opend ? Used by dieout
@@ -304,7 +305,7 @@
305306 install_version_checks();
306307 $self = 'Installer'; # Maintenance script name, to please Setup.php
307308
308 -print "<li>PHP " . phpversion() . " installed</li>\n";
 309+print "<li>PHP " . htmlspecialchars( phpversion() ) . " installed</li>\n";
309310
310311 error_reporting( 0 );
311312 $phpdatabases = array();
@@ -404,7 +405,7 @@
405406 $conf->safeMode = false;
406407 }
407408
408 -$sapi = php_sapi_name();
 409+$sapi = htmlspecialchars( php_sapi_name() );
409410 print "<li>PHP server API is $sapi; ";
410411 $script = defined('MW_INSTALL_PHP5_EXT') ? 'index.php5' : 'index.php';
411412 if( $wgUsePathInfo ) {
@@ -587,6 +588,9 @@
588589 : $_SERVER["SERVER_ADMIN"];
589590 $conf->EmergencyContact = importPost( "EmergencyContact", $defaultEmail );
590591 $conf->DBtype = importPost( "DBtype", $DefaultDBtype );
 592+ if ( !isset( $ourdb[$conf->DBtype] ) ) {
 593+ $conf->DBtype = $DefaultDBtype;
 594+ }
591595
592596 $conf->DBserver = importPost( "DBserver", "localhost" );
593597 $conf->DBname = importPost( "DBname", "wikidb" );
@@ -769,7 +773,7 @@
770774 $errs["DBtype"] = "Unknown database type '$conf->DBtype'";
771775 continue;
772776 }
773 - print "<li>Database type: {$conf->DBtypename}</li>\n";
 777+ print "<li>Database type: " . htmlspecialchars( $conf->DBtypename ) . "</li>\n";
774778 $dbclass = 'Database'.ucfirst($conf->DBtype);
775779 $wgDBtype = $conf->DBtype;
776780 $wgDBadminuser = "root";
@@ -797,7 +801,7 @@
798802
799803 $wgTitle = Title::newFromText( "Installation script" );
800804 error_reporting( E_ALL );
801 - print "<li>Loading class: $dbclass</li>\n";
 805+ print "<li>Loading class: " . htmlspecialchars( $dbclass ) . "</li>\n";
802806 $dbc = new $dbclass;
803807
804808 if( $conf->DBtype == 'mysql' ) {
@@ -821,7 +825,7 @@
822826 }
823827
824828 # Attempt to connect
825 - echo( "<li>Attempting to connect to database server as $db_user..." );
 829+ echo( "<li>Attempting to connect to database server as " . htmlspecialchars( $db_user ) . "..." );
826830 $wgDatabase = Database::newFromParams( $wgDBserver, $db_user, $db_pass, '', 1 );
827831
828832 # Check the connection and respond to errors
@@ -856,7 +860,7 @@
857861 case 2003:
858862 default:
859863 # General connection problem
860 - echo( "failed with error [$errno] $errtx.</li>\n" );
 864+ echo( htmlspecialchars( "failed with error [$errno] $errtx." ) . "</li>\n" );
861865 $errs["DBserver"] = "Connection failed";
862866 break;
863867 } # switch
@@ -870,10 +874,11 @@
871875 ## Possible connect as a superuser
872876 if( $useRoot && $conf->DBtype != 'sqlite' ) {
873877 $wgDBsuperuser = $conf->RootUser;
874 - echo( "<li>Attempting to connect to database \"postgres\" as superuser \"$wgDBsuperuser\"..." );
 878+ echo( "<li>Attempting to connect to database \"postgres\" as superuser \"" .
 879+ htmlspecialchars( $wgDBsuperuser ) . "\"..." );
875880 $wgDatabase = $dbc->newFromParams($wgDBserver, $wgDBsuperuser, $conf->RootPW, "postgres", 1);
876881 if (!$wgDatabase->isOpen()) {
877 - print " error: " . $wgDatabase->lastError() . "</li>\n";
 882+ print " error: " . htmlspecialchars( $wgDatabase->lastError() ) . "</li>\n";
878883 $errs["DBserver"] = "Could not connect to database as superuser";
879884 $errs["RootUser"] = "Check username";
880885 $errs["RootPW"] = "and password";
@@ -881,10 +886,11 @@
882887 }
883888 $wgDatabase->initial_setup($conf->RootPW, 'postgres');
884889 }
885 - echo( "<li>Attempting to connect to database \"$wgDBname\" as \"$wgDBuser\"..." );
 890+ echo( "<li>Attempting to connect to database \"" . htmlspecialchars( $wgDBname ) .
 891+ "\" as \"" . htmlspecialchars( $wgDBuser ) . "\"..." );
886892 $wgDatabase = $dbc->newFromParams($wgDBserver, $wgDBuser, $wgDBpassword, $wgDBname, 1);
887893 if (!$wgDatabase->isOpen()) {
888 - print " error: " . $wgDatabase->lastError() . "</li>\n";
 894+ print " error: " . htmlspecialchars( $wgDatabase->lastError() ) . "</li>\n";
889895 } else {
890896 $myver = $wgDatabase->getServerVersion();
891897 }
@@ -896,7 +902,7 @@
897903 continue;
898904 }
899905
900 - print "<li>Connected to {$conf->DBtype} $myver";
 906+ print "<li>Connected to " . htmlspecialchars( "{$conf->DBtype} $myver" );
901907 if ($conf->DBtype == 'mysql') {
902908 if( version_compare( $myver, "4.0.14" ) < 0 ) {
903909 print "</li>\n";
@@ -983,15 +989,19 @@
984990 }
985991 }
986992 if ( $existingSchema && $existingSchema != $conf->DBschema ) {
987 - print "<li><strong>Warning:</strong> you requested the {$conf->DBschema} schema, " .
988 - "but the existing database has the $existingSchema schema. This upgrade script ".
989 - "can't convert it, so it will remain $existingSchema.</li>\n";
 993+ $encExisting = htmlspecialchars( $existingSchema );
 994+ $encRequested = htmlspecialchars( $conf->DBschema );
 995+ print "<li><strong>Warning:</strong> you requested the $encRequested schema, " .
 996+ "but the existing database has the $encExisting schema. This upgrade script ".
 997+ "can't convert it, so it will remain $encExisting.</li>\n";
990998 $conf->setSchema( $existingSchema, $conf->DBengine );
991999 }
9921000 if ( $existingEngine && $existingEngine != $conf->DBengine ) {
993 - print "<li><strong>Warning:</strong> you requested the {$conf->DBengine} storage " .
994 - "engine, but the existing database uses the $existingEngine engine. This upgrade " .
995 - "script can't convert it, so it will remain $existingEngine.</li>\n";
 1001+ $encExisting = htmlspecialchars( $existingEngine );
 1002+ $encRequested = htmlspecialchars( $conf->DBengine );
 1003+ print "<li><strong>Warning:</strong> you requested the $encRequested storage " .
 1004+ "engine, but the existing database uses the $encExisting engine. This upgrade " .
 1005+ "script can't convert it, so it will remain $encExisting.</li>\n";
9961006 $conf->setSchema( $conf->DBschema, $existingEngine );
9971007 }
9981008 }
@@ -1032,7 +1042,8 @@
10331043 }
10341044 $wgDatabase->freeResult( $res );
10351045 if ( !$found && $conf->DBengine != 'MyISAM' ) {
1036 - echo "<li><strong>Warning:</strong> {$conf->DBengine} storage engine not available, " .
 1046+ echo "<li><strong>Warning:</strong> " . htmlspecialchars( $conf->DBengine ) .
 1047+ " storage engine not available, " .
10371048 "using MyISAM instead</li>\n";
10381049 $conf->setSchema( $conf->DBschema, 'MyISAM' );
10391050 }
@@ -1071,10 +1082,10 @@
10721083 if( $wgDatabase2->isOpen() ) {
10731084 # Nope, just close the test connection and continue
10741085 $wgDatabase2->close();
1075 - echo( "<li>User $wgDBuser exists. Skipping grants.</li>\n" );
 1086+ echo( "<li>User " . htmlspecialchars( $wgDBuser ) . " exists. Skipping grants.</li>\n" );
10761087 } else {
10771088 # Yes, so run the grants
1078 - echo( "<li>Granting user permissions to $wgDBuser on $wgDBname..." );
 1089+ echo( "<li>" . htmlspecialchars( "Granting user permissions to $wgDBuser on $wgDBname..." ) );
10791090 dbsource( "../maintenance/users.sql", $wgDatabase );
10801091 echo( "success.</li>\n" );
10811092 }
@@ -1177,7 +1188,9 @@
11781189 $list = getLanguageList();
11791190 foreach( $list as $code => $name ) {
11801191 $sel = ($code == $conf->LanguageCode) ? 'selected="selected"' : '';
1181 - echo "\n\t\t<option value=\"$code\" $sel>$name</option>";
 1192+ $encCode = htmlspecialchars( $code );
 1193+ $encName = htmlspecialchars( $name );
 1194+ echo "\n\t\t<option value=\"$encCode\" $sel>$encName</option>";
11821195 }
11831196 echo "\n";
11841197 ?>
@@ -1344,7 +1357,11 @@
13451358 <div class="config-section">
13461359 <div class="config-input">
13471360 <label class='column'>Database type:</label>
1348 -<?php if (isset($errs['DBpicktype'])) print "\t<span class='error'>$errs[DBpicktype]</span>\n"; ?>
 1361+<?php
 1362+ if (isset($errs['DBpicktype'])) {
 1363+ print "\t<span class='error'>" . htmlspecialchars( $errs[DBpicktype] ) . "</span>\n";
 1364+ }
 1365+?>
13491366 <ul class='plain'><?php
13501367 database_picker($conf);
13511368 ?></ul>
@@ -1478,7 +1495,7 @@
14791496 </div>
14801497 </form>
14811498 <script type="text/javascript">
1482 -window.onload = toggleDBarea('<?php echo $conf->DBtype; ?>',
 1499+window.onload = toggleDBarea('<?php echo Xml::encodeJsVar( $conf->DBtype ); ?>',
14831500 <?php
14841501 ## If they passed in a root user name, don't populate it on page load
14851502 echo strlen(importPost('RootUser', '')) ? 0 : 1;
@@ -1804,10 +1821,8 @@
18051822 return importVar( $_REQUEST, $name, $default );
18061823 }
18071824
1808 -$radioCount = 0;
1809 -
18101825 function aField( &$conf, $field, $text, $type = "text", $value = "", $onclick = '' ) {
1811 - global $radioCount;
 1826+ static $radioCount = 0;
18121827 if( $type != "" ) {
18131828 $xtype = "type=\"$type\"";
18141829 } else {
@@ -1847,7 +1862,9 @@
18481863 }
18491864
18501865 global $errs;
1851 - if(isset($errs[$field])) echo "<span class='error'>" . $errs[$field] . "</span>\n";
 1866+ if(isset($errs[$field])) {
 1867+ echo "<span class='error'>" . htmlspecialchars( $errs[$field] ) . "</span>\n";
 1868+ }
18521869 }
18531870
18541871 function getLanguageList() {
@@ -1940,7 +1957,7 @@
19411958 fclose( $fp );
19421959 }
19431960 if ( !$errstr ) {
1944 - echo "<li>Connected to memcached on $host:$port successfully";
 1961+ echo "<li>Connected to memcached on " . htmlspecialchars( "$host:$port" ) ." successfully</li>";
19451962 }
19461963 return $errstr;
19471964 }

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

Comments

#Comment by Tim Starling (talk | contribs)   04:14, 9 February 2009

What the hell are you doing marking changes to a release branch as "deferred"?

Status & tagging log