r46892 MediaWiki - Code Review archive

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

Diff [purge]

Index: branches/REL1_13/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_13/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_13/phase3/maintenance/updaters.inc
@@ -171,11 +171,11 @@
172172 global $wgDatabase;
173173 if ( $wgDatabase->tableExists( $from ) ) {
174174 if ( $wgDatabase->tableExists( $to ) ) {
175 - echo "...can't move table $from to $to, $to already exists.\n";
 175+ wfOut( "...can't move table $from to $to, $to already exists.\n" );
176176 } else {
177 - echo "Moving table $from to $to...";
 177+ wfOut( "Moving table $from to $to..." );
178178 dbsource( archive($patch), $wgDatabase );
179 - echo "ok\n";
 179+ wfOut( "ok\n" );
180180 }
181181 } else {
182182 // Source table does not exist
@@ -187,47 +187,47 @@
188188 function add_table( $name, $patch, $fullpath=false ) {
189189 global $wgDatabase;
190190 if ( $wgDatabase->tableExists( $name ) ) {
191 - echo "...$name table already exists.\n";
 191+ wfOut( "...$name table already exists.\n" );
192192 } else {
193 - echo "Creating $name table...";
 193+ wfOut( "Creating $name table..." );
194194 if( $fullpath ) {
195195 dbsource( $patch, $wgDatabase );
196196 } else {
197197 dbsource( archive($patch), $wgDatabase );
198198 }
199 - echo "ok\n";
 199+ wfOut( "ok\n" );
200200 }
201201 }
202202
203203 function add_field( $table, $field, $patch, $fullpath=false ) {
204204 global $wgDatabase;
205205 if ( !$wgDatabase->tableExists( $table ) ) {
206 - echo "...$table table does not exist, skipping new field patch\n";
 206+ wfOut( "...$table table does not exist, skipping new field patch\n" );
207207 } elseif ( $wgDatabase->fieldExists( $table, $field ) ) {
208 - echo "...have $field field in $table table.\n";
 208+ wfOut( "...have $field field in $table table.\n" );
209209 } else {
210 - echo "Adding $field field to table $table...";
 210+ wfOut( "Adding $field field to table $table..." );
211211 if( $fullpath ) {
212212 dbsource( $patch, $wgDatabase );
213213 } else {
214214 dbsource( archive($patch), $wgDatabase );
215215 }
216 - echo "ok\n";
 216+ wfOut( "ok\n" );
217217 }
218218 }
219219
220220 function add_index( $table, $index, $patch, $fullpath=false ) {
221221 global $wgDatabase;
222222 if( $wgDatabase->indexExists( $table, $index ) ) {
223 - echo "...$index key already set on $table table.\n";
 223+ wfOut( "...$index key already set on $table table.\n" );
224224 } else {
225 - echo "Adding $index key to table $table... ";
 225+ wfOut( "Adding $index key to table $table... " );
226226 if( $fullpath ) {
227227 dbsource( $patch, $wgDatabase );
228228 } else {
229229 dbsource( archive($patch), $wgDatabase );
230230 }
231 - echo "ok\n";
 231+ wfOut( "ok\n" );
232232 }
233233 }
234234
@@ -243,11 +243,11 @@
244244
245245 global $wgDatabase;
246246 $fname = "Update script: update_passwords()";
247 - print "\nIt appears that you need to update the user passwords in your\n" .
 247+ wfOut( "\nIt appears that you need to update the user passwords in your\n" .
248248 "database. If you have already done this (if you've run this update\n" .
249249 "script once before, for example), doing so again will make all your\n" .
250250 "user accounts inaccessible, so be sure you only do this once.\n" .
251 - "Update user passwords? (yes/no)";
 251+ "Update user passwords? (yes/no)" );
252252
253253 $resp = readconsole();
254254 if ( ! ( "Y" == $resp{0} || "y" == $resp{0} ) ) { return; }
@@ -270,15 +270,15 @@
271271 # Check that interwiki table exists; if it doesn't source it
272272 global $wgDatabase, $IP;
273273 if( $wgDatabase->tableExists( "interwiki" ) ) {
274 - echo "...already have interwiki table\n";
 274+ wfOut( "...already have interwiki table\n" );
275275 return true;
276276 }
277 - echo "Creating interwiki table: ";
 277+ wfOut( "Creating interwiki table: " );
278278 dbsource( archive("patch-interwiki.sql") );
279 - echo "ok\n";
280 - echo "Adding default interwiki definitions: ";
 279+ wfOut( "ok\n" );
 280+ wfOut( "Adding default interwiki definitions: " );
281281 dbsource( "$IP/maintenance/interwiki.sql" );
282 - echo "ok\n";
 282+ wfOut( "ok\n" );
283283 }
284284
285285 function do_index_update() {
@@ -286,12 +286,12 @@
287287 global $wgDatabase;
288288 $meta = $wgDatabase->fieldInfo( "recentchanges", "rc_timestamp" );
289289 if( !$meta->isMultipleKey() ) {
290 - echo "Updating indexes to 20031107: ";
 290+ wfOut( "Updating indexes to 20031107: " );
291291 dbsource( archive("patch-indexes.sql") );
292 - echo "ok\n";
 292+ wfOut( "ok\n" );
293293 return true;
294294 }
295 - echo "...indexes seem up to 20031107 standards\n";
 295+ wfOut( "...indexes seem up to 20031107 standards\n" );
296296 return false;
297297 }
298298
@@ -300,67 +300,67 @@
301301
302302 $meta = $wgDatabase->fieldInfo( "image", "img_major_mime" );
303303 if( !$meta->isMultipleKey() ) {
304 - echo "Updating indexes to 20050912: ";
 304+ wfOut( "Updating indexes to 20050912: " );
305305 dbsource( archive("patch-mimesearch-indexes.sql") );
306 - echo "ok\n";
 306+ wfOut( "ok\n" );
307307 return true;
308308 }
309 - echo "...indexes seem up to 20050912 standards\n";
 309+ wfOut( "...indexes seem up to 20050912 standards\n" );
310310 return false;
311311 }
312312
313313 function do_image_name_unique_update() {
314314 global $wgDatabase;
315315 if( $wgDatabase->indexExists( 'image', 'PRIMARY' ) ) {
316 - echo "...image primary key already set.\n";
 316+ wfOut( "...image primary key already set.\n" );
317317 } else {
318 - echo "Making img_name the primary key... ";
 318+ wfOut( "Making img_name the primary key... " );
319319 dbsource( archive("patch-image_name_primary.sql"), $wgDatabase );
320 - echo "ok\n";
 320+ wfOut( "ok\n" );
321321 }
322322 }
323323
324324 function do_logging_timestamp_index() {
325325 global $wgDatabase;
326326 if( $wgDatabase->indexExists( 'logging', 'times' ) ) {
327 - echo "...timestamp key on logging already exists.\n";
 327+ wfOut( "...timestamp key on logging already exists.\n" );
328328 } else {
329 - echo "Adding timestamp key on logging table... ";
 329+ wfOut( "Adding timestamp key on logging table... " );
330330 dbsource( archive("patch-logging-times-index.sql"), $wgDatabase );
331 - echo "ok\n";
 331+ wfOut( "ok\n" );
332332 }
333333 }
334334
335335 function do_archive_user_index() {
336336 global $wgDatabase;
337337 if( $wgDatabase->indexExists( 'archive', 'usertext_timestamp' ) ) {
338 - echo "...usertext,timestamp key on archive already exists.\n";
 338+ wfOut( "...usertext,timestamp key on archive already exists.\n" );
339339 } else {
340 - echo "Adding usertext,timestamp key on archive table... ";
 340+ wfOut( "Adding usertext,timestamp key on archive table... " );
341341 dbsource( archive("patch-archive-user-index.sql"), $wgDatabase );
342 - echo "ok\n";
 342+ wfOut( "ok\n" );
343343 }
344344 }
345345
346346 function do_image_user_index() {
347347 global $wgDatabase;
348348 if( $wgDatabase->indexExists( 'image', 'img_usertext_timestamp' ) ) {
349 - echo "...usertext,timestamp key on image already exists.\n";
 349+ wfOut( "...usertext,timestamp key on image already exists.\n" );
350350 } else {
351 - echo "Adding usertext,timestamp key on image table... ";
 351+ wfOut( "Adding usertext,timestamp key on image table... " );
352352 dbsource( archive("patch-image-user-index.sql"), $wgDatabase );
353 - echo "ok\n";
 353+ wfOut( "ok\n" );
354354 }
355355 }
356356
357357 function do_oldimage_user_index() {
358358 global $wgDatabase;
359359 if( $wgDatabase->indexExists( 'oldimage', 'oi_usertext_timestamp' ) ) {
360 - echo "...usertext,timestamp key on oldimage already exists.\n";
 360+ wfOut( "...usertext,timestamp key on oldimage already exists.\n" );
361361 } else {
362 - echo "Adding usertext,timestamp key on oldimage table... ";
 362+ wfOut( "Adding usertext,timestamp key on oldimage table... " );
363363 dbsource( archive("patch-oldimage-user-index.sql"), $wgDatabase );
364 - echo "ok\n";
 364+ wfOut( "ok\n" );
365365 }
366366 }
367367
@@ -368,18 +368,18 @@
369369 global $wgDatabase;
370370 $fname = 'do_watchlist_update';
371371 if( $wgDatabase->fieldExists( 'watchlist', 'wl_notificationtimestamp' ) ) {
372 - echo "The watchlist table is already set up for email notification.\n";
 372+ wfOut( "The watchlist table is already set up for email notification.\n" );
373373 } else {
374 - echo "Adding wl_notificationtimestamp field for email notification management.";
 374+ wfOut( "Adding wl_notificationtimestamp field for email notification management." );
375375 /* ALTER TABLE watchlist ADD (wl_notificationtimestamp varchar(14) binary NOT NULL default '0'); */
376376 dbsource( archive( 'patch-email-notification.sql' ), $wgDatabase );
377 - echo "ok\n";
 377+ wfOut( "ok\n" );
378378 }
379379 # Check if we need to add talk page rows to the watchlist
380380 $talk = $wgDatabase->selectField( 'watchlist', 'count(*)', 'wl_namespace & 1', $fname );
381381 $nontalk = $wgDatabase->selectField( 'watchlist', 'count(*)', 'NOT (wl_namespace & 1)', $fname );
382382 if ( $talk != $nontalk ) {
383 - echo "Adding missing watchlist talk page rows... ";
 383+ wfOut( "Adding missing watchlist talk page rows... " );
384384 flush();
385385
386386 $wgDatabase->insertSelect( 'watchlist', 'watchlist',
@@ -389,9 +389,9 @@
390390 'wl_title' => 'wl_title',
391391 'wl_notificationtimestamp' => 'wl_notificationtimestamp'
392392 ), array( 'NOT (wl_namespace & 1)' ), $fname, 'IGNORE' );
393 - echo "ok\n";
 393+ wfOut( "ok\n" );
