Index: trunk/phase3/maintenance/initStats.inc |
— | — | @@ -7,34 +7,34 @@ |
8 | 8 | function wfInitStats( $options=array() ) { |
9 | 9 | $dbr = wfGetDB( DB_SLAVE ); |
10 | 10 | |
11 | | - echo "Counting total edits..."; |
| 11 | + wfOut( "Counting total edits..." ); |
12 | 12 | $edits = $dbr->selectField( 'revision', 'COUNT(*)', '', __METHOD__ ); |
13 | 13 | $edits += $dbr->selectField( 'archive', 'COUNT(*)', '', __METHOD__ ); |
14 | | - echo "{$edits}\nCounting number of articles..."; |
| 14 | + wfOut( "{$edits}\nCounting number of articles..." ); |
15 | 15 | |
16 | 16 | global $wgContentNamespaces; |
17 | 17 | $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..." ); |
19 | 19 | |
20 | 20 | $pages = $dbr->selectField( 'page', 'COUNT(*)', '', __METHOD__ ); |
21 | | - echo "{$pages}\nCounting number of users..."; |
| 21 | + wfOut( "{$pages}\nCounting number of users..." ); |
22 | 22 | |
23 | 23 | $users = $dbr->selectField( 'user', 'COUNT(*)', '', __METHOD__ ); |
24 | | - echo "{$users}\nCounting number of admins..."; |
| 24 | + wfOut( "{$users}\nCounting number of admins..." ); |
25 | 25 | |
26 | 26 | $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..." ); |
28 | 28 | |
29 | 29 | $image = $dbr->selectField( 'image', 'COUNT(*)', '', __METHOD__ ); |
30 | | - echo "{$image}\n"; |
| 30 | + wfOut( "{$image}\n" ); |
31 | 31 | |
32 | 32 | if( !isset( $options['noviews'] ) ) { |
33 | | - echo "Counting total page views..."; |
| 33 | + wfOut( "Counting total page views..." ); |
34 | 34 | $views = $dbr->selectField( 'page', 'SUM(page_counter)', '', __METHOD__ ); |
35 | | - echo "{$views}\n"; |
| 35 | + wfOut( "{$views}\n" ); |
36 | 36 | } |
37 | 37 | |
38 | | - echo "\nUpdating site statistics..."; |
| 38 | + wfOut( "\nUpdating site statistics..." ); |
39 | 39 | |
40 | 40 | $dbw = wfGetDB( DB_MASTER ); |
41 | 41 | $values = array( 'ss_total_edits' => $edits, |
— | — | @@ -53,5 +53,5 @@ |
54 | 54 | $dbw->insert( 'site_stats', array_merge( $values, $conds, $views ), __METHOD__ ); |
55 | 55 | } |
56 | 56 | |
57 | | - echo( "done.\n" ); |
| 57 | + wfOut( "done.\n" ); |
58 | 58 | } |
Index: trunk/phase3/maintenance/populateCategory.inc |
— | — | @@ -18,9 +18,9 @@ |
19 | 19 | __FUNCTION__ |
20 | 20 | ); |
21 | 21 | if( $row ) { |
22 | | - echo "Category table already populated. Use php ". |
| 22 | + wfOut( "Category table already populated. Use php ". |
23 | 23 | "maintenance/populateCategory.php\n--force from the command line ". |
24 | | - "to override.\n"; |
| 24 | + "to override.\n" ); |
25 | 25 | return true; |
26 | 26 | } |
27 | 27 | } |
— | — | @@ -56,14 +56,14 @@ |
57 | 57 | # Use the row to update the category count |
58 | 58 | $cat = Category::newFromName( $name ); |
59 | 59 | if( !is_object( $cat ) ) { |
60 | | - echo "The category named $name is not valid?!\n"; |
| 60 | + wfOut( "The category named $name is not valid?!\n" ); |
61 | 61 | } else { |
62 | 62 | $cat->refreshCounts(); |
63 | 63 | } |
64 | 64 | |
65 | 65 | ++$i; |
66 | 66 | if( !($i % REPORTING_INTERVAL) ) { |
67 | | - echo "$name\n"; |
| 67 | + wfOut( "$name\n" ); |
68 | 68 | wfWaitForSlaves( $maxlag ); |
69 | 69 | } |
70 | 70 | usleep( $throttle*1000 ); |
— | — | @@ -76,10 +76,10 @@ |
77 | 77 | 'IGNORE' |
78 | 78 | ) |
79 | 79 | ) { |
80 | | - echo "Category population complete.\n"; |
| 80 | + wfOut( "Category population complete.\n" ); |
81 | 81 | return true; |
82 | 82 | } else { |
83 | | - echo "Could not insert category population row.\n"; |
| 83 | + wfOut( "Could not insert category population row.\n" ); |
84 | 84 | return false; |
85 | 85 | } |
86 | 86 | } |
Index: trunk/phase3/maintenance/updaters.inc |
— | — | @@ -190,11 +190,11 @@ |
191 | 191 | global $wgDatabase; |
192 | 192 | if ( $wgDatabase->tableExists( $from ) ) { |
193 | 193 | if ( $wgDatabase->tableExists( $to ) ) { |
194 | | - echo "...can't move table $from to $to, $to already exists.\n"; |
| 194 | + wfOut( "...can't move table $from to $to, $to already exists.\n" ); |
195 | 195 | } else { |
196 | | - echo "Moving table $from to $to..."; |
| 196 | + wfOut( "Moving table $from to $to..." ); |
197 | 197 | dbsource( archive($patch), $wgDatabase ); |
198 | | - echo "ok\n"; |
| 198 | + wfOut( "ok\n" ); |
199 | 199 | } |
200 | 200 | } else { |
201 | 201 | // Source table does not exist |
— | — | @@ -206,47 +206,47 @@ |
207 | 207 | function add_table( $name, $patch, $fullpath=false ) { |
208 | 208 | global $wgDatabase; |
209 | 209 | if ( $wgDatabase->tableExists( $name ) ) { |
210 | | - echo "...$name table already exists.\n"; |
| 210 | + wfOut( "...$name table already exists.\n" ); |
211 | 211 | } else { |
212 | | - echo "Creating $name table..."; |
| 212 | + wfOut( "Creating $name table..." ); |
213 | 213 | if( $fullpath ) { |
214 | 214 | dbsource( $patch, $wgDatabase ); |
215 | 215 | } else { |
216 | 216 | dbsource( archive($patch), $wgDatabase ); |
217 | 217 | } |
218 | | - echo "ok\n"; |
| 218 | + wfOut( "ok\n" ); |
219 | 219 | } |
220 | 220 | } |
221 | 221 | |
222 | 222 | function add_field( $table, $field, $patch, $fullpath=false ) { |
223 | 223 | global $wgDatabase; |
224 | 224 | if ( !$wgDatabase->tableExists( $table ) ) { |
225 | | - echo "...$table table does not exist, skipping new field patch\n"; |
| 225 | + wfOut( "...$table table does not exist, skipping new field patch\n" ); |
226 | 226 | } elseif ( $wgDatabase->fieldExists( $table, $field ) ) { |
227 | | - echo "...have $field field in $table table.\n"; |
| 227 | + wfOut( "...have $field field in $table table.\n" ); |
228 | 228 | } else { |
229 | | - echo "Adding $field field to table $table..."; |
| 229 | + wfOut( "Adding $field field to table $table..." ); |
230 | 230 | if( $fullpath ) { |
231 | 231 | dbsource( $patch, $wgDatabase ); |
232 | 232 | } else { |
233 | 233 | dbsource( archive($patch), $wgDatabase ); |
234 | 234 | } |
235 | | - echo "ok\n"; |
| 235 | + wfOut( "ok\n" ); |
236 | 236 | } |
237 | 237 | } |
238 | 238 | |
239 | 239 | function add_index( $table, $index, $patch, $fullpath=false ) { |
240 | 240 | global $wgDatabase; |
241 | 241 | if( $wgDatabase->indexExists( $table, $index ) ) { |
242 | | - echo "...$index key already set on $table table.\n"; |
| 242 | + wfOut( "...$index key already set on $table table.\n" ); |
243 | 243 | } else { |
244 | | - echo "Adding $index key to table $table... "; |
| 244 | + wfOut( "Adding $index key to table $table... " ); |
245 | 245 | if( $fullpath ) { |
246 | 246 | dbsource( $patch, $wgDatabase ); |
247 | 247 | } else { |
248 | 248 | dbsource( archive($patch), $wgDatabase ); |
249 | 249 | } |
250 | | - echo "ok\n"; |
| 250 | + wfOut( "ok\n" ); |
251 | 251 | } |
252 | 252 | } |
253 | 253 | |
— | — | @@ -262,11 +262,11 @@ |
263 | 263 | |
264 | 264 | global $wgDatabase; |
265 | 265 | $fname = "Update script: update_passwords()"; |
266 | | - print "\nIt appears that you need to update the user passwords in your\n" . |
| 266 | + wfOut( "\nIt appears that you need to update the user passwords in your\n" . |
267 | 267 | "database. If you have already done this (if you've run this update\n" . |
268 | 268 | "script once before, for example), doing so again will make all your\n" . |
269 | 269 | "user accounts inaccessible, so be sure you only do this once.\n" . |
270 | | - "Update user passwords? (yes/no)"; |
| 270 | + "Update user passwords? (yes/no)" ); |
271 | 271 | |
272 | 272 | $resp = readconsole(); |
273 | 273 | if ( ! ( "Y" == $resp{0} || "y" == $resp{0} ) ) { return; } |
— | — | @@ -289,15 +289,15 @@ |
290 | 290 | # Check that interwiki table exists; if it doesn't source it |
291 | 291 | global $wgDatabase, $IP; |
292 | 292 | if( $wgDatabase->tableExists( "interwiki" ) ) { |
293 | | - echo "...already have interwiki table\n"; |
| 293 | + wfOut( "...already have interwiki table\n" ); |
294 | 294 | return true; |
295 | 295 | } |
296 | | - echo "Creating interwiki table: "; |
| 296 | + wfOut( "Creating interwiki table: " ); |
297 | 297 | dbsource( archive("patch-interwiki.sql") ); |
298 | | - echo "ok\n"; |
299 | | - echo "Adding default interwiki definitions: "; |
| 298 | + wfOut( "ok\n" ); |
| 299 | + wfOut( "Adding default interwiki definitions: " ); |
300 | 300 | dbsource( "$IP/maintenance/interwiki.sql" ); |
301 | | - echo "ok\n"; |
| 301 | + wfOut( "ok\n" ); |
302 | 302 | } |
303 | 303 | |
304 | 304 | function do_index_update() { |
— | — | @@ -305,12 +305,12 @@ |
306 | 306 | global $wgDatabase; |
307 | 307 | $meta = $wgDatabase->fieldInfo( "recentchanges", "rc_timestamp" ); |
308 | 308 | if( !$meta->isMultipleKey() ) { |
309 | | - echo "Updating indexes to 20031107: "; |
| 309 | + wfOut( "Updating indexes to 20031107: " ); |
310 | 310 | dbsource( archive("patch-indexes.sql") ); |
311 | | - echo "ok\n"; |
| 311 | + wfOut( "ok\n" ); |
312 | 312 | return true; |
313 | 313 | } |
314 | | - echo "...indexes seem up to 20031107 standards\n"; |
| 314 | + wfOut( "...indexes seem up to 20031107 standards\n" ); |
315 | 315 | return false; |
316 | 316 | } |
317 | 317 | |
— | — | @@ -319,67 +319,67 @@ |
320 | 320 | |
321 | 321 | $meta = $wgDatabase->fieldInfo( "image", "img_major_mime" ); |
322 | 322 | if( !$meta->isMultipleKey() ) { |
323 | | - echo "Updating indexes to 20050912: "; |
| 323 | + wfOut( "Updating indexes to 20050912: " ); |
324 | 324 | dbsource( archive("patch-mimesearch-indexes.sql") ); |
325 | | - echo "ok\n"; |
| 325 | + wfOut( "ok\n" ); |
326 | 326 | return true; |
327 | 327 | } |
328 | | - echo "...indexes seem up to 20050912 standards\n"; |
| 328 | + wfOut( "...indexes seem up to 20050912 standards\n" ); |
329 | 329 | return false; |
330 | 330 | } |
331 | 331 | |
332 | 332 | function do_image_name_unique_update() { |
333 | 333 | global $wgDatabase; |
334 | 334 | if( $wgDatabase->indexExists( 'image', 'PRIMARY' ) ) { |
335 | | - echo "...image primary key already set.\n"; |
| 335 | + wfOut( "...image primary key already set.\n" ); |
336 | 336 | } else { |
337 | | - echo "Making img_name the primary key... "; |
| 337 | + wfOut( "Making img_name the primary key... " ); |
338 | 338 | dbsource( archive("patch-image_name_primary.sql"), $wgDatabase ); |
339 | | - echo "ok\n"; |
| 339 | + wfOut( "ok\n" ); |
340 | 340 | } |
341 | 341 | } |
342 | 342 | |
343 | 343 | function do_logging_timestamp_index() { |
344 | 344 | global $wgDatabase; |
345 | 345 | if( $wgDatabase->indexExists( 'logging', 'times' ) ) { |
346 | | - echo "...timestamp key on logging already exists.\n"; |
| 346 | + wfOut( "...timestamp key on logging already exists.\n" ); |
347 | 347 | } else { |
348 | | - echo "Adding timestamp key on logging table... "; |
| 348 | + wfOut( "Adding timestamp key on logging table... " ); |
349 | 349 | dbsource( archive("patch-logging-times-index.sql"), $wgDatabase ); |
350 | | - echo "ok\n"; |
| 350 | + wfOut( "ok\n" ); |
351 | 351 | } |
352 | 352 | } |
353 | 353 | |
354 | 354 | function do_archive_user_index() { |
355 | 355 | global $wgDatabase; |
356 | 356 | if( $wgDatabase->indexExists( 'archive', 'usertext_timestamp' ) ) { |
357 | | - echo "...usertext,timestamp key on archive already exists.\n"; |
| 357 | + wfOut( "...usertext,timestamp key on archive already exists.\n" ); |
358 | 358 | } else { |
359 | | - echo "Adding usertext,timestamp key on archive table... "; |
| 359 | + wfOut( "Adding usertext,timestamp key on archive table... " ); |
360 | 360 | dbsource( archive("patch-archive-user-index.sql"), $wgDatabase ); |
361 | | - echo "ok\n"; |
| 361 | + wfOut( "ok\n" ); |
362 | 362 | } |
363 | 363 | } |
364 | 364 | |
365 | 365 | function do_image_user_index() { |
366 | 366 | global $wgDatabase; |
367 | 367 | if( $wgDatabase->indexExists( 'image', 'img_usertext_timestamp' ) ) { |
368 | | - echo "...usertext,timestamp key on image already exists.\n"; |
| 368 | + wfOut( "...usertext,timestamp key on image already exists.\n" ); |
369 | 369 | } else { |
370 | | - echo "Adding usertext,timestamp key on image table... "; |
| 370 | + wfOut( "Adding usertext,timestamp key on image table... " ); |
371 | 371 | dbsource( archive("patch-image-user-index.sql"), $wgDatabase ); |
372 | | - echo "ok\n"; |
| 372 | + wfOut( "ok\n" ); |
373 | 373 | } |
374 | 374 | } |
375 | 375 | |
376 | 376 | function do_oldimage_user_index() { |
377 | 377 | global $wgDatabase; |
378 | 378 | if( $wgDatabase->indexExists( 'oldimage', 'oi_usertext_timestamp' ) ) { |
379 | | - echo "...usertext,timestamp key on oldimage already exists.\n"; |
| 379 | + wfOut( "...usertext,timestamp key on oldimage already exists.\n" ); |
380 | 380 | } else { |
381 | | - echo "Adding usertext,timestamp key on oldimage table... "; |
| 381 | + wfOut( "Adding usertext,timestamp key on oldimage table... " ); |
382 | 382 | dbsource( archive("patch-oldimage-user-index.sql"), $wgDatabase ); |
383 | | - echo "ok\n"; |
| 383 | + wfOut( "ok\n" ); |
384 | 384 | } |
385 | 385 | } |
386 | 386 | |
— | — | @@ -387,18 +387,18 @@ |
388 | 388 | global $wgDatabase; |
389 | 389 | $fname = 'do_watchlist_update'; |
390 | 390 | if( $wgDatabase->fieldExists( 'watchlist', 'wl_notificationtimestamp' ) ) { |
391 | | - echo "The watchlist table is already set up for email notification.\n"; |
| 391 | + wfOut( "The watchlist table is already set up for email notification.\n" ); |
392 | 392 | } else { |
393 | | - echo "Adding wl_notificationtimestamp field for email notification management."; |
| 393 | + wfOut( "Adding wl_notificationtimestamp field for email notification management." ); |
394 | 394 | /* ALTER TABLE watchlist ADD (wl_notificationtimestamp varchar(14) binary NOT NULL default '0'); */ |
395 | 395 | dbsource( archive( 'patch-email-notification.sql' ), $wgDatabase ); |
396 | | - echo "ok\n"; |
| 396 | + wfOut( "ok\n" ); |
397 | 397 | } |
398 | 398 | # Check if we need to add talk page rows to the watchlist |
399 | 399 | $talk = $wgDatabase->selectField( 'watchlist', 'count(*)', 'wl_namespace & 1', $fname ); |
400 | 400 | $nontalk = $wgDatabase->selectField( 'watchlist', 'count(*)', 'NOT (wl_namespace & 1)', $fname ); |
401 | 401 | if ( $talk != $nontalk ) { |
402 | | - echo "Adding missing watchlist talk page rows... "; |
| 402 | + wfOut( "Adding missing watchlist talk page rows... " ); |
403 | 403 | flush(); |
404 | 404 | |
405 | 405 | $wgDatabase->insertSelect( 'watchlist', 'watchlist', |
— | — | @@ -408,9 +408,9 @@ |
409 | 409 | 'wl_title' => 'wl_title', |
410 | 410 | 'wl_notificationtimestamp' => 'wl_notificationtimestamp' |
411 | 411 | ), array( 'NOT (wl_namespace & 1)' ), $fname, 'IGNORE' ); |
412 | | - echo "ok\n"; |
| 412 | + wfOut( "ok\n" ); |
413 | 413 | } else { |
414 | | - echo "...watchlist talk page rows already present\n"; |
| 414 | + wfOut( "...watchlist talk page rows already present\n" ); |
415 | 415 | } |
416 | 416 | } |
417 | 417 | |
— | — | @@ -421,7 +421,7 @@ |
422 | 422 | $res = $wgDatabase->safeQuery( 'SELECT user_id, user_ip FROM !', |
423 | 423 | $wgDatabase->tableName( 'user_newtalk' ) ); |
424 | 424 | $num_newtalks=$wgDatabase->numRows($res); |
425 | | - echo "Now converting ".$num_newtalks." user_newtalk entries to watchlist table entries ... \n"; |
| 425 | + wfOut( "Now converting $num_newtalks user_newtalk entries to watchlist table entries ... \n" ); |
426 | 426 | |
427 | 427 | $user = new User(); |
428 | 428 | for ( $i = 1; $i <= $num_newtalks; $i++ ) { |
— | — | @@ -449,18 +449,18 @@ |
450 | 450 | ); |
451 | 451 | } |
452 | 452 | } |
453 | | - echo "Done.\n"; |
| 453 | + wfOut( "Done.\n" ); |
454 | 454 | } |
455 | 455 | |
456 | 456 | |
457 | 457 | function do_user_update() { |
458 | 458 | global $wgDatabase; |
459 | 459 | if( $wgDatabase->fieldExists( 'user', 'user_emailauthenticationtimestamp' ) ) { |
460 | | - echo "User table contains old email authentication field. Dropping... "; |
| 460 | + wfOut( "User table contains old email authentication field. Dropping... " ); |
461 | 461 | dbsource( archive( 'patch-email-authentication.sql' ), $wgDatabase ); |
462 | | - echo "ok\n"; |
| 462 | + wfOut( "ok\n" ); |
463 | 463 | } else { |
464 | | - echo "...user table does not contain old email authentication field.\n"; |
| 464 | + wfOut( "...user table does not contain old email authentication field.\n" ); |
465 | 465 | } |
466 | 466 | } |
467 | 467 | |
— | — | @@ -478,11 +478,11 @@ |
479 | 479 | $wgDatabase->freeResult( $res ); |
480 | 480 | |
481 | 481 | if( in_array( 'binary', $flags ) ) { |
482 | | - echo "$table table has correct $field encoding.\n"; |
| 482 | + wfOut( "$table table has correct $field encoding.\n" ); |
483 | 483 | } else { |
484 | | - echo "Fixing $field encoding on $table table... "; |
| 484 | + wfOut( "Fixing $field encoding on $table table... " ); |
485 | 485 | dbsource( archive( $patchFile ), $wgDatabase ); |
486 | | - echo "ok\n"; |
| 486 | + wfOut( "ok\n" ); |
487 | 487 | } |
488 | 488 | } |
489 | 489 | |
— | — | @@ -490,11 +490,11 @@ |
491 | 491 | global $wgDatabase; |
492 | 492 | $fname="do_schema_restructuring"; |
493 | 493 | if ( $wgDatabase->tableExists( 'page' ) ) { |
494 | | - echo "...page table already exists.\n"; |
| 494 | + wfOut( "...page table already exists.\n" ); |
495 | 495 | } else { |
496 | | - echo "...converting from cur/old to page/revision/text DB structure.\n"; flush(); |
497 | | - echo wfTimestamp( TS_DB ); |
498 | | - echo "......checking for duplicate entries.\n"; flush(); |
| 496 | + wfOut( "...converting from cur/old to page/revision/text DB structure.\n" ); |
| 497 | + wfOut( wfTimestamp( TS_DB ) ); |
| 498 | + wfOut( "......checking for duplicate entries.\n" ); |
499 | 499 | |
500 | 500 | list ($cur, $old, $page, $revision, $text) = $wgDatabase->tableNamesN( 'cur', 'old', 'page', 'revision', 'text' ); |
501 | 501 | |
— | — | @@ -502,15 +502,15 @@ |
503 | 503 | FROM $cur GROUP BY cur_title, cur_namespace HAVING c>1", $fname ); |
504 | 504 | |
505 | 505 | if ( $wgDatabase->numRows( $rows ) > 0 ) { |
506 | | - echo wfTimestamp( TS_DB ); |
507 | | - echo "......<b>Found duplicate entries</b>\n"; |
508 | | - echo ( sprintf( "<b> %-60s %3s %5s</b>\n", 'Title', 'NS', 'Count' ) ); |
| 506 | + wfOut( wfTimestamp( TS_DB ) ); |
| 507 | + wfOut( "......<b>Found duplicate entries</b>\n" ); |
| 508 | + wfOut( sprintf( "<b> %-60s %3s %5s</b>\n", 'Title', 'NS', 'Count' ) ); |
509 | 509 | while ( $row = $wgDatabase->fetchObject( $rows ) ) { |
510 | 510 | if ( ! isset( $duplicate[$row->cur_namespace] ) ) { |
511 | 511 | $duplicate[$row->cur_namespace] = array(); |
512 | 512 | } |
513 | 513 | $duplicate[$row->cur_namespace][] = $row->cur_title; |
514 | | - echo ( sprintf( " %-60s %3s %5s\n", $row->cur_title, $row->cur_namespace, $row->c ) ); |
| 514 | + wfOut( sprintf( " %-60s %3s %5s\n", $row->cur_title, $row->cur_namespace, $row->c ) ); |
515 | 515 | } |
516 | 516 | $sql = "SELECT cur_title, cur_namespace, cur_id, cur_timestamp FROM $cur WHERE "; |
517 | 517 | $firstCond = true; |
— | — | @@ -550,13 +550,13 @@ |
551 | 551 | } |
552 | 552 | $sql = "DELETE FROM $cur WHERE cur_id IN ( " . join( ',', $deleteId ) . ')'; |
553 | 553 | $rows = $wgDatabase->query( $sql, $fname ); |
554 | | - echo wfTimestamp( TS_DB ); |
555 | | - echo "......<b>Deleted</b> ".$wgDatabase->affectedRows()." records.\n"; |
| 554 | + wfOut( wfTimestamp( TS_DB ) ); |
| 555 | + wfOut( "......<b>Deleted</b> ".$wgDatabase->affectedRows()." records.\n" ); |
556 | 556 | } |
557 | 557 | |
558 | 558 | |
559 | | - echo wfTimestamp( TS_DB ); |
560 | | - echo "......Creating tables.\n"; |
| 559 | + wfOut( wfTimestamp( TS_DB ) ); |
| 560 | + wfOut( "......Creating tables.\n" ); |
561 | 561 | $wgDatabase->query("CREATE TABLE $page ( |
562 | 562 | page_id int(8) unsigned NOT NULL auto_increment, |
563 | 563 | page_namespace int NOT NULL, |
— | — | @@ -594,26 +594,26 @@ |
595 | 595 | INDEX usertext_timestamp (rev_user_text,rev_timestamp) |
596 | 596 | ) ENGINE=InnoDB", $fname ); |
597 | 597 | |
598 | | - echo wfTimestamp( TS_DB ); |
599 | | - echo "......Locking tables.\n"; |
| 598 | + wfOut( wfTimestamp( TS_DB ) ); |
| 599 | + wfOut( "......Locking tables.\n" ); |
600 | 600 | $wgDatabase->query( "LOCK TABLES $page WRITE, $revision WRITE, $old WRITE, $cur WRITE", $fname ); |
601 | 601 | |
602 | 602 | $maxold = intval( $wgDatabase->selectField( 'old', 'max(old_id)', '', $fname ) ); |
603 | | - echo wfTimestamp( TS_DB ); |
604 | | - echo "......maxold is {$maxold}\n"; |
| 603 | + wfOut( wfTimestamp( TS_DB ) ); |
| 604 | + wfOut( "......maxold is {$maxold}\n" ); |
605 | 605 | |
606 | | - echo wfTimestamp( TS_DB ); |
| 606 | + wfOut( wfTimestamp( TS_DB ) ); |
607 | 607 | global $wgLegacySchemaConversion; |
608 | 608 | if( $wgLegacySchemaConversion ) { |
609 | 609 | // Create HistoryBlobCurStub entries. |
610 | 610 | // Text will be pulled from the leftover 'cur' table at runtime. |
611 | | - echo "......Moving metadata from cur; using blob references to text in cur table.\n"; |
| 611 | + wfOut( "......Moving metadata from cur; using blob references to text in cur table.\n" ); |
612 | 612 | $cur_text = "concat('O:18:\"historyblobcurstub\":1:{s:6:\"mCurId\";i:',cur_id,';}')"; |
613 | 613 | $cur_flags = "'object'"; |
614 | 614 | } else { |
615 | 615 | // Copy all cur text in immediately: this may take longer but avoids |
616 | 616 | // having to keep an extra table around. |
617 | | - echo "......Moving text from cur.\n"; |
| 617 | + wfOut( "......Moving text from cur.\n" ); |
618 | 618 | $cur_text = 'cur_text'; |
619 | 619 | $cur_flags = "''"; |
620 | 620 | } |
— | — | @@ -622,16 +622,16 @@ |
623 | 623 | SELECT cur_namespace, cur_title, $cur_text, cur_comment, cur_user, cur_user_text, cur_timestamp, cur_minor_edit, $cur_flags |
624 | 624 | FROM $cur", $fname ); |
625 | 625 | |
626 | | - echo wfTimestamp( TS_DB ); |
627 | | - echo "......Setting up revision table.\n"; |
| 626 | + wfOut( wfTimestamp( TS_DB ) ); |
| 627 | + wfOut( "......Setting up revision table.\n" ); |
628 | 628 | $wgDatabase->query( "INSERT INTO $revision (rev_id, rev_page, rev_comment, rev_user, rev_user_text, rev_timestamp, |
629 | 629 | rev_minor_edit) |
630 | 630 | SELECT old_id, cur_id, old_comment, old_user, old_user_text, |
631 | 631 | old_timestamp, old_minor_edit |
632 | 632 | FROM $old,$cur WHERE old_namespace=cur_namespace AND old_title=cur_title", $fname ); |
633 | 633 | |
634 | | - echo wfTimestamp( TS_DB ); |
635 | | - echo "......Setting up page table.\n"; |
| 634 | + wfOut( wfTimestamp( TS_DB ) ); |
| 635 | + wfOut( "......Setting up page table.\n" ); |
636 | 636 | $wgDatabase->query( "INSERT INTO $page (page_id, page_namespace, page_title, page_restrictions, page_counter, |
637 | 637 | page_is_redirect, page_is_new, page_random, page_touched, page_latest, page_len) |
638 | 638 | SELECT cur_id, cur_namespace, cur_title, cur_restrictions, cur_counter, cur_is_redirect, cur_is_new, |
— | — | @@ -639,38 +639,38 @@ |
640 | 640 | FROM $cur,$revision |
641 | 641 | WHERE cur_id=rev_page AND rev_timestamp=cur_timestamp AND rev_id > {$maxold}", $fname ); |
642 | 642 | |
643 | | - echo wfTimestamp( TS_DB ); |
644 | | - echo "......Unlocking tables.\n"; |
| 643 | + wfOut( wfTimestamp( TS_DB ) ); |
| 644 | + wfOut( "......Unlocking tables.\n" ); |
645 | 645 | $wgDatabase->query( "UNLOCK TABLES", $fname ); |
646 | 646 | |
647 | | - echo wfTimestamp( TS_DB ); |
648 | | - echo "......Renaming old.\n"; |
| 647 | + wfOut( wfTimestamp( TS_DB ) ); |
| 648 | + wfOut( "......Renaming old.\n" ); |
649 | 649 | $wgDatabase->query( "ALTER TABLE $old RENAME TO $text", $fname ); |
650 | 650 | |
651 | | - echo wfTimestamp( TS_DB ); |
652 | | - echo "...done.\n"; |
| 651 | + wfOut( wfTimestamp( TS_DB ) ); |
| 652 | + wfOut( "...done.\n" ); |
653 | 653 | } |
654 | 654 | } |
655 | 655 | |
656 | 656 | function do_inverse_timestamp() { |
657 | 657 | global $wgDatabase; |
658 | 658 | if( $wgDatabase->fieldExists( 'revision', 'inverse_timestamp' ) ) { |
659 | | - echo "Removing revision.inverse_timestamp and fixing indexes... "; |
| 659 | + wfOut( "Removing revision.inverse_timestamp and fixing indexes... " ); |
660 | 660 | dbsource( archive( 'patch-inverse_timestamp.sql' ), $wgDatabase ); |
661 | | - echo "ok\n"; |
| 661 | + wfOut( "ok\n" ); |
662 | 662 | } else { |
663 | | - echo "revision timestamp indexes already up to 2005-03-13\n"; |
| 663 | + wfOut( "revision timestamp indexes already up to 2005-03-13\n" ); |
664 | 664 | } |
665 | 665 | } |
666 | 666 | |
667 | 667 | function do_text_id() { |
668 | 668 | global $wgDatabase; |
669 | 669 | if( $wgDatabase->fieldExists( 'revision', 'rev_text_id' ) ) { |
670 | | - echo "...rev_text_id already in place.\n"; |
| 670 | + wfOut( "...rev_text_id already in place.\n" ); |
671 | 671 | } else { |
672 | | - echo "Adding rev_text_id field... "; |
| 672 | + wfOut( "Adding rev_text_id field... " ); |
673 | 673 | dbsource( archive( 'patch-rev_text_id.sql' ), $wgDatabase ); |
674 | | - echo "ok\n"; |
| 674 | + wfOut( "ok\n" ); |
675 | 675 | } |
676 | 676 | } |
677 | 677 | |
— | — | @@ -701,25 +701,25 @@ |
702 | 702 | $wgDatabase->freeResult( $result ); |
703 | 703 | |
704 | 704 | if( substr( $info->Type, 0, 3 ) == 'int' ) { |
705 | | - echo "...$field is already a full int ($info->Type).\n"; |
| 705 | + wfOut( "...$field is already a full int ($info->Type).\n" ); |
706 | 706 | } else { |
707 | | - echo "Promoting $field from $info->Type to int... "; |
| 707 | + wfOut( "Promoting $field from $info->Type to int... " ); |
708 | 708 | |
709 | 709 | $sql = "ALTER TABLE $tablename MODIFY $field int NOT NULL"; |
710 | 710 | $wgDatabase->query( $sql ); |
711 | 711 | |
712 | | - echo "ok\n"; |
| 712 | + wfOut( "ok\n" ); |
713 | 713 | } |
714 | 714 | } |
715 | 715 | |
716 | 716 | function do_pagelinks_update() { |
717 | 717 | global $wgDatabase; |
718 | 718 | if( $wgDatabase->tableExists( 'pagelinks' ) ) { |
719 | | - echo "...already have pagelinks table.\n"; |
| 719 | + wfOut( "...already have pagelinks table.\n" ); |
720 | 720 | } else { |
721 | | - echo "Converting links and brokenlinks tables to pagelinks... "; |
| 721 | + wfOut( "Converting links and brokenlinks tables to pagelinks... " ); |
722 | 722 | dbsource( archive( 'patch-pagelinks.sql' ), $wgDatabase ); |
723 | | - echo "ok\n"; |
| 723 | + wfOut( "ok\n" ); |
724 | 724 | flush(); |
725 | 725 | |
726 | 726 | global $wgCanonicalNamespaceNames; |
— | — | @@ -735,7 +735,7 @@ |
736 | 736 | global $wgDatabase, $wgContLang; |
737 | 737 | |
738 | 738 | $ns = intval( $namespace ); |
739 | | - echo "Cleaning up broken links for namespace $ns... "; |
| 739 | + wfOut( "Cleaning up broken links for namespace $ns... " ); |
740 | 740 | |
741 | 741 | $pagelinks = $wgDatabase->tableName( 'pagelinks' ); |
742 | 742 | $name = $wgContLang->getNsText( $ns ); |
— | — | @@ -749,25 +749,25 @@ |
750 | 750 | AND pl_title LIKE '$likeprefix:%'"; |
751 | 751 | |
752 | 752 | $wgDatabase->query( $sql, 'do_pagelinks_namespace' ); |
753 | | - echo "ok\n"; |
| 753 | + wfOut( "ok\n" ); |
754 | 754 | } |
755 | 755 | |
756 | 756 | function do_drop_img_type() { |
757 | 757 | global $wgDatabase; |
758 | 758 | |
759 | 759 | if( $wgDatabase->fieldExists( 'image', 'img_type' ) ) { |
760 | | - echo "Dropping unused img_type field in image table... "; |
| 760 | + wfOut( "Dropping unused img_type field in image table... " ); |
761 | 761 | dbsource( archive( 'patch-drop_img_type.sql' ), $wgDatabase ); |
762 | | - echo "ok\n"; |
| 762 | + wfOut( "ok\n" ); |
763 | 763 | } else { |
764 | | - echo "No img_type field in image table; Good.\n"; |
| 764 | + wfOut( "No img_type field in image table; Good.\n" ); |
765 | 765 | } |
766 | 766 | } |
767 | 767 | |
768 | 768 | function do_old_links_update() { |
769 | 769 | global $wgDatabase; |
770 | 770 | if( $wgDatabase->tableExists( 'pagelinks' ) ) { |
771 | | - echo "Already have pagelinks; skipping old links table updates.\n"; |
| 771 | + wfOut( "Already have pagelinks; skipping old links table updates.\n" ); |
772 | 772 | } else { |
773 | 773 | convertLinks(); flush(); |
774 | 774 | } |
— | — | @@ -777,14 +777,14 @@ |
778 | 778 | global $wgDatabase; |
779 | 779 | $duper = new UserDupes( $wgDatabase ); |
780 | 780 | if( $duper->hasUniqueIndex() ) { |
781 | | - echo "Already have unique user_name index.\n"; |
| 781 | + wfOut( "Already have unique user_name index.\n" ); |
782 | 782 | } else { |
783 | 783 | if( !$duper->clearDupes() ) { |
784 | | - echo "WARNING: This next step will probably fail due to unfixed duplicates...\n"; |
| 784 | + wfOut( "WARNING: This next step will probably fail due to unfixed duplicates...\n" ); |
785 | 785 | } |
786 | | - echo "Adding unique index on user_name... "; |
| 786 | + wfOut( "Adding unique index on user_name... " ); |
787 | 787 | dbsource( archive( 'patch-user_nameindex.sql' ), $wgDatabase ); |
788 | | - echo "ok\n"; |
| 788 | + wfOut( "ok\n" ); |
789 | 789 | } |
790 | 790 | } |
791 | 791 | |
— | — | @@ -793,28 +793,28 @@ |
794 | 794 | global $wgDatabase; |
795 | 795 | |
796 | 796 | if( $wgDatabase->tableExists( 'user_groups' ) ) { |
797 | | - echo "...user_groups table already exists.\n"; |
| 797 | + wfOut( "...user_groups table already exists.\n" ); |
798 | 798 | return do_user_groups_reformat(); |
799 | 799 | } |
800 | 800 | |
801 | | - echo "Adding user_groups table... "; |
| 801 | + wfOut( "Adding user_groups table... " ); |
802 | 802 | dbsource( archive( 'patch-user_groups.sql' ), $wgDatabase ); |
803 | | - echo "ok\n"; |
| 803 | + wfOut( "ok\n" ); |
804 | 804 | |
805 | 805 | if( !$wgDatabase->tableExists( 'user_rights' ) ) { |
806 | 806 | if( $wgDatabase->fieldExists( 'user', 'user_rights' ) ) { |
807 | | - echo "Upgrading from a 1.3 or older database? Breaking out user_rights for conversion..."; |
| 807 | + wfOut( "Upgrading from a 1.3 or older database? Breaking out user_rights for conversion..." ); |
808 | 808 | dbsource( archive( 'patch-user_rights.sql' ), $wgDatabase ); |
809 | | - echo "ok\n"; |
| 809 | + wfOut( "ok\n" ); |
810 | 810 | } else { |
811 | | - echo "*** WARNING: couldn't locate user_rights table or field for upgrade.\n"; |
812 | | - echo "*** You may need to manually configure some sysops by manipulating\n"; |
813 | | - echo "*** the user_groups table.\n"; |
| 811 | + wfOut( "*** WARNING: couldn't locate user_rights table or field for upgrade.\n" ); |
| 812 | + wfOut( "*** You may need to manually configure some sysops by manipulating\n" ); |
| 813 | + wfOut( "*** the user_groups table.\n" ); |
814 | 814 | return; |
815 | 815 | } |
816 | 816 | } |
817 | 817 | |
818 | | - echo "Converting user_rights table to user_groups... "; |
| 818 | + wfOut( "Converting user_rights table to user_groups... " ); |
819 | 819 | $result = $wgDatabase->select( 'user_rights', |
820 | 820 | array( 'ur_user', 'ur_rights' ), |
821 | 821 | array( "ur_rights != ''" ), |
— | — | @@ -834,7 +834,7 @@ |
835 | 835 | } |
836 | 836 | } |
837 | 837 | $wgDatabase->freeResult( $result ); |
838 | | - echo "ok\n"; |
| 838 | + wfOut( "ok\n" ); |
839 | 839 | } |
840 | 840 | |
841 | 841 | function do_user_groups_reformat() { |
— | — | @@ -845,20 +845,20 @@ |
846 | 846 | if( $info->type() == 'int' ) { |
847 | 847 | $oldug = $wgDatabase->tableName( 'user_groups' ); |
848 | 848 | $newug = $wgDatabase->tableName( 'user_groups_bogus' ); |
849 | | - echo "user_groups is in bogus intermediate format. Renaming to $newug... "; |
| 849 | + wfOut( "user_groups is in bogus intermediate format. Renaming to $newug... " ); |
850 | 850 | $wgDatabase->query( "ALTER TABLE $oldug RENAME TO $newug" ); |
851 | | - echo "ok\n"; |
| 851 | + wfOut( "ok\n" ); |
852 | 852 | |
853 | | - echo "Re-adding fresh user_groups table... "; |
| 853 | + wfOut( "Re-adding fresh user_groups table... " ); |
854 | 854 | dbsource( archive( 'patch-user_groups.sql' ), $wgDatabase ); |
855 | | - echo "ok\n"; |
| 855 | + wfOut( "ok\n" ); |
856 | 856 | |
857 | | - echo "***\n"; |
858 | | - echo "*** WARNING: You will need to manually fix up user permissions in the user_groups\n"; |
859 | | - echo "*** table. Old 1.5 alpha versions did some pretty funky stuff...\n"; |
860 | | - echo "***\n"; |
| 857 | + wfOut( "***\n" ); |
| 858 | + wfOut( "*** WARNING: You will need to manually fix up user permissions in the user_groups\n" ); |
| 859 | + wfOut( "*** table. Old 1.5 alpha versions did some pretty funky stuff...\n" ); |
| 860 | + wfOut( "***\n" ); |
861 | 861 | } else { |
862 | | - echo "...user_groups is in current format.\n"; |
| 862 | + wfOut( "...user_groups is in current format.\n" ); |
863 | 863 | } |
864 | 864 | |
865 | 865 | } |
— | — | @@ -870,11 +870,11 @@ |
871 | 871 | $info = $wgDatabase->fieldInfo( 'watchlist', 'wl_notificationtimestamp' ); |
872 | 872 | |
873 | 873 | if( !$info->nullable() ) { |
874 | | - echo "Making wl_notificationtimestamp nullable... "; |
| 874 | + wfOut( "Making wl_notificationtimestamp nullable... " ); |
875 | 875 | dbsource( archive( 'patch-watchlist-null.sql' ), $wgDatabase ); |
876 | | - echo "ok\n"; |
| 876 | + wfOut( "ok\n" ); |
877 | 877 | } else { |
878 | | - echo "...wl_notificationtimestamp is already nullable.\n"; |
| 878 | + wfOut( "...wl_notificationtimestamp is already nullable.\n" ); |
879 | 879 | } |
880 | 880 | |
881 | 881 | } |
— | — | @@ -885,13 +885,13 @@ |
886 | 886 | function do_page_random_update() { |
887 | 887 | global $wgDatabase; |
888 | 888 | |
889 | | - echo "Setting page_random to a random value on rows where it equals 0..."; |
| 889 | + wfOut( "Setting page_random to a random value on rows where it equals 0..." ); |
890 | 890 | |
891 | 891 | $page = $wgDatabase->tableName( 'page' ); |
892 | 892 | $wgDatabase->query( "UPDATE $page SET page_random = RAND() WHERE page_random = 0", 'do_page_random_update' ); |
893 | 893 | $rows = $wgDatabase->affectedRows(); |
894 | 894 | |
895 | | - echo "changed $rows rows\n"; |
| 895 | + wfOut( "changed $rows rows\n" ); |
896 | 896 | } |
897 | 897 | |
898 | 898 | function do_templatelinks_update() { |
— | — | @@ -899,12 +899,12 @@ |
900 | 900 | $fname = 'do_templatelinks_update'; |
901 | 901 | |
902 | 902 | if ( $wgDatabase->tableExists( 'templatelinks' ) ) { |
903 | | - echo "...templatelinks table already exists\n"; |
| 903 | + wfOut( "...templatelinks table already exists\n" ); |
904 | 904 | return; |
905 | 905 | } |
906 | | - echo "Creating templatelinks table...\n"; |
| 906 | + wfOut( "Creating templatelinks table...\n" ); |
907 | 907 | dbsource( archive('patch-templatelinks.sql'), $wgDatabase ); |
908 | | - echo "Populating...\n"; |
| 908 | + wfOut( "Populating...\n" ); |
909 | 909 | if ( isset( $wgLoadBalancer ) && $wgLoadBalancer->getServerCount() > 1 ) { |
910 | 910 | // Slow, replication-friendly update |
911 | 911 | $res = $wgDatabase->select( 'pagelinks', array( 'pl_from', 'pl_namespace', 'pl_title' ), |
— | — | @@ -941,14 +941,14 @@ |
942 | 942 | ), $fname |
943 | 943 | ); |
944 | 944 | } |
945 | | - echo "Done. Please run maintenance/refreshLinks.php for a more thorough templatelinks update.\n"; |
| 945 | + wfOut( "Done. Please run maintenance/refreshLinks.php for a more thorough templatelinks update.\n" ); |
946 | 946 | } |
947 | 947 | |
948 | 948 | // Add index on ( rc_namespace, rc_user_text ) [Jul. 2006] |
949 | 949 | // Add index on ( rc_user_text, rc_timestamp ) [Nov. 2006] |
950 | 950 | function do_rc_indices_update() { |
951 | 951 | global $wgDatabase; |
952 | | - echo( "Checking for additional recent changes indices...\n" ); |
| 952 | + wfOut( "Checking for additional recent changes indices...\n" ); |
953 | 953 | |
954 | 954 | $indexes = array( |
955 | 955 | 'rc_ns_usertext' => 'patch-recentchanges-utindex.sql', |
— | — | @@ -958,59 +958,59 @@ |
959 | 959 | foreach( $indexes as $index => $patch ) { |
960 | 960 | $info = $wgDatabase->indexInfo( 'recentchanges', $index, __METHOD__ ); |
961 | 961 | if( !$info ) { |
962 | | - echo( "...index `{$index}` not found; adding..." ); |
| 962 | + wfOut( "...index `{$index}` not found; adding..." ); |
963 | 963 | dbsource( archive( $patch ) ); |
964 | | - echo( "done.\n" ); |
| 964 | + wfOut( "done.\n" ); |
965 | 965 | } else { |
966 | | - echo( "...index `{$index}` seems ok.\n" ); |
| 966 | + wfOut( "...index `{$index}` seems ok.\n" ); |
967 | 967 | } |
968 | 968 | } |
969 | 969 | } |
970 | 970 | |
971 | 971 | function index_has_field($table, $index, $field) { |
972 | 972 | global $wgDatabase; |
973 | | - echo( "Checking if $table index $index includes field $field...\n" ); |
| 973 | + wfOut( "Checking if $table index $index includes field $field...\n" ); |
974 | 974 | $info = $wgDatabase->indexInfo( $table, $index, __METHOD__ ); |
975 | 975 | if( $info ) { |
976 | 976 | foreach($info as $row) { |
977 | 977 | if($row->Column_name == $field) { |
978 | | - echo( "...index $index on table $table seems to be ok\n" ); |
| 978 | + wfOut( "...index $index on table $table seems to be ok\n" ); |
979 | 979 | return true; |
980 | 980 | } |
981 | 981 | } |
982 | 982 | } |
983 | | - echo( "...index $index on table $table has no field $field; adding\n" ); |
| 983 | + wfOut( "...index $index on table $table has no field $field; adding\n" ); |
984 | 984 | return false; |
985 | 985 | } |
986 | 986 | |
987 | 987 | function do_backlinking_indices_update() { |
988 | | - echo( "Checking for backlinking indices...\n" ); |
| 988 | + wfOut( "Checking for backlinking indices...\n" ); |
989 | 989 | if (!index_has_field('pagelinks', 'pl_namespace', 'pl_from') || |
990 | 990 | !index_has_field('templatelinks', 'tl_namespace', 'tl_from') || |
991 | 991 | !index_has_field('imagelinks', 'il_to', 'il_from')) |
992 | 992 | { |
993 | 993 | dbsource( archive( 'patch-backlinkindexes.sql' ) ); |
994 | | - echo( "...backlinking indices updated\n" ); |
| 994 | + wfOut( "...backlinking indices updated\n" ); |
995 | 995 | } |
996 | 996 | } |
997 | 997 | |
998 | 998 | function do_categorylinks_indices_update() { |
999 | | - echo( "Checking for categorylinks indices...\n" ); |
| 999 | + wfOut( "Checking for categorylinks indices...\n" ); |
1000 | 1000 | if (!index_has_field('categorylinks', 'cl_sortkey', 'cl_from')) |
1001 | 1001 | { |
1002 | 1002 | dbsource( archive( 'patch-categorylinksindex.sql' ) ); |
1003 | | - echo( "...categorylinks indices updated\n" ); |
| 1003 | + wfOut( "...categorylinks indices updated\n" ); |
1004 | 1004 | } |
1005 | 1005 | } |
1006 | 1006 | |
1007 | 1007 | function do_filearchive_indices_update() { |
1008 | 1008 | global $wgDatabase; |
1009 | | - echo( "Checking filearchive indices...\n" ); |
| 1009 | + wfOut( "Checking filearchive indices...\n" ); |
1010 | 1010 | $info = $wgDatabase->indexInfo( 'filearchive', 'fa_user_timestamp', __METHOD__ ); |
1011 | 1011 | if ( !$info ) |
1012 | 1012 | { |
1013 | 1013 | dbsource( archive( 'patch-filearhive-user-index.sql' ) ); |
1014 | | - echo( "...filearchive indices updated\n" ); |
| 1014 | + wfOut( "...filearchive indices updated\n" ); |
1015 | 1015 | } |
1016 | 1016 | } |
1017 | 1017 | |
— | — | @@ -1019,25 +1019,25 @@ |
1020 | 1020 | if ( !$wgDatabase->tableExists( 'profiling' ) ) { |
1021 | 1021 | // Simply ignore |
1022 | 1022 | } elseif ( $wgDatabase->fieldExists( 'profiling', 'pf_memory' ) ) { |
1023 | | - echo "profiling table has pf_memory field.\n"; |
| 1023 | + wfOut( "profiling table has pf_memory field.\n" ); |
1024 | 1024 | } else { |
1025 | | - echo "Adding pf_memory field to table profiling..."; |
| 1025 | + wfOut( "Adding pf_memory field to table profiling..." ); |
1026 | 1026 | dbsource( archive( 'patch-profiling-memory.sql' ), $wgDatabase ); |
1027 | | - echo "ok\n"; |
| 1027 | + wfOut( "ok\n" ); |
1028 | 1028 | } |
1029 | 1029 | } |
1030 | 1030 | |
1031 | 1031 | function do_stats_init() { |
1032 | 1032 | // Sometimes site_stats table is not properly populated. |
1033 | 1033 | global $wgDatabase; |
1034 | | - echo "Checking site_stats row..."; |
| 1034 | + wfOut( "Checking site_stats row..." ); |
1035 | 1035 | $row = $wgDatabase->selectRow( 'site_stats', '*', array( 'ss_row_id' => 1 ), __METHOD__ ); |
1036 | 1036 | if( $row === false ) { |
1037 | | - echo "data is missing! rebuilding...\n"; |
| 1037 | + wfOut( "data is missing! rebuilding...\n" ); |
1038 | 1038 | } elseif ( isset( $row->site_stats ) && $row->ss_total_pages == -1 ) { |
1039 | | - echo "missing ss_total_pages, rebuilding...\n"; |
| 1039 | + wfOut( "missing ss_total_pages, rebuilding...\n" ); |
1040 | 1040 | } else { |
1041 | | - echo "ok.\n"; |
| 1041 | + wfOut( "ok.\n" ); |
1042 | 1042 | return; |
1043 | 1043 | } |
1044 | 1044 | |
— | — | @@ -1059,16 +1059,16 @@ |
1060 | 1060 | array( 'ss_row_id' => 1 ), __METHOD__, array( 'LIMIT' => 1 ) |
1061 | 1061 | ); |
1062 | 1062 | } |
1063 | | - echo( "...ss_active_users user count set...\n" ); |
| 1063 | + wfOut( "...ss_active_users user count set...\n" ); |
1064 | 1064 | } |
1065 | 1065 | |
1066 | 1066 | function purge_cache() { |
1067 | 1067 | global $wgDatabase; |
1068 | 1068 | # We can't guarantee that the user will be able to use TRUNCATE, |
1069 | 1069 | # but we know that DELETE is available to us |
1070 | | - echo( "Purging caches..." ); |
| 1070 | + wfOut( "Purging caches..." ); |
1071 | 1071 | $wgDatabase->delete( 'objectcache', '*', __METHOD__ ); |
1072 | | - echo( "done.\n" ); |
| 1072 | + wfOut( "done.\n" ); |
1073 | 1073 | } |
1074 | 1074 | |
1075 | 1075 | function do_all_updates( $shared = false, $purge = true ) { |
— | — | @@ -1114,15 +1114,14 @@ |
1115 | 1115 | } |
1116 | 1116 | |
1117 | 1117 | |
1118 | | - echo "Deleting old default messages (this may take a long time!)..."; flush(); |
| 1118 | + wfOut( "Deleting old default messages (this may take a long time!)..." ); |
1119 | 1119 | deleteDefaultMessages(); |
1120 | | - echo "Done\n"; flush(); |
| 1120 | + wfOut( "Done\n" ); |
1121 | 1121 | |
1122 | | - do_stats_init(); flush(); |
| 1122 | + do_stats_init(); |
1123 | 1123 | |
1124 | 1124 | if( $purge ) { |
1125 | 1125 | purge_cache(); |
1126 | | - flush(); |
1127 | 1126 | } |
1128 | 1127 | } |
1129 | 1128 | |
— | — | @@ -1147,14 +1146,14 @@ |
1148 | 1147 | $patch2 = 'patch-page_restrictions_sortkey.sql'; |
1149 | 1148 | |
1150 | 1149 | if ( $wgDatabase->tableExists( $name ) ) { |
1151 | | - echo "...$name table already exists.\n"; |
| 1150 | + wfOut( "...$name table already exists.\n" ); |
1152 | 1151 | } else { |
1153 | | - echo "Creating $name table..."; |
| 1152 | + wfOut( "Creating $name table..." ); |
1154 | 1153 | dbsource( archive($patch), $wgDatabase ); |
1155 | 1154 | dbsource( archive($patch2), $wgDatabase ); |
1156 | | - echo "ok\n"; |
| 1155 | + wfOut( "ok\n" ); |
1157 | 1156 | |
1158 | | - echo "Migrating old restrictions to new table..."; |
| 1157 | + wfOut( "Migrating old restrictions to new table..." ); |
1159 | 1158 | |
1160 | 1159 | $res = $wgDatabase->select( 'page', array( 'page_id', 'page_restrictions' ), array("page_restrictions!=''", "page_restrictions!='edit=:move='"), __METHOD__ ); |
1161 | 1160 | |
— | — | @@ -1206,27 +1205,27 @@ |
1207 | 1206 | __METHOD__ ); |
1208 | 1207 | } |
1209 | 1208 | } |
1210 | | - print "ok\n"; |
| 1209 | + wfOut( "ok\n" ); |
1211 | 1210 | } |
1212 | 1211 | } |
1213 | 1212 | |
1214 | 1213 | function do_category_population() { |
1215 | 1214 | if( update_row_exists( 'populate category' ) ) { |
1216 | | - echo "...category table already populated.\n"; |
| 1215 | + wfOut( "...category table already populated.\n" ); |
1217 | 1216 | return; |
1218 | 1217 | } |
1219 | 1218 | require_once( 'populateCategory.inc' ); |
1220 | | - echo "Populating category table, printing progress markers. ". |
| 1219 | + wfOut( "Populating category table, printing progress markers. " ). |
1221 | 1220 | "For large databases, you\n". |
1222 | 1221 | "may want to hit Ctrl-C and do this manually with maintenance/\n". |
1223 | 1222 | "populateCategory.php.\n"; |
1224 | 1223 | populateCategory( '', 10, 0, true ); |
1225 | | - echo "Done populating category table.\n"; |
| 1224 | + wfOut( "Done populating category table.\n" ); |
1226 | 1225 | } |
1227 | 1226 | |
1228 | 1227 | function do_populate_parent_id() { |
1229 | 1228 | if( update_row_exists( 'populate rev_parent_id' ) ) { |
1230 | | - echo "...rev_parent_id column already populated.\n"; |
| 1229 | + wfOut( "...rev_parent_id column already populated.\n" ); |
1231 | 1230 | return; |
1232 | 1231 | } |
1233 | 1232 | require_once( 'populateParentId.inc' ); |
— | — | @@ -1237,11 +1236,11 @@ |
1238 | 1237 | |
1239 | 1238 | function update_password_format() { |
1240 | 1239 | if ( update_row_exists( 'password format' ) ) { |
1241 | | - echo "...password hash format already changed\n"; |
| 1240 | + wfOut( "...password hash format already changed\n" ); |
1242 | 1241 | return; |
1243 | 1242 | } |
1244 | 1243 | |
1245 | | - echo "Updating password hash format..."; |
| 1244 | + wfOut( "Updating password hash format..." ); |
1246 | 1245 | |
1247 | 1246 | global $wgDatabase, $wgPasswordSalt; |
1248 | 1247 | $user = $wgDatabase->tableName( 'user' ); |
— | — | @@ -1255,29 +1254,29 @@ |
1256 | 1255 | $wgDatabase->query( $sql, __METHOD__ ); |
1257 | 1256 | $wgDatabase->insert( 'updatelog', array( 'ul_key' => 'password format' ), __METHOD__ ); |
1258 | 1257 | |
1259 | | - echo "done\n"; |
| 1258 | + wfOut( "done\n" ); |
1260 | 1259 | } |
1261 | 1260 | |
1262 | 1261 | function sqlite_initial_indexes() { |
1263 | 1262 | global $wgDatabase; |
1264 | 1263 | if ( update_row_exists( 'initial_indexes' ) ) { |
1265 | | - echo "...have initial indexes\n"; |
| 1264 | + wfOut( "...have initial indexes\n" ); |
1266 | 1265 | return; |
1267 | 1266 | } |
1268 | | - echo "Adding initial indexes..."; |
| 1267 | + wfOut( "Adding initial indexes..." ); |
1269 | 1268 | $wgDatabase->sourceFile( archive( 'initial-indexes.sql' ) ); |
1270 | | - echo "done\n"; |
| 1269 | + wfOut( "done\n" ); |
1271 | 1270 | } |
1272 | 1271 | |
1273 | 1272 | function do_unique_pl_tl_il() { |
1274 | 1273 | global $wgDatabase; |
1275 | 1274 | $info = $wgDatabase->indexInfo( 'pagelinks', 'pl_namespace' ); |
1276 | 1275 | if( is_array($info) && !$info[0]->Non_unique ) { |
1277 | | - echo "...pl_namespace, tl_namespace, il_to indices are already UNIQUE.\n"; |
| 1276 | + wfOut( "...pl_namespace, tl_namespace, il_to indices are already UNIQUE.\n" ); |
1278 | 1277 | } else { |
1279 | | - echo "Making pl_namespace, tl_namespace and il_to indices UNIQUE... "; |
| 1278 | + wfOut( "Making pl_namespace, tl_namespace and il_to indices UNIQUE... " ); |
1280 | 1279 | dbsource( archive( 'patch-pl-tl-il-unique.sql' ), $wgDatabase ); |
1281 | | - echo "ok\n"; |
| 1280 | + wfOut( "ok\n" ); |
1282 | 1281 | } |
1283 | 1282 | } |
1284 | 1283 | |
— | — | @@ -1443,11 +1442,11 @@ |
1444 | 1443 | $search_path = $conf['search_path']; |
1445 | 1444 | } |
1446 | 1445 | if( strpos( $search_path, $wgDBmwschema ) === false ) { |
1447 | | - echo "Adding in schema \"$wgDBmwschema\" to search_path for user \"$wgDBuser\"\n"; |
| 1446 | + wfOut( "Adding in schema \"$wgDBmwschema\" to search_path for user \"$wgDBuser\"\n" ); |
1448 | 1447 | $search_path = "$wgDBmwschema, $search_path"; |
1449 | 1448 | } |
1450 | 1449 | if( strpos( $search_path, $wgDBts2schema ) === false ) { |
1451 | | - echo "Adding in schema \"$wgDBts2schema\" to search_path for user \"$wgDBuser\"\n"; |
| 1450 | + wfOut( "Adding in schema \"$wgDBts2schema\" to search_path for user \"$wgDBuser\"\n" ); |
1452 | 1451 | $search_path = "$search_path, $wgDBts2schema"; |
1453 | 1452 | } |
1454 | 1453 | $search_path = str_replace( ', ,', ',', $search_path); |
— | — | @@ -1457,7 +1456,7 @@ |
1458 | 1457 | } |
1459 | 1458 | else { |
1460 | 1459 | $path = $conf['search_path']; |
1461 | | - echo "... search_path for user \"$wgDBuser\" looks correct ($path)\n"; |
| 1460 | + wfOut( "... search_path for user \"$wgDBuser\" looks correct ($path)\n" ); |
1462 | 1461 | } |
1463 | 1462 | $goodconf = array( |
1464 | 1463 | 'client_min_messages' => 'error', |
— | — | @@ -1467,12 +1466,12 @@ |
1468 | 1467 | foreach( array_keys( $goodconf ) AS $key ) { |
1469 | 1468 | $value = $goodconf[$key]; |
1470 | 1469 | if( !array_key_exists( $key, $conf ) or $conf[$key] !== $value ) { |
1471 | | - echo "Setting $key to '$value' for user \"$wgDBuser\"\n"; |
| 1470 | + wfOut( "Setting $key to '$value' for user \"$wgDBuser\"\n" ); |
1472 | 1471 | $wgDatabase->doQuery( "ALTER USER $wgDBuser SET $key = '$value'" ); |
1473 | 1472 | $wgDatabase->doQuery( "SET $key = '$value'" ); |
1474 | 1473 | } |
1475 | 1474 | else { |
1476 | | - echo "... default value of \"$key\" is correctly set to \"$value\" for user \"$wgDBuser\"\n"; |
| 1475 | + wfOut( "... default value of \"$key\" is correctly set to \"$value\" for user \"$wgDBuser\"\n" ); |
1477 | 1476 | } |
1478 | 1477 | } |
1479 | 1478 | |
— | — | @@ -1601,62 +1600,62 @@ |
1602 | 1601 | |
1603 | 1602 | foreach ($newsequences as $ns) { |
1604 | 1603 | if ($wgDatabase->sequenceExists($ns)) { |
1605 | | - echo "... sequence \"$ns\" already exists\n"; |
| 1604 | + wfOut( "... sequence \"$ns\" already exists\n" ); |
1606 | 1605 | continue; |
1607 | 1606 | } |
1608 | 1607 | |
1609 | | - echo "Creating sequence \"$ns\"\n"; |
| 1608 | + wfOut( "Creating sequence \"$ns\"\n" ); |
1610 | 1609 | $wgDatabase->query("CREATE SEQUENCE $ns"); |
1611 | 1610 | } |
1612 | 1611 | |
1613 | 1612 | foreach ($newtables as $nt) { |
1614 | 1613 | if ($wgDatabase->tableExists($nt[0])) { |
1615 | | - echo "... table \"$nt[0]\" already exists\n"; |
| 1614 | + wfOut( "... table \"$nt[0]\" already exists\n" ); |
1616 | 1615 | continue; |
1617 | 1616 | } |
1618 | 1617 | |
1619 | | - echo "Creating table \"$nt[0]\"\n"; |
| 1618 | + wfOut( "Creating table \"$nt[0]\"\n" ); |
1620 | 1619 | dbsource(archive($nt[1])); |
1621 | 1620 | } |
1622 | 1621 | |
1623 | 1622 | ## Needed before newcols |
1624 | 1623 | if ($wgDatabase->tableExists("archive2")) { |
1625 | | - echo "Converting \"archive2\" back to normal archive table\n"; |
| 1624 | + wfOut( "Converting \"archive2\" back to normal archive table\n" ); |
1626 | 1625 | if ($wgDatabase->ruleExists("archive", "archive_insert")) { |
1627 | | - echo "Dropping rule \"archive_insert\"\n"; |
| 1626 | + wfOut( "Dropping rule \"archive_insert\"\n" ); |
1628 | 1627 | $wgDatabase->query("DROP RULE archive_insert ON archive"); |
1629 | 1628 | } |
1630 | 1629 | if ($wgDatabase->ruleExists("archive", "archive_delete")) { |
1631 | | - echo "Dropping rule \"archive_delete\"\n"; |
| 1630 | + wfOut( "Dropping rule \"archive_delete\"\n" ); |
1632 | 1631 | $wgDatabase->query("DROP RULE archive_delete ON archive"); |
1633 | 1632 | } |
1634 | 1633 | dbsource(archive("patch-remove-archive2.sql")); |
1635 | 1634 | } |
1636 | 1635 | else |
1637 | | - echo "... obsolete table \"archive2\" does not exist\n"; |
| 1636 | + wfOut( "... obsolete table \"archive2\" does not exist\n" ); |
1638 | 1637 | |
1639 | 1638 | foreach ($newcols as $nc) { |
1640 | 1639 | $fi = $wgDatabase->fieldInfo($nc[0], $nc[1]); |
1641 | 1640 | if (!is_null($fi)) { |
1642 | | - echo "... column \"$nc[0].$nc[1]\" already exists\n"; |
| 1641 | + wfOut( "... column \"$nc[0].$nc[1]\" already exists\n" ); |
1643 | 1642 | continue; |
1644 | 1643 | } |
1645 | 1644 | |
1646 | | - echo "Adding column \"$nc[0].$nc[1]\"\n"; |
| 1645 | + wfOut( "Adding column \"$nc[0].$nc[1]\"\n" ); |
1647 | 1646 | $wgDatabase->query("ALTER TABLE $nc[0] ADD $nc[1] $nc[2]"); |
1648 | 1647 | } |
1649 | 1648 | |
1650 | 1649 | foreach ($typechanges as $tc) { |
1651 | 1650 | $fi = $wgDatabase->fieldInfo($tc[0], $tc[1]); |
1652 | 1651 | if (is_null($fi)) { |
1653 | | - echo "... error: expected column $tc[0].$tc[1] to exist\n"; |
| 1652 | + wfOut( "... error: expected column $tc[0].$tc[1] to exist\n" ); |
1654 | 1653 | exit(1); |
1655 | 1654 | } |
1656 | 1655 | |
1657 | 1656 | if ($fi->type() === $tc[2]) |
1658 | | - echo "... column \"$tc[0].$tc[1]\" is already of type \"$tc[2]\"\n"; |
| 1657 | + wfOut( "... column \"$tc[0].$tc[1]\" is already of type \"$tc[2]\"\n" ); |
1659 | 1658 | else { |
1660 | | - echo "Changing column type of \"$tc[0].$tc[1]\" from \"{$fi->type()}\" to \"$tc[2]\"\n"; |
| 1659 | + wfOut( "Changing column type of \"$tc[0].$tc[1]\" from \"{$fi->type()}\" to \"$tc[2]\"\n" ); |
1661 | 1660 | $sql = "ALTER TABLE $tc[0] ALTER $tc[1] TYPE $tc[2]"; |
1662 | 1661 | if (strlen($tc[3])) { |
1663 | 1662 | $default = array(); |
— | — | @@ -1673,91 +1672,91 @@ |
1674 | 1673 | } |
1675 | 1674 | |
1676 | 1675 | if ($wgDatabase->fieldInfo('oldimage','oi_deleted')->type() !== 'smallint') { |
1677 | | - echo "Changing \"oldimage.oi_deleted\" to type \"smallint\"\n"; |
| 1676 | + wfOut( "Changing \"oldimage.oi_deleted\" to type \"smallint\"\n" ); |
1678 | 1677 | $wgDatabase->query( "ALTER TABLE oldimage ALTER oi_deleted DROP DEFAULT" ); |
1679 | 1678 | $wgDatabase->query( "ALTER TABLE oldimage ALTER oi_deleted TYPE SMALLINT USING (oi_deleted::smallint)" ); |
1680 | 1679 | $wgDatabase->query( "ALTER TABLE oldimage ALTER oi_deleted SET DEFAULT 0" ); |
1681 | 1680 | } |
1682 | 1681 | else |
1683 | | - echo "... column \"oldimage.oi_deleted\" is already of type \"smallint\"\n"; |
| 1682 | + wfOut( "... column \"oldimage.oi_deleted\" is already of type \"smallint\"\n" ); |
1684 | 1683 | |
1685 | 1684 | |
1686 | 1685 | foreach ($newindexes as $ni) { |
1687 | 1686 | if (pg_index_exists($ni[0], $ni[1])) { |
1688 | | - echo "... index \"$ni[1]\" on table \"$ni[0]\" already exists\n"; |
| 1687 | + wfOut( "... index \"$ni[1]\" on table \"$ni[0]\" already exists\n" ); |
1689 | 1688 | continue; |
1690 | 1689 | } |
1691 | | - echo "Creating index \"$ni[1]\" on table \"$ni[0]\" $ni[2]\n"; |
| 1690 | + wfOut( "Creating index \"$ni[1]\" on table \"$ni[0]\" $ni[2]\n" ); |
1692 | 1691 | $wgDatabase->query( "CREATE INDEX $ni[1] ON $ni[0] $ni[2]" ); |
1693 | 1692 | } |
1694 | 1693 | |
1695 | 1694 | foreach ($newrules as $nr) { |
1696 | 1695 | if ($wgDatabase->ruleExists($nr[0], $nr[1])) { |
1697 | | - echo "... rule \"$nr[1]\" on table \"$nr[0]\" already exists\n"; |
| 1696 | + wfOut( "... rule \"$nr[1]\" on table \"$nr[0]\" already exists\n" ); |
1698 | 1697 | continue; |
1699 | 1698 | } |
1700 | | - echo "Adding rule \"$nr[1]\" to table \"$nr[0]\"\n"; |
| 1699 | + wfOut( "Adding rule \"$nr[1]\" to table \"$nr[0]\"\n" ); |
1701 | 1700 | dbsource(archive($nr[2])); |
1702 | 1701 | } |
1703 | 1702 | |
1704 | 1703 | if ($wgDatabase->hasConstraint("oldimage_oi_name_fkey")) { |
1705 | | - echo "Making foriegn key on table \"oldimage\" (to image) a cascade delete\n"; |
| 1704 | + wfOut( "Making foriegn key on table \"oldimage\" (to image) a cascade delete\n" ); |
1706 | 1705 | $wgDatabase->query( "ALTER TABLE oldimage DROP CONSTRAINT oldimage_oi_name_fkey" ); |
1707 | 1706 | $wgDatabase->query( "ALTER TABLE oldimage ADD CONSTRAINT oldimage_oi_name_fkey_cascade ". |
1708 | 1707 | "FOREIGN KEY (oi_name) REFERENCES image(img_name) ON DELETE CASCADE" ); |
1709 | 1708 | } |
1710 | 1709 | else |
1711 | | - echo "... table \"oldimage\" has correct cascade delete foreign key to image\n"; |
| 1710 | + wfOut( "... table \"oldimage\" has correct cascade delete foreign key to image\n" ); |
1712 | 1711 | |
1713 | 1712 | if (!$wgDatabase->triggerExists("page", "page_deleted")) { |
1714 | | - echo "Adding function and trigger \"page_deleted\" to table \"page\"\n"; |
| 1713 | + wfOut( "Adding function and trigger \"page_deleted\" to table \"page\"\n" ); |
1715 | 1714 | dbsource(archive('patch-page_deleted.sql')); |
1716 | 1715 | } |
1717 | 1716 | else |
1718 | | - echo "... table \"page\" has \"page_deleted\" trigger\n"; |
| 1717 | + wfOut( "... table \"page\" has \"page_deleted\" trigger\n" ); |
1719 | 1718 | |
1720 | 1719 | $fi = $wgDatabase->fieldInfo("recentchanges", "rc_cur_id"); |
1721 | 1720 | if (!$fi->nullable()) { |
1722 | | - echo "Removing NOT NULL constraint from \"recentchanges.rc_cur_id\"\n"; |
| 1721 | + wfOut( "Removing NOT NULL constraint from \"recentchanges.rc_cur_id\"\n" ); |
1723 | 1722 | dbsource(archive('patch-rc_cur_id-not-null.sql')); |
1724 | 1723 | } |
1725 | 1724 | else |
1726 | | - echo "... column \"recentchanges.rc_cur_id\" has a NOT NULL constraint\n"; |
| 1725 | + wfOut( "... column \"recentchanges.rc_cur_id\" has a NOT NULL constraint\n" ); |
1727 | 1726 | |
1728 | 1727 | $pu = pg_describe_index("pagelink_unique"); |
1729 | 1728 | if (!is_null($pu) && ($pu[0] != "pl_from" || $pu[1] != "pl_namespace" || $pu[2] != "pl_title")) { |
1730 | | - echo "Dropping obsolete version of index \"pagelink_unique index\"\n"; |
| 1729 | + wfOut( "Dropping obsolete version of index \"pagelink_unique index\"\n" ); |
1731 | 1730 | $wgDatabase->query("DROP INDEX pagelink_unique"); |
1732 | 1731 | $pu = null; |
1733 | 1732 | } |
1734 | 1733 | else |
1735 | | - echo "... obsolete version of index \"pagelink_unique index\" does not exist\n"; |
| 1734 | + wfOut( "... obsolete version of index \"pagelink_unique index\" does not exist\n" ); |
1736 | 1735 | |
1737 | 1736 | if (is_null($pu)) { |
1738 | | - echo "Creating index \"pagelink_unique index\"\n"; |
| 1737 | + wfOut( "Creating index \"pagelink_unique index\"\n" ); |
1739 | 1738 | $wgDatabase->query("CREATE UNIQUE INDEX pagelink_unique ON pagelinks (pl_from,pl_namespace,pl_title)"); |
1740 | 1739 | } |
1741 | 1740 | else |
1742 | | - echo "... index \"pagelink_unique_index\" already exists\n"; |
| 1741 | + wfOut( "... index \"pagelink_unique_index\" already exists\n" ); |
1743 | 1742 | |
1744 | 1743 | if (pg_fkey_deltype("revision_rev_user_fkey") == 'r') { |
1745 | | - echo "... constraint \"revision_rev_user_fkey\" is ON DELETE RESTRICT\n"; |
| 1744 | + wfOut( "... constraint \"revision_rev_user_fkey\" is ON DELETE RESTRICT\n" ); |
1746 | 1745 | } |
1747 | 1746 | else { |
1748 | | - echo "Changing constraint \"revision_rev_user_fkey\" to ON DELETE RESTRICT\n"; |
| 1747 | + wfOut( "Changing constraint \"revision_rev_user_fkey\" to ON DELETE RESTRICT\n" ); |
1749 | 1748 | dbsource(archive('patch-revision_rev_user_fkey.sql')); |
1750 | 1749 | } |
1751 | 1750 | |
1752 | 1751 | # Fix ipb_address index |
1753 | 1752 | if (pg_index_exists('ipblocks', 'ipb_address' )) { |
1754 | | - echo "Removing deprecated index 'ipb_address'...\n"; |
| 1753 | + wfOut( "Removing deprecated index 'ipb_address'...\n" ); |
1755 | 1754 | $wgDatabase->query('DROP INDEX ipb_address'); |
1756 | 1755 | } |
1757 | 1756 | if (pg_index_exists('ipblocks', 'ipb_address_unique' )) { |
1758 | | - echo "... have ipb_address_unique\n"; |
| 1757 | + wfOut( "... have ipb_address_unique\n" ); |
1759 | 1758 | } |
1760 | 1759 | else { |
1761 | | - echo "Adding ipb_address_unique index\n"; |
| 1760 | + wfOut( "Adding ipb_address_unique index\n" ); |
1762 | 1761 | dbsource(archive('patch-ipb_address_unique.sql')); |
1763 | 1762 | } |
1764 | 1763 | |
— | — | @@ -1765,29 +1764,29 @@ |
1766 | 1765 | # Add missing extension tables |
1767 | 1766 | foreach ( $wgExtNewTables as $nt ) { |
1768 | 1767 | if ($wgDatabase->tableExists($nt[0])) { |
1769 | | - echo "... table \"$nt[0]\" already exists\n"; |
| 1768 | + wfOut( "... table \"$nt[0]\" already exists\n" ); |
1770 | 1769 | continue; |
1771 | 1770 | } |
1772 | | - echo "Creating table \"$nt[0]\"\n"; |
| 1771 | + wfOut( "Creating table \"$nt[0]\"\n" ); |
1773 | 1772 | dbsource($nt[1]); |
1774 | 1773 | } |
1775 | 1774 | # Add missing extension fields |
1776 | 1775 | foreach ( $wgExtPGNewFields as $nc ) { |
1777 | 1776 | $fi = $wgDatabase->fieldInfo($nc[0], $nc[1]); |
1778 | 1777 | if (!is_null($fi)) { |
1779 | | - echo "... column \"$nc[0].$nc[1]\" already exists\n"; |
| 1778 | + wfOut( "... column \"$nc[0].$nc[1]\" already exists\n" ); |
1780 | 1779 | continue; |
1781 | 1780 | } |
1782 | | - echo "Adding column \"$nc[0].$nc[1]\"\n"; |
| 1781 | + wfOut( "Adding column \"$nc[0].$nc[1]\"\n" ); |
1783 | 1782 | $wgDatabase->query( "ALTER TABLE $nc[0] ADD $nc[1] $nc[2]" ); |
1784 | 1783 | } |
1785 | 1784 | # Add missing extension indexes |
1786 | 1785 | foreach ( $wgExtNewIndexes as $ni ) { |
1787 | 1786 | if (pg_index_exists($ni[0], $ni[1])) { |
1788 | | - echo "... index \"$ni[1]\" on table \"$ni[0]\" already exists\n"; |
| 1787 | + wfOut( "... index \"$ni[1]\" on table \"$ni[0]\" already exists\n" ); |
1789 | 1788 | continue; |
1790 | 1789 | } |
1791 | | - echo "Creating index \"$ni[1]\" on table \"$ni[0]\"\n"; |
| 1790 | + wfOut( "Creating index \"$ni[1]\" on table \"$ni[0]\"\n" ); |
1792 | 1791 | dbsource($ni[2]); |
1793 | 1792 | } |
1794 | 1793 | |
Index: trunk/phase3/maintenance/userDupes.inc |
— | — | @@ -45,7 +45,7 @@ |
46 | 46 | $fname = 'UserDupes::hasUniqueIndex'; |
47 | 47 | $info = $this->db->indexInfo( 'user', 'user_name', $fname ); |
48 | 48 | 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" ); |
50 | 50 | return false; |
51 | 51 | } |
52 | 52 | |
— | — | @@ -92,11 +92,11 @@ |
93 | 93 | |
94 | 94 | $this->lock(); |
95 | 95 | |
96 | | - echo "Checking for duplicate accounts...\n"; |
| 96 | + wfOut( "Checking for duplicate accounts...\n" ); |
97 | 97 | $dupes = $this->getDupes(); |
98 | 98 | $count = count( $dupes ); |
99 | 99 | |
100 | | - echo "Found $count accounts with duplicate records on ".wfWikiID().".\n"; |
| 100 | + wfOut( "Found $count accounts with duplicate records on ".wfWikiID().".\n" ); |
101 | 101 | $this->trimmed = 0; |
102 | 102 | $this->reassigned = 0; |
103 | 103 | $this->failed = 0; |
— | — | @@ -106,34 +106,34 @@ |
107 | 107 | |
108 | 108 | $this->unlock(); |
109 | 109 | |
110 | | - echo "\n"; |
| 110 | + wfOut( "\n" ); |
111 | 111 | |
112 | 112 | if( $this->reassigned > 0 ) { |
113 | 113 | 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" ); |
115 | 115 | } 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" ); |
117 | 117 | } |
118 | 118 | } |
119 | 119 | |
120 | 120 | if( $this->trimmed > 0 ) { |
121 | 121 | 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" ); |
123 | 123 | } 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" ); |
125 | 125 | } |
126 | 126 | } |
127 | 127 | |
128 | 128 | 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" ); |
130 | 130 | return false; |
131 | 131 | } |
132 | 132 | |
133 | 133 | 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" ); |
135 | 135 | return true; |
136 | 136 | } 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" ); |
138 | 138 | return false; |
139 | 139 | } |
140 | 140 | } |
— | — | @@ -215,36 +215,36 @@ |
216 | 216 | |
217 | 217 | $firstRow = $this->db->fetchObject( $result ); |
218 | 218 | $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" ); |
220 | 220 | |
221 | 221 | while( $row = $this->db->fetchObject( $result ) ) { |
222 | 222 | $dupeId = $row->user_id; |
223 | | - echo "... dupe id $dupeId: "; |
| 223 | + wfOut( "... dupe id $dupeId: " ); |
224 | 224 | $edits = $this->editCount( $dupeId ); |
225 | 225 | if( $edits > 0 ) { |
226 | 226 | $this->reassigned++; |
227 | | - echo "has $edits edits! "; |
| 227 | + wfOut( "has $edits edits! " ); |
228 | 228 | if( $doDelete ) { |
229 | 229 | $this->reassignEdits( $dupeId, $firstId ); |
230 | 230 | $newEdits = $this->editCount( $dupeId ); |
231 | 231 | if( $newEdits == 0 ) { |
232 | | - echo "confirmed cleaned. "; |
| 232 | + wfOut( "confirmed cleaned. " ); |
233 | 233 | } else { |
234 | 234 | $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" ); |
236 | 236 | continue; |
237 | 237 | } |
238 | 238 | } else { |
239 | | - echo "(will need to reassign edits on fix)"; |
| 239 | + wfOut( "(will need to reassign edits on fix)" ); |
240 | 240 | } |
241 | 241 | } else { |
242 | | - echo "ok, no edits. "; |
| 242 | + wfOut( "ok, no edits. " ); |
243 | 243 | } |
244 | 244 | $this->trimmed++; |
245 | 245 | if( $doDelete ) { |
246 | 246 | $this->trimAccount( $dupeId ); |
247 | 247 | } |
248 | | - echo "\n"; |
| 248 | + wfOut( "\n" ); |
249 | 249 | } |
250 | 250 | $this->db->freeResult( $result ); |
251 | 251 | } |
— | — | @@ -306,12 +306,12 @@ |
307 | 307 | */ |
308 | 308 | function reassignEditsOn( $table, $field, $from, $to ) { |
309 | 309 | $fname = 'UserDupes::reassignEditsOn'; |
310 | | - echo "reassigning on $table... "; |
| 310 | + wfOut( "reassigning on $table... " ); |
311 | 311 | $this->db->update( $table, |
312 | 312 | array( $field => $to ), |
313 | 313 | array( $field => $from ), |
314 | 314 | $fname ); |
315 | | - echo "ok. "; |
| 315 | + wfOut( "ok. " ); |
316 | 316 | } |
317 | 317 | |
318 | 318 | /** |
— | — | @@ -321,9 +321,9 @@ |
322 | 322 | */ |
323 | 323 | function trimAccount( $userid ) { |
324 | 324 | $fname = 'UserDupes::trimAccount'; |
325 | | - echo "deleting..."; |
| 325 | + wfOut( "deleting..." ); |
326 | 326 | $this->db->delete( 'user', array( 'user_id' => $userid ), $fname ); |
327 | | - echo " ok"; |
| 327 | + wfOut( " ok" ); |
328 | 328 | } |
329 | 329 | |
330 | 330 | } |
Index: trunk/phase3/maintenance/populateParentId.inc |
— | — | @@ -3,11 +3,11 @@ |
4 | 4 | define( 'BATCH_SIZE', 200 ); |
5 | 5 | |
6 | 6 | function populate_rev_parent_id( $db ) { |
7 | | - echo "Populating rev_parent_id column\n"; |
| 7 | + wfOut( "Populating rev_parent_id column\n" ); |
8 | 8 | $start = $db->selectField( 'revision', 'MIN(rev_id)', false, __FUNCTION__ ); |
9 | 9 | $end = $db->selectField( 'revision', 'MAX(rev_id)', false, __FUNCTION__ ); |
10 | 10 | 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" ); |
12 | 12 | $db->insert( 'updatelog', |
13 | 13 | array( 'ul_key' => 'populate rev_parent_id' ), |
14 | 14 | __FUNCTION__, |
— | — | @@ -16,12 +16,12 @@ |
17 | 17 | } |
18 | 18 | # Do remaining chunk |
19 | 19 | $end += BATCH_SIZE - 1; |
20 | | - $blockStart = $start; |
21 | | - $blockEnd = $start + BATCH_SIZE - 1; |
| 20 | + $blockStart = intval( $start ); |
| 21 | + $blockEnd = intval( $start ) + BATCH_SIZE - 1; |
22 | 22 | $count = 0; |
23 | 23 | $changed = 0; |
24 | 24 | while( $blockEnd <= $end ) { |
25 | | - echo "...doing rev_id from $blockStart to $blockEnd\n"; |
| 25 | + wfOut( "...doing rev_id from $blockStart to $blockEnd\n" ); |
26 | 26 | $cond = "rev_id BETWEEN $blockStart AND $blockEnd"; |
27 | 27 | $res = $db->select( 'revision', |
28 | 28 | array('rev_id','rev_page','rev_timestamp','rev_parent_id'), |
— | — | @@ -36,14 +36,14 @@ |
37 | 37 | # as timestamp can only decrease and never loops with IDs (from parent to parent) |
38 | 38 | $previousID = $db->selectField( 'revision', 'rev_id', |
39 | 39 | array( 'rev_page' => $row->rev_page, 'rev_timestamp' => $row->rev_timestamp, |
40 | | - "rev_id < {$row->rev_id}" ), |
| 40 | + "rev_id < " . intval( $row->rev_id ) ), |
41 | 41 | __FUNCTION__, |
42 | 42 | array( 'ORDER BY' => 'rev_id DESC' ) ); |
43 | 43 | # If there are none, check the the highest ID with a lower timestamp |
44 | 44 | if( !$previousID ) { |
45 | 45 | # Get the highest older timestamp |
46 | 46 | $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 ) ), |
48 | 48 | __FUNCTION__, |
49 | 49 | array( 'ORDER BY' => 'rev_timestamp DESC' ) ); |
50 | 50 | # If there is one, let the highest rev ID win |
— | — | @@ -73,10 +73,10 @@ |
74 | 74 | __FUNCTION__, |
75 | 75 | 'IGNORE' ); |
76 | 76 | 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" ); |
78 | 78 | return true; |
79 | 79 | } else { |
80 | | - echo "Could not insert rev_parent_id population row.\n"; |
| 80 | + wfOut( "Could not insert rev_parent_id population row.\n" ); |
81 | 81 | return false; |
82 | 82 | } |
83 | 83 | } |
Index: trunk/phase3/maintenance/convertLinks.inc |
— | — | @@ -9,11 +9,11 @@ |
10 | 10 | function convertLinks() { |
11 | 11 | global $wgDBtype; |
12 | 12 | if( $wgDBtype == 'postgres' ) { |
13 | | - print "Links table already ok on Postgres.\n"; |
| 13 | + wfOut( "Links table already ok on Postgres.\n" ); |
14 | 14 | return; |
15 | 15 | } |
16 | 16 | |
17 | | - print "Converting links table to ID-ID...\n"; |
| 17 | + wfOut( "Converting links table to ID-ID...\n" ); |
18 | 18 | |
19 | 19 | global $wgLang, $wgDBserver, $wgDBadminuser, $wgDBadminpassword, $wgDBname; |
20 | 20 | global $noKeys, $logPerformance, $fh; |
— | — | @@ -48,7 +48,7 @@ |
49 | 49 | |
50 | 50 | $res = $dbw->query( "SELECT l_from FROM $links LIMIT 1" ); |
51 | 51 | if ( $dbw->fieldType( $res, 0 ) == "int" ) { |
52 | | - print "Schema already converted\n"; |
| 52 | + wfOut( "Schema already converted\n" ); |
53 | 53 | return; |
54 | 54 | } |
55 | 55 | |
— | — | @@ -58,13 +58,13 @@ |
59 | 59 | $dbw->freeResult( $res ); |
60 | 60 | |
61 | 61 | if ( $numRows == 0 ) { |
62 | | - print "Updating schema (no rows to convert)...\n"; |
| 62 | + wfOut( "Updating schema (no rows to convert)...\n" ); |
63 | 63 | createTempTable(); |
64 | 64 | } else { |
65 | 65 | if ( $logPerformance ) { $fh = fopen ( $perfLogFilename, "w" ); } |
66 | 66 | $baseTime = $startTime = getMicroTime(); |
67 | 67 | # Create a title -> cur_id map |
68 | | - print "Loading IDs from $cur table...\n"; |
| 68 | + wfOut( "Loading IDs from $cur table...\n" ); |
69 | 69 | performanceLog ( "Reading $numRows rows from cur table...\n" ); |
70 | 70 | performanceLog ( "rows read vs seconds elapsed:\n" ); |
71 | 71 | |
— | — | @@ -82,13 +82,13 @@ |
83 | 83 | if ($reportCurReadProgress) { |
84 | 84 | if (($curRowsRead % $curReadReportInterval) == 0) { |
85 | 85 | 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" ); |
87 | 87 | } |
88 | 88 | } |
89 | 89 | } |
90 | 90 | $dbw->freeResult( $res ); |
91 | 91 | $dbw->bufferResults( true ); |
92 | | - print "Finished loading IDs.\n\n"; |
| 92 | + wfOut( "Finished loading IDs.\n\n" ); |
93 | 93 | performanceLog( "Took " . (getMicroTime() - $baseTime) . " seconds to load IDs.\n\n" ); |
94 | 94 | #-------------------------------------------------------------------- |
95 | 95 | |
— | — | @@ -97,7 +97,7 @@ |
98 | 98 | createTempTable(); |
99 | 99 | performanceLog( "Resetting timer.\n\n" ); |
100 | 100 | $baseTime = getMicroTime(); |
101 | | - print "Processing $numRows rows from $links table...\n"; |
| 101 | + wfOut( "Processing $numRows rows from $links table...\n" ); |
102 | 102 | performanceLog( "Processing $numRows rows from $links table...\n" ); |
103 | 103 | performanceLog( "rows inserted vs seconds elapsed:\n" ); |
104 | 104 | |
— | — | @@ -127,19 +127,19 @@ |
128 | 128 | } |
129 | 129 | } |
130 | 130 | $dbw->freeResult($res); |
131 | | - #print "rowOffset: $rowOffset\ttuplesAdded: $tuplesAdded\tnumBadLinks: $numBadLinks\n"; |
| 131 | + #wfOut( "rowOffset: $rowOffset\ttuplesAdded: $tuplesAdded\tnumBadLinks: $numBadLinks\n" ); |
132 | 132 | if ( $tuplesAdded != 0 ) { |
133 | 133 | if ($reportLinksConvProgress) { |
134 | | - print "Inserting $tuplesAdded tuples into $links_temp..."; |
| 134 | + wfOut( "Inserting $tuplesAdded tuples into $links_temp..." ); |
135 | 135 | } |
136 | 136 | $dbw->query( implode("",$sqlWrite) ); |
137 | 137 | $totalTuplesInserted += $tuplesAdded; |
138 | 138 | if ($reportLinksConvProgress) |
139 | | - print " done. Total $totalTuplesInserted tuples inserted.\n"; |
| 139 | + wfOut( " done. Total $totalTuplesInserted tuples inserted.\n" ); |
140 | 140 | performanceLog( $totalTuplesInserted . " " . (getMicroTime() - $baseTime) . "\n" ); |
141 | 141 | } |
142 | 142 | } |
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" ); |
144 | 144 | performanceLog( "$totalTuplesInserted valid titles and $numBadLinks invalid titles were processed.\n" ); |
145 | 145 | performanceLog( "Total execution time: " . (getMicroTime() - $startTime) . " seconds.\n" ); |
146 | 146 | if ( $logPerformance ) { fclose ( $fh ); } |
— | — | @@ -149,25 +149,25 @@ |
150 | 150 | if ( $overwriteLinksTable ) { |
151 | 151 | $dbConn = Database::newFromParams( $wgDBserver, $wgDBadminuser, $wgDBadminpassword, $wgDBname ); |
152 | 152 | if (!($dbConn->isOpen())) { |
153 | | - print "Opening connection to database failed.\n"; |
| 153 | + wfOut( "Opening connection to database failed.\n" ); |
154 | 154 | return; |
155 | 155 | } |
156 | 156 | # 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..." ); |
158 | 158 | $dbConn->query( "DROP TABLE IF EXISTS $links_backup", DB_MASTER); |
159 | | - print " done.\n"; |
| 159 | + wfOut( " done.\n" ); |
160 | 160 | |
161 | 161 | # 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'..." ); |
163 | 163 | $dbConn->query( "RENAME TABLE links TO $links_backup, $links_temp TO $links", DB_MASTER ); |
164 | | - print " done.\n\n"; |
| 164 | + wfOut( " done.\n\n" ); |
165 | 165 | |
166 | 166 | $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" ); |
169 | 169 | } 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" ); |
172 | 172 | } |
173 | 173 | } |
174 | 174 | |
— | — | @@ -179,16 +179,16 @@ |
180 | 180 | $dbConn = Database::newFromParams( $wgDBserver, $wgDBadminuser, $wgDBadminpassword, $wgDBname ); |
181 | 181 | |
182 | 182 | if (!($dbConn->isOpen())) { |
183 | | - print "Opening connection to database failed.\n"; |
| 183 | + wfOut( "Opening connection to database failed.\n" ); |
184 | 184 | return; |
185 | 185 | } |
186 | 186 | $links_temp = $dbConn->tableName( 'links_temp' ); |
187 | 187 | |
188 | | - print "Dropping temporary links table if it exists..."; |
| 188 | + wfOut( "Dropping temporary links table if it exists..." ); |
189 | 189 | $dbConn->query( "DROP TABLE IF EXISTS $links_temp"); |
190 | | - print " done.\n"; |
| 190 | + wfOut( " done.\n" ); |
191 | 191 | |
192 | | - print "Creating temporary links table..."; |
| 192 | + wfOut( "Creating temporary links table..." ); |
193 | 193 | if ( $noKeys ) { |
194 | 194 | $dbConn->query( "CREATE TABLE $links_temp ( " . |
195 | 195 | "l_from int(8) unsigned NOT NULL default '0', " . |
— | — | @@ -200,7 +200,7 @@ |
201 | 201 | "UNIQUE KEY l_from(l_from,l_to), " . |
202 | 202 | "KEY (l_to))"); |
203 | 203 | } |
204 | | - print " done.\n\n"; |
| 204 | + wfOut( " done.\n\n" ); |
205 | 205 | } |
206 | 206 | |
207 | 207 | function performanceLog( $text ) { |
Index: trunk/phase3/includes/GlobalFunctions.php |
— | — | @@ -2955,6 +2955,21 @@ |
2956 | 2956 | } |
2957 | 2957 | } |
2958 | 2958 | |
| 2959 | +/** |
| 2960 | + * Output some plain text in command-line mode or in the installer (updaters.inc). |
| 2961 | + * Do not use it in any other context, its behaviour is subject to change. |
| 2962 | + */ |
| 2963 | +function wfOut( $s ) { |
| 2964 | + static $lineStarted = false; |
| 2965 | + global $wgCommandLineMode; |
| 2966 | + if ( $wgCommandLineMode && !defined( 'MEDIAWIKI_INSTALL' ) ) { |
| 2967 | + echo $s; |
| 2968 | + } else { |
| 2969 | + echo htmlspecialchars( $s ); |
| 2970 | + } |
| 2971 | + flush(); |
| 2972 | +} |
| 2973 | + |
2959 | 2974 | /** Generate a random 32-character hexadecimal token. |
2960 | 2975 | * @param mixed $salt Some sort of salt, if necessary, to add to random characters before hashing. |
2961 | 2976 | */ |
Index: trunk/phase3/config/index.php |
— | — | @@ -92,7 +92,8 @@ |
93 | 93 | <html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en" lang="en" dir="ltr"> |
94 | 94 | <head> |
95 | 95 | <meta http-equiv="Content-type" content="text/html; charset=utf-8" /> |
96 | | - <title>MediaWiki <?php echo( $wgVersion ); ?> Installation</title> |
| 96 | + <meta name="robots" content="noindex,nofollow"/> |
| 97 | + <title>MediaWiki <?php echo htmlspecialchars( $wgVersion ); ?> Installation</title> |
97 | 98 | <style type="text/css"> |
98 | 99 | |
99 | 100 | @import "../skins/monobook/main.css"; |
— | — | @@ -210,7 +211,7 @@ |
211 | 212 | <div id="content"> |
212 | 213 | <div id="bodyContent"> |
213 | 214 | |
214 | | -<h1>MediaWiki <?php print $wgVersion ?> Installation</h1> |
| 215 | +<h1>MediaWiki <?php print htmlspecialchars( $wgVersion ) ?> Installation</h1> |
215 | 216 | |
216 | 217 | <?php |
217 | 218 | $mainListOpened = false; # Is the main list (environement checking) opend ? Used by dieout |
— | — | @@ -310,7 +311,7 @@ |
311 | 312 | install_version_checks(); |
312 | 313 | $self = 'Installer'; # Maintenance script name, to please Setup.php |
313 | 314 | |
314 | | -print "<li>PHP " . phpversion() . " installed</li>\n"; |
| 315 | +print "<li>PHP " . htmlspecialchars( phpversion() ) . " installed</li>\n"; |
315 | 316 | |
316 | 317 | error_reporting( 0 ); |
317 | 318 | $phpdatabases = array(); |
— | — | @@ -410,7 +411,7 @@ |
411 | 412 | $conf->safeMode = false; |
412 | 413 | } |
413 | 414 | |
414 | | -$sapi = php_sapi_name(); |
| 415 | +$sapi = htmlspecialchars( php_sapi_name() ); |
415 | 416 | print "<li>PHP server API is $sapi; "; |
416 | 417 | $script = defined('MW_INSTALL_PHP5_EXT') ? 'index.php5' : 'index.php'; |
417 | 418 | if( $wgUsePathInfo ) { |
— | — | @@ -593,6 +594,9 @@ |
594 | 595 | : $_SERVER["SERVER_ADMIN"]; |
595 | 596 | $conf->EmergencyContact = importPost( "EmergencyContact", $defaultEmail ); |
596 | 597 | $conf->DBtype = importPost( "DBtype", $DefaultDBtype ); |
| 598 | + if ( !isset( $ourdb[$conf->DBtype] ) ) { |
| 599 | + $conf->DBtype = $DefaultDBtype; |
| 600 | + } |
597 | 601 | |
598 | 602 | $conf->DBserver = importPost( "DBserver", "localhost" ); |
599 | 603 | $conf->DBname = importPost( "DBname", "wikidb" ); |
— | — | @@ -652,6 +656,8 @@ |
653 | 657 | } |
654 | 658 | if( !preg_match( '/^[A-Za-z_0-9]*$/', $conf->DBprefix ) ) { |
655 | 659 | $errs["DBprefix"] = "Invalid table prefix"; |
| 660 | +} else { |
| 661 | + untaint( $conf->DBprefix, TC_MYSQL ); |
656 | 662 | } |
657 | 663 | |
658 | 664 | error_reporting( E_ALL ); |
— | — | @@ -728,7 +734,7 @@ |
729 | 735 | /* Test memcached servers */ |
730 | 736 | |
731 | 737 | if ( $conf->Shm == 'memcached' && $conf->MCServers ) { |
732 | | - $conf->MCServerArray = array_map( 'trim', explode( ',', $conf->MCServers ) ); |
| 738 | + $conf->MCServerArray = wfArrayMap( 'trim', explode( ',', $conf->MCServers ) ); |
733 | 739 | foreach ( $conf->MCServerArray as $server ) { |
734 | 740 | $error = testMemcachedServer( $server ); |
735 | 741 | if ( $error ) { |
— | — | @@ -781,7 +787,7 @@ |
782 | 788 | $errs["DBtype"] = "Unknown database type '$conf->DBtype'"; |
783 | 789 | continue; |
784 | 790 | } |
785 | | - print "<li>Database type: {$conf->DBtypename}</li>\n"; |
| 791 | + print "<li>Database type: " . htmlspecialchars( $conf->DBtypename ) . "</li>\n"; |
786 | 792 | $dbclass = 'Database'.ucfirst($conf->DBtype); |
787 | 793 | $wgDBtype = $conf->DBtype; |
788 | 794 | $wgDBadminuser = "root"; |
— | — | @@ -812,7 +818,7 @@ |
813 | 819 | |
814 | 820 | $wgTitle = Title::newFromText( "Installation script" ); |
815 | 821 | error_reporting( E_ALL ); |
816 | | - print "<li>Loading class: $dbclass</li>\n"; |
| 822 | + print "<li>Loading class: " . htmlspecialchars( $dbclass ) . "</li>\n"; |
817 | 823 | $dbc = new $dbclass; |
818 | 824 | |
819 | 825 | if( $conf->DBtype == 'mysql' ) { |
— | — | @@ -836,7 +842,7 @@ |
837 | 843 | } |
838 | 844 | |
839 | 845 | # Attempt to connect |
840 | | - echo( "<li>Attempting to connect to database server as $db_user..." ); |
| 846 | + echo( "<li>Attempting to connect to database server as " . htmlspecialchars( $db_user ) . "..." ); |
841 | 847 | $wgDatabase = Database::newFromParams( $wgDBserver, $db_user, $db_pass, '', 1 ); |
842 | 848 | |
843 | 849 | # Check the connection and respond to errors |
— | — | @@ -871,7 +877,7 @@ |
872 | 878 | case 2003: |
873 | 879 | default: |
874 | 880 | # General connection problem |
875 | | - echo( "failed with error [$errno] $errtx.</li>\n" ); |
| 881 | + echo( htmlspecialchars( "failed with error [$errno] $errtx." ) . "</li>\n" ); |
876 | 882 | $errs["DBserver"] = "Connection failed"; |
877 | 883 | break; |
878 | 884 | } # switch |
— | — | @@ -888,10 +894,11 @@ |
889 | 895 | $db_pass = $wgDBpassword; |
890 | 896 | } |
891 | 897 | |
892 | | - echo( "<li>Attempting to connect to database \"$wgDBname\" as \"$db_user\"..." ); |
| 898 | + echo( "<li>Attempting to connect to database \"" . htmlspecialchars( $wgDBname ) . |
| 899 | + "\" as \"" . htmlspecialchars( $db_user ) . "\"..." ); |
893 | 900 | $wgDatabase = $dbc->newFromParams($wgDBserver, $db_user, $db_pass, $wgDBname, 1); |
894 | 901 | if (!$wgDatabase->isOpen()) { |
895 | | - print " error: " . $wgDatabase->lastError() . "</li>\n"; |
| 902 | + print " error: " . htmlspecialchars( $wgDatabase->lastError() ) . "</li>\n"; |
896 | 903 | } else { |
897 | 904 | $myver = $wgDatabase->getServerVersion(); |
898 | 905 | } |
— | — | @@ -904,10 +911,11 @@ |
905 | 912 | // Changed !mysql to postgres check since it seems to only apply to postgres |
906 | 913 | if( $useRoot && $conf->DBtype == 'postgres' ) { |
907 | 914 | $wgDBsuperuser = $conf->RootUser; |
908 | | - echo( "<li>Attempting to connect to database \"postgres\" as superuser \"$wgDBsuperuser\"..." ); |
| 915 | + echo( "<li>Attempting to connect to database \"postgres\" as superuser \"" . |
| 916 | + htmlspecialchars( $wgDBsuperuser ) . "\"..." ); |
909 | 917 | $wgDatabase = $dbc->newFromParams($wgDBserver, $wgDBsuperuser, $conf->RootPW, "postgres", 1); |
910 | 918 | if (!$wgDatabase->isOpen()) { |
911 | | - print " error: " . $wgDatabase->lastError() . "</li>\n"; |
| 919 | + print " error: " . htmlspecialchars( $wgDatabase->lastError() ) . "</li>\n"; |
912 | 920 | $errs["DBserver"] = "Could not connect to database as superuser"; |
913 | 921 | $errs["RootUser"] = "Check username"; |
914 | 922 | $errs["RootPW"] = "and password"; |
— | — | @@ -915,10 +923,11 @@ |
916 | 924 | } |
917 | 925 | $wgDatabase->initial_setup($conf->RootPW, 'postgres'); |
918 | 926 | } |
919 | | - echo( "<li>Attempting to connect to database \"$wgDBname\" as \"$wgDBuser\"..." ); |
| 927 | + echo( "<li>Attempting to connect to database \"" . htmlspecialchars( $wgDBname ) . |
| 928 | + "\" as \"" . htmlspecialchars( $wgDBuser ) . "\"..." ); |
920 | 929 | $wgDatabase = $dbc->newFromParams($wgDBserver, $wgDBuser, $wgDBpassword, $wgDBname, 1); |
921 | 930 | if (!$wgDatabase->isOpen()) { |
922 | | - print " error: " . $wgDatabase->lastError() . "</li>\n"; |
| 931 | + print " error: " . htmlspecialchars( $wgDatabase->lastError() ) . "</li>\n"; |
923 | 932 | } else { |
924 | 933 | $myver = $wgDatabase->getServerVersion(); |
925 | 934 | } |
— | — | @@ -930,7 +939,7 @@ |
931 | 940 | continue; |
932 | 941 | } |
933 | 942 | |
934 | | - print "<li>Connected to {$conf->DBtype} $myver"; |
| 943 | + print "<li>Connected to " . htmlspecialchars( "{$conf->DBtype} $myver" ); |
935 | 944 | if ($conf->DBtype == 'mysql') { |
936 | 945 | if( version_compare( $myver, "4.0.14" ) < 0 ) { |
937 | 946 | print "</li>\n"; |
— | — | @@ -1017,15 +1026,19 @@ |
1018 | 1027 | } |
1019 | 1028 | } |
1020 | 1029 | if ( $existingSchema && $existingSchema != $conf->DBschema ) { |
1021 | | - print "<li><strong>Warning:</strong> you requested the {$conf->DBschema} schema, " . |
1022 | | - "but the existing database has the $existingSchema schema. This upgrade script ". |
1023 | | - "can't convert it, so it will remain $existingSchema.</li>\n"; |
| 1030 | + $encExisting = htmlspecialchars( $existingSchema ); |
| 1031 | + $encRequested = htmlspecialchars( $conf->DBschema ); |
| 1032 | + print "<li><strong>Warning:</strong> you requested the $encRequested schema, " . |
| 1033 | + "but the existing database has the $encExisting schema. This upgrade script ". |
| 1034 | + "can't convert it, so it will remain $encExisting.</li>\n"; |
1024 | 1035 | $conf->setSchema( $existingSchema, $conf->DBengine ); |
1025 | 1036 | } |
1026 | 1037 | if ( $existingEngine && $existingEngine != $conf->DBengine ) { |
1027 | | - print "<li><strong>Warning:</strong> you requested the {$conf->DBengine} storage " . |
1028 | | - "engine, but the existing database uses the $existingEngine engine. This upgrade " . |
1029 | | - "script can't convert it, so it will remain $existingEngine.</li>\n"; |
| 1038 | + $encExisting = htmlspecialchars( $existingEngine ); |
| 1039 | + $encRequested = htmlspecialchars( $conf->DBengine ); |
| 1040 | + print "<li><strong>Warning:</strong> you requested the $encRequested storage " . |
| 1041 | + "engine, but the existing database uses the $encExisting engine. This upgrade " . |
| 1042 | + "script can't convert it, so it will remain $encExisting.</li>\n"; |
1030 | 1043 | $conf->setSchema( $conf->DBschema, $existingEngine ); |
1031 | 1044 | } |
1032 | 1045 | } |
— | — | @@ -1066,7 +1079,8 @@ |
1067 | 1080 | } |
1068 | 1081 | $wgDatabase->freeResult( $res ); |
1069 | 1082 | if ( !$found && $conf->DBengine != 'MyISAM' ) { |
1070 | | - echo "<li><strong>Warning:</strong> {$conf->DBengine} storage engine not available, " . |
| 1083 | + echo "<li><strong>Warning:</strong> " . htmlspecialchars( $conf->DBengine ) . |
| 1084 | + " storage engine not available, " . |
1071 | 1085 | "using MyISAM instead</li>\n"; |
1072 | 1086 | $conf->setSchema( $conf->DBschema, 'MyISAM' ); |
1073 | 1087 | } |
— | — | @@ -1105,10 +1119,10 @@ |
1106 | 1120 | if( $wgDatabase2->isOpen() ) { |
1107 | 1121 | # Nope, just close the test connection and continue |
1108 | 1122 | $wgDatabase2->close(); |
1109 | | - echo( "<li>User $wgDBuser exists. Skipping grants.</li>\n" ); |
| 1123 | + echo( "<li>User " . htmlspecialchars( $wgDBuser ) . " exists. Skipping grants.</li>\n" ); |
1110 | 1124 | } else { |
1111 | 1125 | # Yes, so run the grants |
1112 | | - echo( "<li>Granting user permissions to $wgDBuser on $wgDBname..." ); |
| 1126 | + echo( "<li>" . htmlspecialchars( "Granting user permissions to $wgDBuser on $wgDBname..." ) ); |
1113 | 1127 | dbsource( "../maintenance/users.sql", $wgDatabase ); |
1114 | 1128 | echo( "success.</li>\n" ); |
1115 | 1129 | } |
— | — | @@ -1213,7 +1227,9 @@ |
1214 | 1228 | $list = getLanguageList(); |
1215 | 1229 | foreach( $list as $code => $name ) { |
1216 | 1230 | $sel = ($code == $conf->LanguageCode) ? 'selected="selected"' : ''; |
1217 | | - echo "\n\t\t<option value=\"$code\" $sel>$name</option>"; |
| 1231 | + $encCode = htmlspecialchars( $code ); |
| 1232 | + $encName = htmlspecialchars( $name ); |
| 1233 | + echo "\n\t\t<option value=\"$encCode\" $sel>$encName</option>"; |
1218 | 1234 | } |
1219 | 1235 | echo "\n"; |
1220 | 1236 | ?> |
— | — | @@ -1380,7 +1396,11 @@ |
1381 | 1397 | <div class="config-section"> |
1382 | 1398 | <div class="config-input"> |
1383 | 1399 | <label class='column'>Database type:</label> |
1384 | | -<?php if (isset($errs['DBpicktype'])) print "\t<span class='error'>$errs[DBpicktype]</span>\n"; ?> |
| 1400 | +<?php |
| 1401 | + if (isset($errs['DBpicktype'])) { |
| 1402 | + print "\t<span class='error'>" . htmlspecialchars( $errs[DBpicktype] ) . "</span>\n"; |
| 1403 | + } |
| 1404 | +?> |
1385 | 1405 | <ul class='plain'><?php |
1386 | 1406 | database_picker($conf); |
1387 | 1407 | ?></ul> |
— | — | @@ -1524,7 +1544,7 @@ |
1525 | 1545 | </div> |
1526 | 1546 | </form> |
1527 | 1547 | <script type="text/javascript"> |
1528 | | -window.onload = toggleDBarea('<?php echo $conf->DBtype; ?>', |
| 1548 | +window.onload = toggleDBarea('<?php echo htmlspecialchars( Xml::encodeJsVar( $conf->DBtype ) ); ?>', |
1529 | 1549 | <?php |
1530 | 1550 | ## If they passed in a root user name, don't populate it on page load |
1531 | 1551 | echo strlen(importPost('RootUser', '')) ? 0 : 1; |
— | — | @@ -1656,7 +1676,7 @@ |
1657 | 1677 | } |
1658 | 1678 | |
1659 | 1679 | # Add slashes to strings for double quoting |
1660 | | - $slconf = array_map( "escapePhpString", get_object_vars( $conf ) ); |
| 1680 | + $slconf = wfArrayMap( "escapePhpString", get_object_vars( $conf ) ); |
1661 | 1681 | if( $conf->License == 'gfdl1_2' || $conf->License == 'pd' || $conf->License == 'gfdl1_3' ) { |
1662 | 1682 | # Needs literal string interpolation for the current style path |
1663 | 1683 | $slconf['RightsIcon'] = $conf->RightsIcon; |
— | — | @@ -1841,6 +1861,7 @@ |
1842 | 1862 | } else { |
1843 | 1863 | $retval = $default; |
1844 | 1864 | } |
| 1865 | + taint( $retval ); |
1845 | 1866 | return $retval; |
1846 | 1867 | } |
1847 | 1868 | |
— | — | @@ -1856,10 +1877,8 @@ |
1857 | 1878 | return importVar( $_REQUEST, $name, $default ); |
1858 | 1879 | } |
1859 | 1880 | |
1860 | | -$radioCount = 0; |
1861 | | - |
1862 | 1881 | function aField( &$conf, $field, $text, $type = "text", $value = "", $onclick = '' ) { |
1863 | | - global $radioCount; |
| 1882 | + static $radioCount = 0; |
1864 | 1883 | if( $type != "" ) { |
1865 | 1884 | $xtype = "type=\"$type\""; |
1866 | 1885 | } else { |
— | — | @@ -1899,7 +1918,9 @@ |
1900 | 1919 | } |
1901 | 1920 | |
1902 | 1921 | global $errs; |
1903 | | - if(isset($errs[$field])) echo "<span class='error'>" . $errs[$field] . "</span>\n"; |
| 1922 | + if(isset($errs[$field])) { |
| 1923 | + echo "<span class='error'>" . htmlspecialchars( $errs[$field] ) . "</span>\n"; |
| 1924 | + } |
1904 | 1925 | } |
1905 | 1926 | |
1906 | 1927 | function getLanguageList() { |
— | — | @@ -2042,7 +2063,7 @@ |
2043 | 2064 | return false; |
2044 | 2065 | } |
2045 | 2066 | |
2046 | | - $lines = array_map( 'trim', $lines ); |
| 2067 | + $lines = wfArrayMap( 'trim', $lines ); |
2047 | 2068 | $candidatesByLocale = array(); |
2048 | 2069 | $candidatesByLang = array(); |
2049 | 2070 | foreach ( $lines as $line ) { |
— | — | @@ -2086,6 +2107,17 @@ |
2087 | 2108 | return false; |
2088 | 2109 | } |
2089 | 2110 | |
| 2111 | +function wfArrayMap( $function, $input ) { |
| 2112 | + $ret = array_map( $function, $input ); |
| 2113 | + foreach ( $ret as $key => $value ) { |
| 2114 | + $taint = istainted( $input[$key] ); |
| 2115 | + if ( $taint ) { |
| 2116 | + taint( $ret[$key], $taint ); |
| 2117 | + } |
| 2118 | + } |
| 2119 | + return $ret; |
| 2120 | +} |
| 2121 | + |
2090 | 2122 | ?> |
2091 | 2123 | |
2092 | 2124 | <div class="license"> |