394394 } else {
395 - echo "...watchlist talk page rows already present\n";
 395+ wfOut( "...watchlist talk page rows already present\n" );
396396 }
397397 }
398398
@@ -402,7 +402,7 @@
403403 $res = $wgDatabase->safeQuery( 'SELECT user_id, user_ip FROM !',
404404 $wgDatabase->tableName( 'user_newtalk' ) );
405405 $num_newtalks=$wgDatabase->numRows($res);
406 - echo "Now converting ".$num_newtalks." user_newtalk entries to watchlist table entries ... \n";
 406+ wfOut( "Now converting $num_newtalks user_newtalk entries to watchlist table entries ... \n" );
407407
408408 $user = new User();
409409 for ( $i = 1; $i <= $num_newtalks; $i++ ) {
@@ -430,18 +430,18 @@
431431 );
432432 }
433433 }
434 - echo "Done.\n";
 434+ wfOut( "Done.\n" );
435435 }
436436
437437
438438 function do_user_update() {
439439 global $wgDatabase;
440440 if( $wgDatabase->fieldExists( 'user', 'user_emailauthenticationtimestamp' ) ) {
441 - echo "User table contains old email authentication field. Dropping... ";
 441+ wfOut( "User table contains old email authentication field. Dropping... " );
442442 dbsource( archive( 'patch-email-authentication.sql' ), $wgDatabase );
443 - echo "ok\n";
 443+ wfOut( "ok\n" );
444444 } else {
445 - echo "...user table does not contain old email authentication field.\n";
 445+ wfOut( "...user table does not contain old email authentication field.\n" );
446446 }
447447 }
448448
@@ -459,11 +459,11 @@
460460 $wgDatabase->freeResult( $res );
461461
462462 if( in_array( 'binary', $flags ) ) {
463 - echo "$table table has correct $field encoding.\n";
 463+ wfOut( "$table table has correct $field encoding.\n" );
464464 } else {
465 - echo "Fixing $field encoding on $table table... ";
 465+ wfOut( "Fixing $field encoding on $table table... " );
466466 dbsource( archive( $patchFile ), $wgDatabase );
467 - echo "ok\n";
 467+ wfOut( "ok\n" );
468468 }
469469 }
470470
@@ -471,11 +471,11 @@
472472 global $wgDatabase;
473473 $fname="do_schema_restructuring";
474474 if ( $wgDatabase->tableExists( 'page' ) ) {
475 - echo "...page table already exists.\n";
 475+ wfOut( "...page table already exists.\n" );
476476 } else {
477 - echo "...converting from cur/old to page/revision/text DB structure.\n"; flush();
478 - echo wfTimestamp( TS_DB );
479 - echo "......checking for duplicate entries.\n"; flush();
 477+ wfOut( "...converting from cur/old to page/revision/text DB structure.\n" );
 478+ wfOut( wfTimestamp( TS_DB ) );
 479+ wfOut( "......checking for duplicate entries.\n" );
480480
481481 list ($cur, $old, $page, $revision, $text) = $wgDatabase->tableNamesN( 'cur', 'old', 'page', 'revision', 'text' );
482482
@@ -483,15 +483,15 @@
484484 FROM $cur GROUP BY cur_title, cur_namespace HAVING c>1", $fname );
485485
486486 if ( $wgDatabase->numRows( $rows ) > 0 ) {
487 - echo wfTimestamp( TS_DB );
488 - echo "......<b>Found duplicate entries</b>\n";
489 - echo ( sprintf( "<b> %-60s %3s %5s</b>\n", 'Title', 'NS', 'Count' ) );
 487+ wfOut( wfTimestamp( TS_DB ) );
 488+ wfOut( "......<b>Found duplicate entries</b>\n" );
 489+ wfOut( sprintf( "<b> %-60s %3s %5s</b>\n", 'Title', 'NS', 'Count' ) );
490490 while ( $row = $wgDatabase->fetchObject( $rows ) ) {
491491 if ( ! isset( $duplicate[$row->cur_namespace] ) ) {
492492 $duplicate[$row->cur_namespace] = array();
493493 }
494494 $duplicate[$row->cur_namespace][] = $row->cur_title;
495 - echo ( sprintf( " %-60s %3s %5s\n", $row->cur_title, $row->cur_namespace, $row->c ) );
 495+ wfOut( sprintf( " %-60s %3s %5s\n", $row->cur_title, $row->cur_namespace, $row->c ) );
496496 }
497497 $sql = "SELECT cur_title, cur_namespace, cur_id, cur_timestamp FROM $cur WHERE ";
498498 $firstCond = true;
@@ -531,13 +531,13 @@
532532 }
533533 $sql = "DELETE FROM $cur WHERE cur_id IN ( " . join( ',', $deleteId ) . ')';
534534 $rows = $wgDatabase->query( $sql, $fname );
535 - echo wfTimestamp( TS_DB );
536 - echo "......<b>Deleted</b> ".$wgDatabase->affectedRows()." records.\n";
 535+ wfOut( wfTimestamp( TS_DB ) );
 536+ wfOut( "......<b>Deleted</b> ".$wgDatabase->affectedRows()." records.\n" );
537537 }
538538
539539
540 - echo wfTimestamp( TS_DB );
541 - echo "......Creating tables.\n";
 540+ wfOut( wfTimestamp( TS_DB ) );
 541+ wfOut( "......Creating tables.\n" );
542542 $wgDatabase->query("CREATE TABLE $page (
543543 page_id int(8) unsigned NOT NULL auto_increment,
544544 page_namespace int NOT NULL,
@@ -575,26 +575,26 @@
576576 INDEX usertext_timestamp (rev_user_text,rev_timestamp)
577577 ) ENGINE=InnoDB", $fname );
578578
579 - echo wfTimestamp( TS_DB );
580 - echo "......Locking tables.\n";
 579+ wfOut( wfTimestamp( TS_DB ) );
 580+ wfOut( "......Locking tables.\n" );
581581 $wgDatabase->query( "LOCK TABLES $page WRITE, $revision WRITE, $old WRITE, $cur WRITE", $fname );
582582
583583 $maxold = intval( $wgDatabase->selectField( 'old', 'max(old_id)', '', $fname ) );
584 - echo wfTimestamp( TS_DB );
585 - echo "......maxold is {$maxold}\n";
 584+ wfOut( wfTimestamp( TS_DB ) );
 585+ wfOut( "......maxold is {$maxold}\n" );
586586
587 - echo wfTimestamp( TS_DB );
 587+ wfOut( wfTimestamp( TS_DB ) );
588588 global $wgLegacySchemaConversion;
589589 if( $wgLegacySchemaConversion ) {
590590 // Create HistoryBlobCurStub entries.
591591 // Text will be pulled from the leftover 'cur' table at runtime.
592 - echo "......Moving metadata from cur; using blob references to text in cur table.\n";
 592+ wfOut( "......Moving metadata from cur; using blob references to text in cur table.\n" );
593593 $cur_text = "concat('O:18:\"historyblobcurstub\":1:{s:6:\"mCurId\";i:',cur_id,';}')";
594594 $cur_flags = "'object'";
595595 } else {
596596 // Copy all cur text in immediately: this may take longer but avoids
597597 // having to keep an extra table around.
598 - echo "......Moving text from cur.\n";
 598+ wfOut( "......Moving text from cur.\n" );
599599 $cur_text = 'cur_text';
600600 $cur_flags = "''";
601601 }
@@ -603,16 +603,16 @@
604604 SELECT cur_namespace, cur_title, $cur_text, cur_comment, cur_user, cur_user_text, cur_timestamp, cur_minor_edit, $cur_flags
605605 FROM $cur", $fname );
606606
607 - echo wfTimestamp( TS_DB );
608 - echo "......Setting up revision table.\n";
 607+ wfOut( wfTimestamp( TS_DB ) );
 608+ wfOut( "......Setting up revision table.\n" );
609609 $wgDatabase->query( "INSERT INTO $revision (rev_id, rev_page, rev_comment, rev_user, rev_user_text, rev_timestamp,
610610 rev_minor_edit)
611611 SELECT old_id, cur_id, old_comment, old_user, old_user_text,
612612 old_timestamp, old_minor_edit
613613 FROM $old,$cur WHERE old_namespace=cur_namespace AND old_title=cur_title", $fname );
614614
615 - echo wfTimestamp( TS_DB );
616 - echo "......Setting up page table.\n";
 615+ wfOut( wfTimestamp( TS_DB ) );
 616+ wfOut( "......Setting up page table.\n" );
617617 $wgDatabase->query( "INSERT INTO $page (page_id, page_namespace, page_title, page_restrictions, page_counter,
618618 page_is_redirect, page_is_new, page_random, page_touched, page_latest, page_len)
619619 SELECT cur_id, cur_namespace, cur_title, cur_restrictions, cur_counter, cur_is_redirect, cur_is_new,
@@ -620,38 +620,38 @@
621621 FROM $cur,$revision
622622 WHERE cur_id=rev_page AND rev_timestamp=cur_timestamp AND rev_id > {$maxold}", $fname );
623623
624 - echo wfTimestamp( TS_DB );
625 - echo "......Unlocking tables.\n";
 624+ wfOut( wfTimestamp( TS_DB ) );
 625+ wfOut( "......Unlocking tables.\n" );
626626 $wgDatabase->query( "UNLOCK TABLES", $fname );
627627
628 - echo wfTimestamp( TS_DB );
629 - echo "......Renaming old.\n";
 628+ wfOut( wfTimestamp( TS_DB ) );
 629+ wfOut( "......Renaming old.\n" );
630630 $wgDatabase->query( "ALTER TABLE $old RENAME TO $text", $fname );
631631
632 - echo wfTimestamp( TS_DB );
633 - echo "...done.\n";
 632+ wfOut( wfTimestamp( TS_DB ) );
 633+ wfOut( "...done.\n" );
634634 }
635635 }
636636
637637 function do_inverse_timestamp() {
638638 global $wgDatabase;
639639 if( $wgDatabase->fieldExists( 'revision', 'inverse_timestamp' ) ) {
640 - echo "Removing revision.inverse_timestamp and fixing indexes... ";
 640+ wfOut( "Removing revision.inverse_timestamp and fixing indexes... " );
641641 dbsource( archive( 'patch-inverse_timestamp.sql' ), $wgDatabase );
642 - echo "ok\n";
 642+ wfOut( "ok\n" );
643643 } else {
644 - echo "revision timestamp indexes already up to 2005-03-13\n";
 644+ wfOut( "revision timestamp indexes already up to 2005-03-13\n" );
645645 }
646646 }
647647
648648 function do_text_id() {
649649 global $wgDatabase;
650650 if( $wgDatabase->fieldExists( 'revision', 'rev_text_id' ) ) {
651 - echo "...rev_text_id already in place.\n";
 651+ wfOut( "...rev_text_id already in place.\n" );
652652 } else {
653 - echo "Adding rev_text_id field... ";
 653+ wfOut( "Adding rev_text_id field... " );
654654 dbsource( archive( 'patch-rev_text_id.sql' ), $wgDatabase );
655 - echo "ok\n";
 655+ wfOut( "ok\n" );
656656 }
657657 }
658658
@@ -682,25 +682,25 @@
683683 $wgDatabase->freeResult( $result );
684684
685685 if( substr( $info->Type, 0, 3 ) == 'int' ) {
686 - echo "...$field is already a full int ($info->Type).\n";
 686+ wfOut( "...$field is already a full int ($info->Type).\n" );
687687 } else {
688 - echo "Promoting $field from $info->Type to int... ";
 688+ wfOut( "Promoting $field from $info->Type to int... " );
689689
690690 $sql = "ALTER TABLE $tablename MODIFY $field int NOT NULL";
691691 $wgDatabase->query( $sql );
692692
693 - echo "ok\n";
 693+ wfOut( "ok\n" );
694694 }
695695 }
696696
697697 function do_pagelinks_update() {
698698 global $wgDatabase;
699699 if( $wgDatabase->tableExists( 'pagelinks' ) ) {
700 - echo "...already have pagelinks table.\n";
 700+ wfOut( "...already have pagelinks table.\n" );
701701 } else {
702 - echo "Converting links and brokenlinks tables to pagelinks... ";
 702+ wfOut( "Converting links and brokenlinks tables to pagelinks... " );
703703 dbsource( archive( 'patch-pagelinks.sql' ), $wgDatabase );
704 - echo "ok\n";
 704+ wfOut( "ok\n" );
705705 flush();
706706
707707 global $wgCanonicalNamespaceNames;
@@ -716,7 +716,7 @@
717717 global $wgDatabase, $wgContLang;
718718
719719 $ns = intval( $namespace );
720 - echo "Cleaning up broken links for namespace $ns... ";
 720+ wfOut( "Cleaning up broken links for namespace $ns... " );
721721
722722 $pagelinks = $wgDatabase->tableName( 'pagelinks' );
723723 $name = $wgContLang->getNsText( $ns );
@@ -730,25 +730,25 @@
731731 AND pl_title LIKE '$likeprefix:%'";
732732
733733 $wgDatabase->query( $sql, 'do_pagelinks_namespace' );
734 - echo "ok\n";
 734+ wfOut( "ok\n" );
735735 }
736736
737737 function do_drop_img_type() {
738738 global $wgDatabase;
739739
740740 if( $wgDatabase->fieldExists( 'image', 'img_type' ) ) {
741 - echo "Dropping unused img_type field in image table... ";
 741+ wfOut( "Dropping unused img_type field in image table... " );
742742 dbsource( archive( 'patch-drop_img_type.sql' ), $wgDatabase );
743 - echo "ok\n";
 743+ wfOut( "ok\n" );
744744 } else {
745 - echo "No img_type field in image table; Good.\n";
 745+ wfOut( "No img_type field in image table; Good.\n" );
746746 }
747747 }
748748
749749 function do_old_links_update() {
750750 global $wgDatabase;
751751 if( $wgDatabase->tableExists( 'pagelinks' ) ) {
752 - echo "Already have pagelinks; skipping old links table updates.\n";
 752+ wfOut( "Already have pagelinks; skipping old links table updates.\n" );
753753 } else {
754754 convertLinks(); flush();
755755 }
@@ -758,14 +758,14 @@
759759 global $wgDatabase;
760760 $duper = new UserDupes( $wgDatabase );
761761 if( $duper->hasUniqueIndex() ) {
762 - echo "Already have unique user_name index.\n";
 762+ wfOut( "Already have unique user_name index.\n" );
763763 } else {
764764 if( !$duper->clearDupes() ) {
765 - echo "WARNING: This next step will probably fail due to unfixed duplicates...\n";
 765+ wfOut( "WARNING: This next step will probably fail due to unfixed duplicates...\n" );
766766 }
767 - echo "Adding unique index on user_name... ";
 767+ wfOut( "Adding unique index on user_name... " );
768768 dbsource( archive( 'patch-user_nameindex.sql' ), $wgDatabase );
769 - echo "ok\n";
 769+ wfOut( "ok\n" );
770770 }
771771 }
772772
@@ -774,28 +774,28 @@
775775 global $wgDatabase;
776776
777777 if( $wgDatabase->tableExists( 'user_groups' ) ) {
778 - echo "...user_groups table already exists.\n";
 778+ wfOut( "...user_groups table already exists.\n" );
779779 return do_user_groups_reformat();
780780 }
781781
782 - echo "Adding user_groups table... ";
 782+ wfOut( "Adding user_groups table... " );
783783 dbsource( archive( 'patch-user_groups.sql' ), $wgDatabase );
784 - echo "ok\n";
 784+ wfOut( "ok\n" );
785785
786786 if( !$wgDatabase->tableExists( 'user_rights' ) ) {
787787 if( $wgDatabase->fieldExists( 'user', 'user_rights' ) ) {
788 - echo "Upgrading from a 1.3 or older database? Breaking out user_rights for conversion...";
 788+ wfOut( "Upgrading from a 1.3 or older database? Breaking out user_rights for conversion..." );
789789 dbsource( archive( 'patch-user_rights.sql' ), $wgDatabase );
790 - echo "ok\n";
 790+ wfOut( "ok\n" );
791791 } else {
792 - echo "*** WARNING: couldn't locate user_rights table or field for upgrade.\n";
793 - echo "*** You may need to manually configure some sysops by manipulating\n";
794 - echo "*** the user_groups table.\n";
 792+ wfOut( "*** WARNING: couldn't locate user_rights table or field for upgrade.\n" );
 793+ wfOut( "*** You may need to manually configure some sysops by manipulating\n" );
 794+ wfOut( "*** the user_groups table.\n" );
795795 return;
796796 }
797797 }
798798
799 - echo "Converting user_rights table to user_groups... ";
 799+ wfOut( "Converting user_rights table to user_groups... " );
800800 $result = $wgDatabase->select( 'user_rights',
801801 array( 'ur_user', 'ur_rights' ),
802802 array( "ur_rights != ''" ),
@@ -815,7 +815,7 @@
816816 }
817817 }
818818 $wgDatabase->freeResult( $result );
819 - echo "ok\n";
 819+ wfOut( "ok\n" );
820820 }
821821
822822 function do_user_groups_reformat() {
@@ -826,20 +826,20 @@
827827 if( $info->type() == 'int' ) {
828828 $oldug = $wgDatabase->tableName( 'user_groups' );
829829 $newug = $wgDatabase->tableName( 'user_groups_bogus' );
830 - echo "user_groups is in bogus intermediate format. Renaming to $newug... ";
 830+ wfOut( "user_groups is in bogus intermediate format. Renaming to $newug... " );
831831 $wgDatabase->query( "ALTER TABLE $oldug RENAME TO $newug" );
832 - echo "ok\n";
 832+ wfOut( "ok\n" );
833833
834 - echo "Re-adding fresh user_groups table... ";
 834+ wfOut( "Re-adding fresh user_groups table... " );
835835 dbsource( archive( 'patch-user_groups.sql' ), $wgDatabase );
836 - echo "ok\n";
 836+ wfOut( "ok\n" );
837837
838 - echo "***\n";
839 - echo "*** WARNING: You will need to manually fix up user permissions in the user_groups\n";
840 - echo "*** table. Old 1.5 alpha versions did some pretty funky stuff...\n";
841 - echo "***\n";
 838+ wfOut( "***\n" );
 839+ wfOut( "*** WARNING: You will need to manually fix up user permissions in the user_groups\n" );
 840+ wfOut( "*** table. Old 1.5 alpha versions did some pretty funky stuff...\n" );
 841+ wfOut( "***\n" );
842842 } else {
843 - echo "...user_groups is in current format.\n";
 843+ wfOut( "...user_groups is in current format.\n" );
844844 }
845845
846846 }
@@ -851,11 +851,11 @@
852852 $info = $wgDatabase->fieldInfo( 'watchlist', 'wl_notificationtimestamp' );
853853
854854 if( !$info->nullable() ) {
855 - echo "Making wl_notificationtimestamp nullable... ";
 855+ wfOut( "Making wl_notificationtimestamp nullable... " );
856856 dbsource( archive( 'patch-watchlist-null.sql' ), $wgDatabase );
857 - echo "ok\n";
 857+ wfOut( "ok\n" );
858858 } else {
859 - echo "...wl_notificationtimestamp is already nullable.\n";
 859+ wfOut( "...wl_notificationtimestamp is already nullable.\n" );
860860 }
861861
862862 }
@@ -866,13 +866,13 @@
867867 function do_page_random_update() {
868868 global $wgDatabase;
869869
870 - echo "Setting page_random to a random value on rows where it equals 0...";
 870+ wfOut( "Setting page_random to a random value on rows where it equals 0..." );
871871
872872 $page = $wgDatabase->tableName( 'page' );
873873 $wgDatabase->query( "UPDATE $page SET page_random = RAND() WHERE page_random = 0", 'do_page_random_update' );
874874 $rows = $wgDatabase->affectedRows();
875875
876 - echo "changed $rows rows\n";
 876+ wfOut( "changed $rows rows\n" );
877877 }
878878
879879 function do_templatelinks_update() {
@@ -880,12 +880,12 @@
881881 $fname = 'do_templatelinks_update';
882882
883883 if ( $wgDatabase->tableExists( 'templatelinks' ) ) {
884 - echo "...templatelinks table already exists\n";
 884+ wfOut( "...templatelinks table already exists\n" );
885885 return;
886886 }
887 - echo "Creating templatelinks table...\n";
 887+ wfOut( "Creating templatelinks table...\n" );
888888 dbsource( archive('patch-templatelinks.sql'), $wgDatabase );
889 - echo "Populating...\n";
 889+ wfOut( "Populating...\n" );
890890 if ( isset( $wgLoadBalancer ) && $wgLoadBalancer->getServerCount() > 1 ) {
891891 // Slow, replication-friendly update
892892 $res = $wgDatabase->select( 'pagelinks', array( 'pl_from', 'pl_namespace', 'pl_title' ),
@@ -922,14 +922,14 @@
923923 ), $fname
924924 );
925925 }
926 - echo "Done. Please run maintenance/refreshLinks.php for a more thorough templatelinks update.\n";
 926+ wfOut( "Done. Please run maintenance/refreshLinks.php for a more thorough templatelinks update.\n" );
927927 }
928928
929929 // Add index on ( rc_namespace, rc_user_text ) [Jul. 2006]
930930 // Add index on ( rc_user_text, rc_timestamp ) [Nov. 2006]
931931 function do_rc_indices_update() {
932932 global $wgDatabase;
933 - echo( "Checking for additional recent changes indices...\n" );
 933+ wfOut( "Checking for additional recent changes indices...\n" );
934934
935935 $indexes = array(
936936 'rc_ns_usertext' => 'patch-recentchanges-utindex.sql',
@@ -939,59 +939,59 @@
940940 foreach( $indexes as $index => $patch ) {
941941 $info = $wgDatabase->indexInfo( 'recentchanges', $index, __METHOD__ );
942942 if( !$info ) {
943 - echo( "...index `{$index}` not found; adding..." );
 943+ wfOut( "...index `{$index}` not found; adding..." );
944944 dbsource( archive( $patch ) );
945 - echo( "done.\n" );
 945+ wfOut( "done.\n" );
946946 } else {
947 - echo( "...index `{$index}` seems ok.\n" );
 947+ wfOut( "...index `{$index}` seems ok.\n" );
948948 }
949949 }
950950 }
951951
952952 function index_has_field($table, $index, $field) {
953953 global $wgDatabase;
954 - echo( "Checking if $table index $index includes field $field...\n" );
 954+ wfOut( "Checking if $table index $index includes field $field...\n" );
955955 $info = $wgDatabase->indexInfo( $table, $index, __METHOD__ );
956956 if( $info ) {
957957 foreach($info as $row) {
958958 if($row->Column_name == $field) {
959 - echo( "...index $index on table $table seems to be ok\n" );
 959+ wfOut( "...index $index on table $table seems to be ok\n" );
960960 return true;
961961 }
962962 }
963963 }
964 - echo( "...index $index on table $table has no field $field; adding\n" );
 964+ wfOut( "...index $index on table $table has no field $field; adding\n" );
965965 return false;
966966 }
967967
968968 function do_backlinking_indices_update() {
969 - echo( "Checking for backlinking indices...\n" );
 969+ wfOut( "Checking for backlinking indices...\n" );
970970 if (!index_has_field('pagelinks', 'pl_namespace', 'pl_from') ||
971971 !index_has_field('templatelinks', 'tl_namespace', 'tl_from') ||
972972 !index_has_field('imagelinks', 'il_to', 'il_from'))
973973 {
974974 dbsource( archive( 'patch-backlinkindexes.sql' ) );
975 - echo( "...backlinking indices updated\n" );
 975+ wfOut( "...backlinking indices updated\n" );
976976 }
977977 }
978978
979979 function do_categorylinks_indices_update() {
980 - echo( "Checking for categorylinks indices...\n" );
 980+ wfOut( "Checking for categorylinks indices...\n" );
981981 if (!index_has_field('categorylinks', 'cl_sortkey', 'cl_from'))
982982 {
983983 dbsource( archive( 'patch-categorylinksindex.sql' ) );
984 - echo( "...categorylinks indices updated\n" );
 984+ wfOut( "...categorylinks indices updated\n" );
985985 }
986986 }
987987
988988 function do_filearchive_indices_update() {
989989 global $wgDatabase;
990 - echo( "Checking filearchive indices...\n" );
 990+ wfOut( "Checking filearchive indices...\n" );
991991 $info = $wgDatabase->indexInfo( 'filearchive', 'fa_user_timestamp', __METHOD__ );
992992 if ( !$info )
993993 {
994994 dbsource( archive( 'patch-filearhive-user-index.sql' ) );
995 - echo( "...filearchive indices updated\n" );
 995+ wfOut( "...filearchive indices updated\n" );
996996 }
997997 }
998998
@@ -1000,27 +1000,26 @@
10011001 if ( !$wgDatabase->tableExists( 'profiling' ) ) {
10021002 // Simply ignore
10031003 } elseif ( $wgDatabase->fieldExists( 'profiling', 'pf_memory' ) ) {
1004 - echo "profiling table has pf_memory field.\n";
 1004+ wfOut( "profiling table has pf_memory field.\n" );
10051005 } else {
1006 - echo "Adding pf_memory field to table profiling...";
 1006+ wfOut( "Adding pf_memory field to table profiling..." );
10071007 dbsource( archive( 'patch-profiling-memory.sql' ), $wgDatabase );
1008 - echo "ok\n";
 1008+ wfOut( "ok\n" );
10091009 }
10101010 }
10111011
10121012 function do_stats_init() {
10131013 // Sometimes site_stats table is not properly populated.
10141014 global $wgDatabase;
1015 - echo "Checking site_stats row...";
 1015+ wfOut( "Checking site_stats row..." );
10161016 $row = $wgDatabase->selectRow( 'site_stats', '*', array( 'ss_row_id' => 1 ), __METHOD__ );
10171017 if( $row === false ) {
1018 - echo "data is missing! rebuilding...\n";
1019 -
 1018+ wfOut( "data is missing! rebuilding...\n" );
10201019 global $IP;
10211020 require_once "$IP/maintenance/initStats.inc";
10221021 wfInitStats();
10231022 } else {
1024 - echo "ok.\n";
 1023+ wfOut( "ok.\n" );
10251024 }
10261025 }
10271026
@@ -1028,9 +1027,9 @@
10291028 global $wgDatabase;
10301029 # We can't guarantee that the user will be able to use TRUNCATE,
10311030 # but we know that DELETE is available to us
1032 - echo( "Purging caches..." );
 1031+ wfOut( "Purging caches..." );
10331032 $wgDatabase->delete( 'objectcache', '*', __METHOD__ );
1034 - echo( "done.\n" );
 1033+ wfOut( "done.\n" );
10351034 }
10361035
10371036 function do_all_updates( $shared = false, $purge = true ) {
@@ -1074,15 +1073,14 @@
10751074 }
10761075
10771076
1078 - echo "Deleting old default messages (this may take a long time!)..."; flush();
 1077+ wfOut( "Deleting old default messages (this may take a long time!)..." );
10791078 deleteDefaultMessages();
1080 - echo "Done\n"; flush();
 1079+ wfOut( "Done\n" );
10811080
1082 - do_stats_init(); flush();
 1081+ do_stats_init();
10831082
10841083 if( $purge ) {
10851084 purge_cache();
1086 - flush();
10871085 }
10881086 }
10891087
@@ -1108,14 +1106,14 @@
11091107 $patch2 = 'patch-page_restrictions_sortkey.sql';
11101108
11111109 if ( $wgDatabase->tableExists( $name ) ) {
1112 - echo "...$name table already exists.\n";
 1110+ wfOut( "...$name table already exists.\n" );
11131111 } else {
1114 - echo "Creating $name table...";
 1112+ wfOut( "Creating $name table..." );
11151113 dbsource( archive($patch), $wgDatabase );
11161114 dbsource( archive($patch2), $wgDatabase );
1117 - echo "ok\n";
 1115+ wfOut( "ok\n" );
11181116
1119 - echo "Migrating old restrictions to new table...";
 1117+ wfOut( "Migrating old restrictions to new table..." );
11201118
11211119 $res = $wgDatabase->select( 'page', array( 'page_id', 'page_restrictions' ), array("page_restrictions!=''", "page_restrictions!='edit=:move='"), __METHOD__ );
11221120
@@ -1167,27 +1165,27 @@
11681166 __METHOD__ );
11691167 }
11701168 }
1171 - print "ok\n";
 1169+ wfOut( "ok\n" );
11721170 }
11731171 }
11741172
11751173 function do_category_population() {
11761174 if( update_row_exists( 'populate category' ) ) {
1177 - echo "...category table already populated.\n";
 1175+ wfOut( "...category table already populated.\n" );
11781176 return;
11791177 }
11801178 require_once( 'populateCategory.inc' );
1181 - echo "Populating category table, printing progress markers. ".
 1179+ wfOut( "Populating category table, printing progress markers. " ).
11821180 "For large databases, you\n".
11831181 "may want to hit Ctrl-C and do this manually with maintenance/\n".
11841182 "populateCategory.php.\n";
11851183 populateCategory( '', 10, 0, true );
1186 - echo "Done populating category table.\n";
 1184+ wfOut( "Done populating category table.\n" );
11871185 }
11881186
11891187 function do_populate_parent_id() {
11901188 if( update_row_exists( 'populate rev_parent_id' ) ) {
1191 - echo "...rev_parent_id column already populated.\n";
 1189+ wfOut( "...rev_parent_id column already populated.\n" );
11921190 return;
11931191 }
11941192 require_once( 'populateParentId.inc' );
@@ -1198,11 +1196,11 @@
11991197
12001198 function update_password_format() {
12011199 if ( update_row_exists( 'password format' ) ) {
1202 - echo "...password hash format already changed\n";
 1200+ wfOut( "...password hash format already changed\n" );
12031201 return;
12041202 }
12051203
1206 - echo "Updating password hash format...";
 1204+ wfOut( "Updating password hash format..." );
12071205
12081206 global $wgDatabase, $wgPasswordSalt;
12091207 $user = $wgDatabase->tableName( 'user' );
@@ -1216,7 +1214,7 @@
12171215 $wgDatabase->query( $sql, __METHOD__ );
12181216 $wgDatabase->insert( 'updatelog', array( 'ul_key' => 'password format' ), __METHOD__ );
12191217
1220 - echo "done\n";
 1218+ wfOut( "done\n" );
12211219 }
12221220
12231221 function
@@ -1376,11 +1374,11 @@
13771375 $search_path = $conf['search_path'];
13781376 }
13791377 if( strpos( $search_path, $wgDBmwschema ) === false ) {
1380 - echo "Adding in schema \"$wgDBmwschema\" to search_path for user \"$wgDBuser\"\n";
 1378+ wfOut( "Adding in schema \"$wgDBmwschema\" to search_path for user \"$wgDBuser\"\n" );
13811379 $search_path = "$wgDBmwschema, $search_path";
13821380 }
13831381 if( strpos( $search_path, $wgDBts2schema ) === false ) {
1384 - echo "Adding in schema \"$wgDBts2schema\" to search_path for user \"$wgDBuser\"\n";
 1382+ wfOut( "Adding in schema \"$wgDBts2schema\" to search_path for user \"$wgDBuser\"\n" );
13851383 $search_path = "$search_path, $wgDBts2schema";
13861384 }
13871385 if( array_key_exists( 'search_path', $conf ) === false || $search_path != $conf['search_path'] ) {
@@ -1389,7 +1387,7 @@
13901388 }
13911389 else {
13921390 $path = $conf['search_path'];
1393 - echo "... search_path for user \"$wgDBuser\" looks correct ($path)\n";
 1391+ wfOut( "... search_path for user \"$wgDBuser\" looks correct ($path)\n" );
13941392 }
13951393 $goodconf = array(
13961394 'client_min_messages' => 'error',
@@ -1399,12 +1397,12 @@
14001398 foreach( array_keys( $goodconf ) AS $key ) {
14011399 $value = $goodconf[$key];
14021400 if( !array_key_exists( $key, $conf ) or $conf[$key] !== $value ) {
1403 - echo "Setting $key to '$value' for user \"$wgDBuser\"\n";
 1401+ wfOut( "Setting $key to '$value' for user \"$wgDBuser\"\n" );
14041402 $wgDatabase->doQuery( "ALTER USER $wgDBuser SET $key = '$value'" );
14051403 $wgDatabase->doQuery( "SET $key = '$value'" );
14061404 }
14071405 else {
1408 - echo "... default value of \"$key\" is correctly set to \"$value\" for user \"$wgDBuser\"\n";
 1406+ wfOut( "... default value of \"$key\" is correctly set to \"$value\" for user \"$wgDBuser\"\n" );
14091407 }
14101408 }
14111409
@@ -1526,62 +1524,62 @@
15271525
15281526 foreach ($newsequences as $ns) {
15291527 if ($wgDatabase->sequenceExists($ns)) {
1530 - echo "... sequence \"$ns\" already exists\n";
 1528+ wfOut( "... sequence \"$ns\" already exists\n" );
15311529 continue;
15321530 }
15331531
1534 - echo "Creating sequence \"$ns\"\n";
 1532+ wfOut( "Creating sequence \"$ns\"\n" );
15351533 $wgDatabase->query("CREATE SEQUENCE $ns");
15361534 }
15371535
15381536 foreach ($newtables as $nt) {
15391537 if ($wgDatabase->tableExists($nt[0])) {
1540 - echo "... table \"$nt[0]\" already exists\n";
 1538+ wfOut( "... table \"$nt[0]\" already exists\n" );
15411539 continue;
15421540 }
15431541
1544 - echo "Creating table \"$nt[0]\"\n";
 1542+ wfOut( "Creating table \"$nt[0]\"\n" );
15451543 dbsource(archive($nt[1]));
15461544 }
15471545
15481546 ## Needed before newcols
15491547 if ($wgDatabase->tableExists("archive2")) {
1550 - echo "Converting \"archive2\" back to normal archive table\n";
 1548+ wfOut( "Converting \"archive2\" back to normal archive table\n" );
15511549 if ($wgDatabase->ruleExists("archive", "archive_insert")) {
1552 - echo "Dropping rule \"archive_insert\"\n";
 1550+ wfOut( "Dropping rule \"archive_insert\"\n" );
15531551 $wgDatabase->query("DROP RULE archive_insert ON archive");
15541552 }
15551553 if ($wgDatabase->ruleExists("archive", "archive_delete")) {
1556 - echo "Dropping rule \"archive_delete\"\n";
 1554+ wfOut( "Dropping rule \"archive_delete\"\n" );
15571555 $wgDatabase->query("DROP RULE archive_delete ON archive");
15581556 }
15591557 dbsource(archive("patch-remove-archive2.sql"));
15601558 }
15611559 else
1562 - echo "... obsolete table \"archive2\" does not exist\n";
 1560+ wfOut( "... obsolete table \"archive2\" does not exist\n" );
15631561
15641562 foreach ($newcols as $nc) {
15651563 $fi = $wgDatabase->fieldInfo($nc[0], $nc[1]);
15661564 if (!is_null($fi)) {
1567 - echo "... column \"$nc[0].$nc[1]\" already exists\n";
 1565+ wfOut( "... column \"$nc[0].$nc[1]\" already exists\n" );
15681566 continue;
15691567 }
15701568
1571 - echo "Adding column \"$nc[0].$nc[1]\"\n";
 1569+ wfOut( "Adding column \"$nc[0].$nc[1]\"\n" );
15721570 $wgDatabase->query("ALTER TABLE $nc[0] ADD $nc[1] $nc[2]");
15731571 }
15741572
15751573 foreach ($typechanges as $tc) {
15761574 $fi = $wgDatabase->fieldInfo($tc[0], $tc[1]);
15771575 if (is_null($fi)) {
1578 - echo "... error: expected column $tc[0].$tc[1] to exist\n";
 1576+ wfOut( "... error: expected column $tc[0].$tc[1] to exist\n" );
15791577 exit(1);
15801578 }
15811579
15821580 if ($fi->type() === $tc[2])
1583 - echo "... column \"$tc[0].$tc[1]\" is already of type \"$tc[2]\"\n";
 1581+ wfOut( "... column \"$tc[0].$tc[1]\" is already of type \"$tc[2]\"\n" );
15841582 else {
1585 - echo "Changing column type of \"$tc[0].$tc[1]\" from \"{$fi->type()}\" to \"$tc[2]\"\n";
 1583+ wfOut( "Changing column type of \"$tc[0].$tc[1]\" from \"{$fi->type()}\" to \"$tc[2]\"\n" );
15861584 $sql = "ALTER TABLE $tc[0] ALTER $tc[1] TYPE $tc[2]";
15871585 if (strlen($tc[3])) {
15881586 $default = array();
@@ -1598,86 +1596,86 @@
15991597 }
16001598
16011599 if ($wgDatabase->fieldInfo('oldimage','oi_deleted')->type() !== 'smallint') {
1602 - echo "Changing \"oldimage.oi_deleted\" to type \"smallint\"\n";
 1600+ wfOut( "Changing \"oldimage.oi_deleted\" to type \"smallint\"\n" );
16031601 $wgDatabase->query( "ALTER TABLE oldimage ALTER oi_deleted DROP DEFAULT" );
16041602 $wgDatabase->query( "ALTER TABLE oldimage ALTER oi_deleted TYPE SMALLINT USING (oi_deleted::smallint)" );
16051603 $wgDatabase->query( "ALTER TABLE oldimage ALTER oi_deleted SET DEFAULT 0" );
16061604 }
16071605 else
1608 - echo "... column \"oldimage.oi_deleted\" is already of type \"smallint\"\n";
 1606+ wfOut( "... column \"oldimage.oi_deleted\" is already of type \"smallint\"\n" );
16091607
16101608
16111609 foreach ($newindexes as $ni) {
16121610 if (pg_index_exists($ni[0], $ni[1])) {
1613 - echo "... index \"$ni[1]\" on table \"$ni[0]\" already exists\n";
 1611+ wfOut( "... index \"$ni[1]\" on table \"$ni[0]\" already exists\n" );
16141612 continue;
16151613 }
1616 - echo "Creating index \"$ni[1]\" on table \"$ni[0]\" $ni[2]\n";
 1614+ wfOut( "Creating index \"$ni[1]\" on table \"$ni[0]\" $ni[2]\n" );
16171615 $wgDatabase->query( "CREATE INDEX $ni[1] ON $ni[0] $ni[2]" );
16181616 }
16191617
16201618 foreach ($newrules as $nr) {
16211619 if ($wgDatabase->ruleExists($nr[0], $nr[1])) {
1622 - echo "... rule \"$nr[1]\" on table \"$nr[0]\" already exists\n";
 1620+ wfOut( "... rule \"$nr[1]\" on table \"$nr[0]\" already exists\n" );
16231621 continue;
16241622 }
1625 - echo "Adding rule \"$nr[1]\" to table \"$nr[0]\"\n";
 1623+ wfOut( "Adding rule \"$nr[1]\" to table \"$nr[0]\"\n" );
16261624 dbsource(archive($nr[2]));
16271625 }
16281626
16291627 if ($wgDatabase->hasConstraint("oldimage_oi_name_fkey")) {
1630 - echo "Making foriegn key on table \"oldimage\" (to image) a cascade delete\n";
 1628+ wfOut( "Making foriegn key on table \"oldimage\" (to image) a cascade delete\n" );
16311629 $wgDatabase->query( "ALTER TABLE oldimage DROP CONSTRAINT oldimage_oi_name_fkey" );
16321630 $wgDatabase->query( "ALTER TABLE oldimage ADD CONSTRAINT oldimage_oi_name_fkey_cascade ".
16331631 "FOREIGN KEY (oi_name) REFERENCES image(img_name) ON DELETE CASCADE" );
16341632 }
16351633 else
1636 - echo "... table \"oldimage\" has correct cascade delete foreign key to image\n";
 1634+ wfOut( "... table \"oldimage\" has correct cascade delete foreign key to image\n" );
16371635
16381636 if (!$wgDatabase->triggerExists("page", "page_deleted")) {
1639 - echo "Adding function and trigger \"page_deleted\" to table \"page\"\n";
 1637+ wfOut( "Adding function and trigger \"page_deleted\" to table \"page\"\n" );
16401638 dbsource(archive('patch-page_deleted.sql'));
16411639 }
16421640 else
1643 - echo "... table \"page\" has \"page_deleted\" trigger\n";
 1641+ wfOut( "... table \"page\" has \"page_deleted\" trigger\n" );
16441642
16451643 $fi = $wgDatabase->fieldInfo("recentchanges", "rc_cur_id");
16461644 if (!$fi->nullable()) {
1647 - echo "Removing NOT NULL constraint from \"recentchanges.rc_cur_id\"\n";
 1645+ wfOut( "Removing NOT NULL constraint from \"recentchanges.rc_cur_id\"\n" );
16481646 dbsource(archive('patch-rc_cur_id-not-null.sql'));
16491647 }
16501648 else
1651 - echo "... column \"recentchanges.rc_cur_id\" has a NOT NULL constraint\n";
 1649+ wfOut( "... column \"recentchanges.rc_cur_id\" has a NOT NULL constraint\n" );
16521650
16531651 $pu = pg_describe_index("pagelink_unique");
16541652 if (!is_null($pu) && ($pu[0] != "pl_from" || $pu[1] != "pl_namespace" || $pu[2] != "pl_title")) {
1655 - echo "Dropping obsolete version of index \"pagelink_unique index\"\n";
 1653+ wfOut( "Dropping obsolete version of index \"pagelink_unique index\"\n" );
16561654 $wgDatabase->query("DROP INDEX pagelink_unique");
16571655 $pu = null;
16581656 }
16591657 else
1660 - echo "... obsolete version of index \"pagelink_unique index\" does not exist\n";
 1658+ wfOut( "... obsolete version of index \"pagelink_unique index\" does not exist\n" );
16611659
16621660 if (is_null($pu)) {
1663 - echo "Creating index \"pagelink_unique index\"\n";
 1661+ wfOut( "Creating index \"pagelink_unique index\"\n" );
16641662 $wgDatabase->query("CREATE UNIQUE INDEX pagelink_unique ON pagelinks (pl_from,pl_namespace,pl_title)");
16651663 }
16661664 else
1667 - echo "... index \"pagelink_unique_index\" already exists\n";
 1665+ wfOut( "... index \"pagelink_unique_index\" already exists\n" );
16681666
16691667 if (pg_fkey_deltype("revision_rev_user_fkey") == 'r') {
1670 - echo "... constraint \"revision_rev_user_fkey\" is ON DELETE RESTRICT\n";
 1668+ wfOut( "... constraint \"revision_rev_user_fkey\" is ON DELETE RESTRICT\n" );
16711669 }
16721670 else {
1673 - echo "Changing constraint \"revision_rev_user_fkey\" to ON DELETE RESTRICT\n";
 1671+ wfOut( "Changing constraint \"revision_rev_user_fkey\" to ON DELETE RESTRICT\n" );
16741672 dbsource(archive('patch-revision_rev_user_fkey.sql'));
16751673 }
16761674
16771675 # Fix ipb_address index
16781676 if (pg_index_exists('ipblocks', 'ipb_address_unique' )) {
1679 - echo "... have ipb_address_unique\n";
 1677+ wfOut( "... have ipb_address_unique\n" );
16801678 } else {
1681 - echo "Adding ipb_address_unique index\n";
 1679+ wfOut( "Adding ipb_address_unique index\n" );
16821680 dbsource(archive('patch-ipb_address_unique.sql'));
16831681 }
16841682
@@ -1685,29 +1683,29 @@
16861684 # Add missing extension tables
16871685 foreach ( $wgExtNewTables as $nt ) {
16881686 if ($wgDatabase->tableExists($nt[0])) {
1689 - echo "... table \"$nt[0]\" already exists\n";
 1687+ wfOut( "... table \"$nt[0]\" already exists\n" );
16901688 continue;
16911689 }
1692 - echo "Creating table \"$nt[0]\"\n";
 1690+ wfOut( "Creating table \"$nt[0]\"\n" );
16931691 dbsource($nt[1]);
16941692 }
16951693 # Add missing extension fields
16961694 foreach ( $wgExtPGNewFields as $nc ) {
16971695 $fi = $wgDatabase->fieldInfo($nc[0], $nc[1]);
16981696 if (!is_null($fi)) {
1699 - echo "... column \"$nc[0].$nc[1]\" already exists\n";
 1697+ wfOut( "... column \"$nc[0].$nc[1]\" already exists\n" );
17001698 continue;
17011699 }
1702 - echo "Adding column \"$nc[0].$nc[1]\"\n";
 1700+ wfOut( "Adding column \"$nc[0].$nc[1]\"\n" );
17031701 $wgDatabase->query( "ALTER TABLE $nc[0] ADD $nc[1] $nc[2]" );
17041702 }
17051703 # Add missing extension indexes
17061704 foreach ( $wgExtNewIndexes as $ni ) {
17071705 if (pg_index_exists($ni[0], $ni[1])) {
1708 - echo "... index \"$ni[1]\" on table \"$ni[0]\" already exists\n";
 1706+ wfOut( "... index \"$ni[1]\" on table \"$ni[0]\" already exists\n" );
17091707 continue;
17101708 }
1711 - echo "Creating index \"$ni[1]\" on table \"$ni[0]\"\n";
 1709+ wfOut( "Creating index \"$ni[1]\" on table \"$ni[0]\"\n" );
17121710 dbsource($ni[2]);
17131711 }
17141712
Index: branches/REL1_13/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_13/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_13/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_13/phase3/includes/GlobalFunctions.php
@@ -2769,6 +2769,21 @@
27702770 }
27712771 }
27722772
 2773+/**
 2774+ * Output some plain text in command-line mode or in the installer (updaters.inc).
 2775+ * Do not use it in any other context, its behaviour is subject to change.
 2776+ */
 2777+function wfOut( $s ) {
 2778+ static $lineStarted = false;
 2779+ global $wgCommandLineMode;
 2780+ if ( $wgCommandLineMode && !defined( 'MEDIAWIKI_INSTALL' ) ) {
 2781+ echo $s;
 2782+ } else {
 2783+ echo htmlspecialchars( $s );
 2784+ }
 2785+ flush();
 2786+}
 2787+
27732788 /** Generate a random 32-character hexadecimal token.
27742789 * @param mixed $salt Some sort of salt, if necessary, to add to random characters before hashing.
27752790 */
Index: branches/REL1_13/phase3/includes/db/DatabasePostgres.php
@@ -198,10 +198,11 @@
199199 $version = $this->getServerVersion();
200200 $PGMINVER = '8.1';
201201 if ($this->numeric_version < $PGMINVER) {
202 - print "<b>FAILED</b>. Required version is $PGMINVER. You have $this->numeric_version ($version)</li>\n";
 202+ print "<b>FAILED</b>. Required version is $PGMINVER. You have " .
 203+ htmlspecialchars( $this->numeric_version ) . " (" . htmlspecialchars( $version ) . ")</li>\n";
203204 dieout("</ul>");
204205 }
205 - print "version $this->numeric_version is OK.</li>\n";
 206+ print "version " . htmlspecialchars( $this->numeric_version ) . " is OK.</li>\n";
206207
207208 $safeuser = $this->quote_ident($wgDBuser);
208209 // Are we connecting as a superuser for the first time?
@@ -215,7 +216,7 @@
216217 FROM pg_catalog.pg_user WHERE usename = " . $this->addQuotes($wgDBsuperuser);
217218 $rows = $this->numRows($res = $this->doQuery($SQL));
218219 if (!$rows) {
219 - print "<li>ERROR: Could not read permissions for user \"$wgDBsuperuser\"</li>\n";
 220+ print "<li>ERROR: Could not read permissions for user \"" . htmlspecialchars( $wgDBsuperuser ) . "\"</li>\n";
220221 dieout('</ul>');
221222 }
222223 $perms = pg_fetch_result($res, 0, 0);
@@ -223,15 +224,15 @@
224225 $SQL = "SELECT 1 FROM pg_catalog.pg_user WHERE usename = " . $this->addQuotes($wgDBuser);
225226 $rows = $this->numRows($this->doQuery($SQL));
226227 if ($rows) {
227 - print "<li>User \"$wgDBuser\" already exists, skipping account creation.</li>";
 228+ print "<li>User \"" . htmlspecialchars( $wgDBuser ) . "\" already exists, skipping account creation.</li>";
228229 }
229230 else {
230231 if ($perms != 1 and $perms != 3) {
231 - print "<li>ERROR: the user \"$wgDBsuperuser\" cannot create other users. ";
 232+ print "<li>ERROR: the user \"" . htmlspecialchars( $wgDBsuperuser ) . "\" cannot create other users. ";
232233 print 'Please use a different Postgres user.</li>';
233234 dieout('</ul>');
234235 }
235 - print "<li>Creating user <b>$wgDBuser</b>...";
 236+ print "<li>Creating user <b>" . htmlspecialchars( $wgDBuser ) . "</b>...";
236237 $safepass = $this->addQuotes($wgDBpassword);
237238 $SQL = "CREATE USER $safeuser NOCREATEDB PASSWORD $safepass";
238239 $this->doQuery($SQL);
@@ -242,15 +243,15 @@
243244 $SQL = "SELECT 1 FROM pg_catalog.pg_database WHERE datname = " . $this->addQuotes($wgDBname);
244245 $rows = $this->numRows($this->doQuery($SQL));
245246 if ($rows) {
246 - print "<li>Database \"$wgDBname\" already exists, skipping database creation.</li>";
 247+ print "<li>Database \"" . htmlspecialchars( $wgDBname ) . "\" already exists, skipping database creation.</li>";
247248 }
248249 else {
249250 if ($perms < 2) {
250 - print "<li>ERROR: the user \"$wgDBsuperuser\" cannot create databases. ";
 251+ print "<li>ERROR: the user \"" . htmlspecialchars( $wgDBsuperuser ) . "\" cannot create databases. ";
251252 print 'Please use a different Postgres user.</li>';
252253 dieout('</ul>');
253254 }
254 - print "<li>Creating database <b>$wgDBname</b>...";
 255+ print "<li>Creating database <b>" . htmlspecialchars( $wgDBname ) . "</b>...";
255256 $safename = $this->quote_ident($wgDBname);
256257 $SQL = "CREATE DATABASE $safename OWNER $safeuser ";
257258 $this->doQuery($SQL);
@@ -259,17 +260,21 @@
260261 }
261262
262263 // Reconnect to check out tsearch2 rights for this user
263 - print "<li>Connecting to \"$wgDBname\" as superuser \"$wgDBsuperuser\" to check rights...";
 264+ print "<li>Connecting to \"" . htmlspecialchars( $wgDBname ) . "\" as superuser \"" .
 265+ htmlspecialchars( $wgDBsuperuser ) . "\" to check rights...";
264266
265 - $hstring="";
 267+ $connectVars = array();
266268 if ($this->mServer!=false && $this->mServer!="") {
267 - $hstring="host=$this->mServer ";
 269+ $connectVars['host'] = $this->mServer;
268270 }
269271 if ($this->mPort!=false && $this->mPort!="") {
270 - $hstring .= "port=$this->mPort ";
 272+ $connectVars['port'] = $this->mPort;
271273 }
 274+ $connectVars['dbname'] = $wgDBname;
 275+ $connectVars['user'] = $wgDBsuperuser;
 276+ $connectVars['password'] = $password;
272277
273 - @$this->mConn = pg_connect("$hstring dbname=$wgDBname user=$wgDBsuperuser password=$password");
 278+ @$this->mConn = pg_connect( $this->makeConnectionString( $connectVars ) );
274279 if ( $this->mConn == false ) {
275280 print "<b>FAILED TO CONNECT!</b></li>";
276281 dieout("</ul>");
@@ -279,15 +284,18 @@
280285
281286 if ($this->numeric_version < 8.3) {
282287 // Tsearch2 checks
283 - print "<li>Checking that tsearch2 is installed in the database \"$wgDBname\"...";
 288+ print "<li>Checking that tsearch2 is installed in the database \"" .
 289+ htmlspecialchars( $wgDBname ) . "\"...";
284290 if (! $this->tableExists("pg_ts_cfg", $wgDBts2schema)) {
285 - print "<b>FAILED</b>. tsearch2 must be installed in the database \"$wgDBname\".";
 291+ print "<b>FAILED</b>. tsearch2 must be installed in the database \"" .
 292+ htmlspecialchars( $wgDBname ) . "\".";
286293 print "Please see <a href='http://www.devx.com/opensource/Article/21674/0/page/2'>this article</a>";
287294 print " for instructions or ask on #postgresql on irc.freenode.net</li>\n";
288295 dieout("</ul>");
289296 }
290297 print "OK</li>\n";
291 - print "<li>Ensuring that user \"$wgDBuser\" has select rights on the tsearch2 tables...";
 298+ print "<li>Ensuring that user \"" . htmlspecialchars( $wgDBuser ) .
 299+ "\" has select rights on the tsearch2 tables...";
292300 foreach (array('cfg','cfgmap','dict','parser') as $table) {
293301 $SQL = "GRANT SELECT ON pg_ts_$table TO $safeuser";
294302 $this->doQuery($SQL);
@@ -299,7 +307,7 @@
300308 $result = $this->schemaExists($wgDBmwschema);
301309 $safeschema = $this->quote_ident($wgDBmwschema);
302310 if (!$result) {
303 - print "<li>Creating schema <b>$wgDBmwschema</b> ...";
 311+ print "<li>Creating schema <b>" . htmlspecialchars( $wgDBmwschema ) . "</b> ...";
304312 $result = $this->doQuery("CREATE SCHEMA $safeschema AUTHORIZATION $safeuser");
305313 if (!$result) {
306314 print "<b>FAILED</b>.</li>\n";
@@ -345,7 +353,7 @@
346354
347355 if ($this->numeric_version < 8.3) {
348356 // Do we have the basic tsearch2 table?
349 - print "<li>Checking for tsearch2 in the schema \"$wgDBts2schema\"...";
 357+ print "<li>Checking for tsearch2 in the schema \"" . htmlspecialchars( $wgDBts2schema ) . "\"...";
350358 if (! $this->tableExists("pg_ts_dict", $wgDBts2schema)) {
351359 print "<b>FAILED</b>. Make sure tsearch2 is installed. See <a href=";
352360 print "'http://www.devx.com/opensource/Article/21674/0/page/2'>this article</a>";
@@ -365,12 +373,13 @@
366374 $SQL = "SELECT count(*) FROM $safetsschema.pg_ts_$tname";
367375 $res = $this->doQuery($SQL);
368376 if (!$res) {
369 - print "<b>FAILED</b> to access pg_ts_$tname. Make sure that the user ".
370 - "\"$wgDBuser\" has SELECT access to all four tsearch2 tables</li>\n";
 377+ print "<b>FAILED</b> to access " . htmlspecialchars( "pg_ts_$tname" ) .
 378+ ". Make sure that the user \"". htmlspecialchars( $wgDBuser ) .
 379+ "\" has SELECT access to all four tsearch2 tables</li>\n";
371380 dieout("</ul>");
372381 }
373382 }
374 - $SQL = "SELECT ts_name FROM $safetsschema.pg_ts_cfg WHERE locale = '$ctype'";
 383+ $SQL = "SELECT ts_name FROM $safetsschema.pg_ts_cfg WHERE locale = " . $this->addQuotes( $ctype ) ;
375384 $SQL .= " ORDER BY CASE WHEN ts_name <> 'default' THEN 1 ELSE 0 END";
376385 $res = $this->doQuery($SQL);
377386 error_reporting( E_ALL );
@@ -381,28 +390,30 @@
382391 print "OK</li>";
383392
384393 // Will the current locale work? Can we force it to?
385 - print "<li>Verifying tsearch2 locale with $ctype...";
 394+ print "<li>Verifying tsearch2 locale with " . htmlspecialchars( $ctype ) . "...";
386395 $rows = $this->numRows($res);
387396 $resetlocale = 0;
388397 if (!$rows) {
389398 print "<b>not found</b></li>\n";
390 - print "<li>Attempting to set default tsearch2 locale to \"$ctype\"...";
 399+ print "<li>Attempting to set default tsearch2 locale to \"" . htmlspecialchars( $ctype ) . "\"...";
391400 $resetlocale = 1;
392401 }
393402 else {
394403 $tsname = pg_fetch_result($res, 0, 0);
395404 if ($tsname != 'default') {
396 - print "<b>not set to default ($tsname)</b>";
397 - print "<li>Attempting to change tsearch2 default locale to \"$ctype\"...";
 405+ print "<b>not set to default (" . htmlspecialchars( $tsname ) . ")</b>";
 406+ print "<li>Attempting to change tsearch2 default locale to \"" .
 407+ htmlspecialchars( $ctype ) . "\"...";
398408 $resetlocale = 1;
399409 }
400410 }
401411 if ($resetlocale) {
402 - $SQL = "UPDATE $safetsschema.pg_ts_cfg SET locale = '$ctype' WHERE ts_name = 'default'";
 412+ $SQL = "UPDATE $safetsschema.pg_ts_cfg SET locale = " . $this->addQuotes( $ctype ) . " WHERE ts_name = 'default'";
403413 $res = $this->doQuery($SQL);
404414 if (!$res) {
405415 print "<b>FAILED</b>. ";
406 - print "Please make sure that the locale in pg_ts_cfg for \"default\" is set to \"$ctype\"</li>\n";
 416+ print "Please make sure that the locale in pg_ts_cfg for \"default\" is set to \"" .
 417+ htmlspecialchars( $ctype ) . "\"</li>\n";
407418 dieout("</ul>");
408419 }
409420 print "OK</li>";
@@ -412,7 +423,7 @@
413424 $SQL = "SELECT $safetsschema.to_tsvector('default','MediaWiki tsearch2 testing')";
414425 $res = $this->doQuery($SQL);
415426 if (!$res) {
416 - print "<b>FAILED</b>. Specifically, \"$SQL\" did not work.</li>";
 427+ print "<b>FAILED</b>. Specifically, \"" . htmlspecialchars( $SQL ) . "\" did not work.</li>";
417428 dieout("</ul>");
418429 }
419430 print "OK</li>";
@@ -424,28 +435,32 @@
425436 // Does the schema already exist? Who owns it?
426437 $result = $this->schemaExists($wgDBmwschema);
427438 if (!$result) {
428 - print "<li>Creating schema <b>$wgDBmwschema</b> ...";
 439+ print "<li>Creating schema <b>" . htmlspecialchars( $wgDBmwschema ) . "</b> ...";
429440 error_reporting( 0 );
430441 $safeschema = $this->quote_ident($wgDBmwschema);
431442 $result = $this->doQuery("CREATE SCHEMA $safeschema");
432443 error_reporting( E_ALL );
433444 if (!$result) {
434 - print "<b>FAILED</b>. The user \"$wgDBuser\" must be able to access the schema. ".
 445+ print "<b>FAILED</b>. The user \"" . htmlspecialchars( $wgDBuser ) .
 446+ "\" must be able to access the schema. ".
435447 "You can try making them the owner of the database, or try creating the schema with a ".
436 - "different user, and then grant access to the \"$wgDBuser\" user.</li>\n";
 448+ "different user, and then grant access to the \"" .
 449+ htmlspecialchars( $wgDBuser ) . "\" user.</li>\n";
437450 dieout("</ul>");
438451 }
439452 print "OK</li>\n";
440453 }
441454 else if ($result != $wgDBuser) {
442 - print "<li>Schema \"$wgDBmwschema\" exists but is not owned by \"$wgDBuser\". Not ideal.</li>\n";
 455+ print "<li>Schema \"" . htmlspecialchars( $wgDBmwschema ) . "\" exists but is not owned by \"" .
 456+ htmlspecialchars( $wgDBuser ) . "\". Not ideal.</li>\n";
443457 }
444458 else {
445 - print "<li>Schema \"$wgDBmwschema\" exists and is owned by \"$wgDBuser\". Excellent.</li>\n";
 459+ print "<li>Schema \"" . htmlspecialchars( $wgDBmwschema ) . "\" exists and is owned by \"" .
 460+ htmlspecialchars( $wgDBuser ) . "\". Excellent.</li>\n";
446461 }
447462
448463 // Always return GMT time to accomodate the existing integer-based timestamp assumption
449 - print "<li>Setting the timezone to GMT for user \"$wgDBuser\" ...";
 464+ print "<li>Setting the timezone to GMT for user \"" . htmlspecialchars( $wgDBuser ) . "\" ...";
450465 $SQL = "ALTER USER $safeuser SET timezone = 'GMT'";
451466 $result = pg_query($this->mConn, $SQL);
452467 if (!$result) {
@@ -461,7 +476,7 @@
462477 dieout("</ul>");
463478 }
464479
465 - print "<li>Setting the datestyle to ISO, YMD for user \"$wgDBuser\" ...";
 480+ print "<li>Setting the datestyle to ISO, YMD for user \"" . htmlspecialchars( $wgDBuser ) . "\" ...";
466481 $SQL = "ALTER USER $safeuser SET datestyle = 'ISO, YMD'";
467482 $result = pg_query($this->mConn, $SQL);
468483 if (!$result) {
@@ -478,7 +493,7 @@
479494 }
480495
481496 // Fix up the search paths if needed
482 - print "<li>Setting the search path for user \"$wgDBuser\" ...";
 497+ print "<li>Setting the search path for user \"" . htmlspecialchars( $wgDBuser ) . "\" ...";
483498 $path = $this->quote_ident($wgDBmwschema);
484499 if ($wgDBts2schema !== $wgDBmwschema)
485500 $path .= ", ". $this->quote_ident($wgDBts2schema);
@@ -519,12 +534,14 @@
520535 $result = $this->doQuery("CREATE LANGUAGE plpgsql");
521536 error_reporting($olde);
522537 if (!$result) {
523 - print "<b>FAILED</b>. You need to install the language plpgsql in the database <tt>$wgDBname</tt></li>";
 538+ print "<b>FAILED</b>. You need to install the language plpgsql in the database <tt>" .
 539+ htmlspecialchars( $wgDBname ) . "</tt></li>";
524540 dieout("</ul>");
525541 }
526542 }
527543 else {
528 - print "<b>FAILED</b>. You need to install the language plpgsql in the database <tt>$wgDBname</tt></li>";
 544+ print "<b>FAILED</b>. You need to install the language plpgsql in the database <tt>" .
 545+ htmlspecialchars( $wgDBname ) . "</tt></li>";
529546 dieout("</ul>");
530547 }
531548 }
@@ -1217,7 +1234,8 @@
12181235 $res = $this->doQuery($SQL);
12191236 error_reporting( $olde );
12201237 if (!$res) {
1221 - print "<b>FAILED</b>. Make sure that the user \"$wgDBuser\" can write to the schema \"$wgDBmwschema\"</li>\n";
 1238+ print "<b>FAILED</b>. Make sure that the user \"" . htmlspecialchars( $wgDBuser ) .
 1239+ "\" can write to the schema \"" . htmlspecialchars( $wgDBmwschema ) . "\"</li>\n";
12221240 dieout("</ul>");
12231241 }
12241242 $this->doQuery("DROP TABLE $safeschema.$ctest");
@@ -1232,11 +1250,11 @@
12331251 $tss = $this->addQuotes($wgDBts2schema);
12341252 $pgp = $this->addQuotes($wgDBport);
12351253 $dbn = $this->addQuotes($this->mDBname);
1236 - $ctype = pg_fetch_result($this->doQuery("SHOW lc_ctype"),0,0);
 1254+ $ctype = $this->addQuotes( pg_fetch_result($this->doQuery("SHOW lc_ctype"),0,0) );
12371255
12381256 $SQL = "UPDATE mediawiki_version SET mw_version=$mwv, pg_version=$pgv, pg_user=$pgu, ".
12391257 "mw_schema = $mws, ts2_schema = $tss, pg_port=$pgp, pg_dbname=$dbn, ".
1240 - "ctype = '$ctype' ".
 1258+ "ctype = $ctype ".
12411259 "WHERE type = 'Creation'";
12421260 $this->query($SQL);
12431261
Index: branches/REL1_13/phase3/config/index.php
@@ -84,7 +84,8 @@
8585 <html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en" lang="en" dir="ltr">
8686 <head>
8787 <meta http-equiv="Content-type" content="text/html; charset=utf-8" />
88 - <title>MediaWiki <?php echo( $wgVersion ); ?> Installation</title>
 88+ <meta name="robots" content="noindex,nofollow"/>
 89+ <title>MediaWiki <?php echo htmlspecialchars( $wgVersion ); ?> Installation</title>
8990 <style type="text/css">
9091
9192 @import "../skins/monobook/main.css";
@@ -202,7 +203,7 @@
203204 <div id="content">
204205 <div id="bodyContent">
205206
206 -<h1>MediaWiki <?php print $wgVersion ?> Installation</h1>
 207+<h1>MediaWiki <?php print htmlspecialchars( $wgVersion ) ?> Installation</h1>
207208
208209 <?php
209210 $mainListOpened = false; # Is the main list (environement checking) opend ? Used by dieout
@@ -302,7 +303,7 @@
303304 install_version_checks();
304305 $self = 'Installer'; # Maintenance script name, to please Setup.php
305306
306 -print "<li>PHP " . phpversion() . " installed</li>\n";
 307+print "<li>PHP " . htmlspecialchars( phpversion() ) . " installed</li>\n";
307308
308309 error_reporting( 0 );
309310 $phpdatabases = array();
@@ -402,7 +403,7 @@
403404 $conf->safeMode = false;
404405 }
405406
406 -$sapi = php_sapi_name();
 407+$sapi = htmlspecialchars( php_sapi_name() );
407408 print "<li>PHP server API is $sapi; ";
408409 $script = defined('MW_INSTALL_PHP5_EXT') ? 'index.php5' : 'index.php';
409410 if( $wgUsePathInfo ) {
@@ -585,6 +586,9 @@
586587 : $_SERVER["SERVER_ADMIN"];
587588 $conf->EmergencyContact = importPost( "EmergencyContact", $defaultEmail );
588589 $conf->DBtype = importPost( "DBtype", $DefaultDBtype );
 590+ if ( !isset( $ourdb[$conf->DBtype] ) ) {
 591+ $conf->DBtype = $DefaultDBtype;
 592+ }
589593
590594 $conf->DBserver = importPost( "DBserver", "localhost" );
591595 $conf->DBname = importPost( "DBname", "wikidb" );
@@ -757,7 +761,7 @@
758762 $errs["DBtype"] = "Unknown database type '$conf->DBtype'";
759763 continue;
760764 }
761 - print "<li>Database type: {$conf->DBtypename}</li>\n";
 765+ print "<li>Database type: " . htmlspecialchars( $conf->DBtypename ) . "</li>\n";
762766 $dbclass = 'Database'.ucfirst($conf->DBtype);
763767 $wgDBtype = $conf->DBtype;
764768 $wgDBadminuser = "root";
@@ -785,7 +789,7 @@
786790
787791 $wgTitle = Title::newFromText( "Installation script" );
788792 error_reporting( E_ALL );
789 - print "<li>Loading class: $dbclass</li>\n";
 793+ print "<li>Loading class: " . htmlspecialchars( $dbclass ) . "</li>\n";
790794 $dbc = new $dbclass;
791795
792796 if( $conf->DBtype == 'mysql' ) {
@@ -809,7 +813,7 @@
810814 }
811815
812816 # Attempt to connect
813 - echo( "<li>Attempting to connect to database server as $db_user..." );
 817+ echo( "<li>Attempting to connect to database server as " . htmlspecialchars( $db_user ) . "..." );
814818 $wgDatabase = Database::newFromParams( $wgDBserver, $db_user, $db_pass, '', 1 );
815819
816820 # Check the connection and respond to errors
@@ -844,7 +848,7 @@
845849 case 2003:
846850 default:
847851 # General connection problem
848 - echo( "failed with error [$errno] $errtx.</li>\n" );
 852+ echo( htmlspecialchars( "failed with error [$errno] $errtx." ) . "</li>\n" );
849853 $errs["DBserver"] = "Connection failed";
850854 break;
851855 } # switch
@@ -858,10 +862,11 @@
859863 ## Possible connect as a superuser
860864 if( $useRoot && $conf->DBtype != 'sqlite' ) {
861865 $wgDBsuperuser = $conf->RootUser;
862 - echo( "<li>Attempting to connect to database \"postgres\" as superuser \"$wgDBsuperuser\"..." );
 866+ echo( "<li>Attempting to connect to database \"postgres\" as superuser \"" .
 867+ htmlspecialchars( $wgDBsuperuser ) . "\"..." );
863868 $wgDatabase = $dbc->newFromParams($wgDBserver, $wgDBsuperuser, $conf->RootPW, "postgres", 1);
864869 if (!$wgDatabase->isOpen()) {
865 - print " error: " . $wgDatabase->lastError() . "</li>\n";
 870+ print " error: " . htmlspecialchars( $wgDatabase->lastError() ) . "</li>\n";
866871 $errs["DBserver"] = "Could not connect to database as superuser";
867872 $errs["RootUser"] = "Check username";
868873 $errs["RootPW"] = "and password";
@@ -869,10 +874,11 @@
870875 }
871876 $wgDatabase->initial_setup($conf->RootPW, 'postgres');
872877 }
873 - echo( "<li>Attempting to connect to database \"$wgDBname\" as \"$wgDBuser\"..." );
 878+ echo( "<li>Attempting to connect to database \"" . htmlspecialchars( $wgDBname ) .
 879+ "\" as \"" . htmlspecialchars( $wgDBuser ) . "\"..." );
874880 $wgDatabase = $dbc->newFromParams($wgDBserver, $wgDBuser, $wgDBpassword, $wgDBname, 1);
875881 if (!$wgDatabase->isOpen()) {
876 - print " error: " . $wgDatabase->lastError() . "</li>\n";
 882+ print " error: " . htmlspecialchars( $wgDatabase->lastError() ) . "</li>\n";
877883 } else {
878884 $myver = $wgDatabase->getServerVersion();
879885 }
@@ -884,7 +890,7 @@
885891 continue;
886892 }
887893
888 - print "<li>Connected to $myver";
 894+ print "<li>Connected to " . htmlspecialchars( $myver );
889895 if ($conf->DBtype == 'mysql') {
890896 if( version_compare( $myver, "4.0.14" ) < 0 ) {
891897 print "</li>\n";
@@ -971,15 +977,19 @@
972978 }
973979 }
974980 if ( $existingSchema && $existingSchema != $conf->DBschema ) {
975 - print "<li><strong>Warning:</strong> you requested the {$conf->DBschema} schema, " .
976 - "but the existing database has the $existingSchema schema. This upgrade script ".
977 - "can't convert it, so it will remain $existingSchema.</li>\n";
 981+ $encExisting = htmlspecialchars( $existingSchema );
 982+ $encRequested = htmlspecialchars( $conf->DBschema );
 983+ print "<li><strong>Warning:</strong> you requested the $encRequested schema, " .
 984+ "but the existing database has the $encExisting schema. This upgrade script ".
 985+ "can't convert it, so it will remain $encExisting.</li>\n";
978986 $conf->setSchema( $existingSchema, $conf->DBengine );
979987 }
980988 if ( $existingEngine && $existingEngine != $conf->DBengine ) {
981 - print "<li><strong>Warning:</strong> you requested the {$conf->DBengine} storage " .
982 - "engine, but the existing database uses the $existingEngine engine. This upgrade " .
983 - "script can't convert it, so it will remain $existingEngine.</li>\n";
 989+ $encExisting = htmlspecialchars( $existingEngine );
 990+ $encRequested = htmlspecialchars( $conf->DBengine );
 991+ print "<li><strong>Warning:</strong> you requested the $encRequested storage " .
 992+ "engine, but the existing database uses the $encExisting engine. This upgrade " .
 993+ "script can't convert it, so it will remain $encExisting.</li>\n";
984994 $conf->setSchema( $conf->DBschema, $existingEngine );
985995 }
986996 }
@@ -1020,7 +1030,8 @@
10211031 }
10221032 $wgDatabase->freeResult( $res );
10231033 if ( !$found && $conf->DBengine != 'MyISAM' ) {
1024 - echo "<li><strong>Warning:</strong> {$conf->DBengine} storage engine not available, " .
 1034+ echo "<li><strong>Warning:</strong> " . htmlspecialchars( $conf->DBengine ) .
 1035+ " storage engine not available, " .
10251036 "using MyISAM instead</li>\n";
10261037 $conf->setSchema( $conf->DBschema, 'MyISAM' );
10271038 }
@@ -1059,10 +1070,10 @@
10601071 if( $wgDatabase2->isOpen() ) {
10611072 # Nope, just close the test connection and continue
10621073 $wgDatabase2->close();
1063 - echo( "<li>User $wgDBuser exists. Skipping grants.</li>\n" );
 1074+ echo( "<li>User " . htmlspecialchars( $wgDBuser ) . " exists. Skipping grants.</li>\n" );
10641075 } else {
10651076 # Yes, so run the grants
1066 - echo( "<li>Granting user permissions to $wgDBuser on $wgDBname..." );
 1077+ echo( "<li>" . htmlspecialchars( "Granting user permissions to $wgDBuser on $wgDBname..." ) );
10671078 dbsource( "../maintenance/users.sql", $wgDatabase );
10681079 echo( "success.</li>\n" );
10691080 }
@@ -1165,7 +1176,9 @@
11661177 $list = getLanguageList();
11671178 foreach( $list as $code => $name ) {
11681179 $sel = ($code == $conf->LanguageCode) ? 'selected="selected"' : '';
1169 - echo "\n\t\t<option value=\"$code\" $sel>$name</option>";
 1180+ $encCode = htmlspecialchars( $code );
 1181+ $encName = htmlspecialchars( $name );
 1182+ echo "\n\t\t<option value=\"$encCode\" $sel>$encName</option>";
11701183 }
11711184 echo "\n";
11721185 ?>
@@ -1330,7 +1343,11 @@
13311344 <div class="config-section">
13321345 <div class="config-input">
13331346 <label class='column'>Database type:</label>
1334 -<?php if (isset($errs['DBpicktype'])) print "\t<span class='error'>$errs[DBpicktype]</span>\n"; ?>
 1347+<?php
 1348+ if (isset($errs['DBpicktype'])) {
 1349+ print "\t<span class='error'>" . htmlspecialchars( $errs[DBpicktype] ) . "</span>\n";
 1350+ }
 1351+?>
13351352 <ul class='plain'><?php
13361353 database_picker($conf);
13371354 ?></ul>
@@ -1455,7 +1472,7 @@
14561473 </div>
14571474 </form>
14581475 <script type="text/javascript">
1459 -window.onload = toggleDBarea('<?php echo $conf->DBtype; ?>',
 1476+window.onload = toggleDBarea('<?php echo Xml::encodeJsVar( $conf->DBtype ); ?>',
14601477 <?php
14611478 ## If they passed in a root user name, don't populate it on page load
14621479 echo strlen(importPost('RootUser', '')) ? 0 : 1;
@@ -1781,10 +1798,8 @@
17821799 return importVar( $_REQUEST, $name, $default );
17831800 }
17841801
1785 -$radioCount = 0;
1786 -
17871802 function aField( &$conf, $field, $text, $type = "text", $value = "", $onclick = '' ) {
1788 - global $radioCount;
 1803+ static $radioCount = 0;
17891804 if( $type != "" ) {
17901805 $xtype = "type=\"$type\"";
17911806 } else {
@@ -1824,7 +1839,9 @@
18251840 }
18261841
18271842 global $errs;
1828 - if(isset($errs[$field])) echo "<span class='error'>" . $errs[$field] . "</span>\n";
 1843+ if(isset($errs[$field])) {
 1844+ echo "<span class='error'>" . htmlspecialchars( $errs[$field] ) . "</span>\n";
 1845+ }
18291846 }
18301847
18311848 function getLanguageList() {
@@ -1917,7 +1934,7 @@
19181935 fclose( $fp );
19191936 }
19201937 if ( !$errstr ) {
1921 - echo "<li>Connected to memcached on $host:$port successfully";
 1938+ echo "<li>Connected to memcached on " . htmlspecialchars( "$host:$port" ) ." successfully</li>";
19221939 }
19231940 return $errstr;
19241941 }

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