Index: branches/REL1_14/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: branches/REL1_14/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: branches/REL1_14/phase3/maintenance/updaters.inc |
— | — | @@ -176,11 +176,11 @@ |
177 | 177 | global $wgDatabase; |
178 | 178 | if ( $wgDatabase->tableExists( $from ) ) { |
179 | 179 | if ( $wgDatabase->tableExists( $to ) ) { |
180 | | - echo "...can't move table $from to $to, $to already exists.\n"; |
| 180 | + wfOut( "...can't move table $from to $to, $to already exists.\n" ); |
181 | 181 | } else { |
182 | | - echo "Moving table $from to $to..."; |
| 182 | + wfOut( "Moving table $from to $to..." ); |
183 | 183 | dbsource( archive($patch), $wgDatabase ); |
184 | | - echo "ok\n"; |
| 184 | + wfOut( "ok\n" ); |
185 | 185 | } |
186 | 186 | } else { |
187 | 187 | // Source table does not exist |
— | — | @@ -192,47 +192,47 @@ |
193 | 193 | function add_table( $name, $patch, $fullpath=false ) { |
194 | 194 | global $wgDatabase; |
195 | 195 | if ( $wgDatabase->tableExists( $name ) ) { |
196 | | - echo "...$name table already exists.\n"; |
| 196 | + wfOut( "...$name table already exists.\n" ); |
197 | 197 | } else { |
198 | | - echo "Creating $name table..."; |
| 198 | + wfOut( "Creating $name table..." ); |
199 | 199 | if( $fullpath ) { |
200 | 200 | dbsource( $patch, $wgDatabase ); |
201 | 201 | } else { |
202 | 202 | dbsource( archive($patch), $wgDatabase ); |
203 | 203 | } |
204 | | - echo "ok\n"; |
| 204 | + wfOut( "ok\n" ); |
205 | 205 | } |
206 | 206 | } |
207 | 207 | |
208 | 208 | function add_field( $table, $field, $patch, $fullpath=false ) { |
209 | 209 | global $wgDatabase; |
210 | 210 | if ( !$wgDatabase->tableExists( $table ) ) { |
211 | | - echo "...$table table does not exist, skipping new field patch\n"; |
| 211 | + wfOut( "...$table table does not exist, skipping new field patch\n" ); |
212 | 212 | } elseif ( $wgDatabase->fieldExists( $table, $field ) ) { |
213 | | - echo "...have $field field in $table table.\n"; |
| 213 | + wfOut( "...have $field field in $table table.\n" ); |
214 | 214 | } else { |
215 | | - echo "Adding $field field to table $table..."; |
| 215 | + wfOut( "Adding $field field to table $table..." ); |
216 | 216 | if( $fullpath ) { |
217 | 217 | dbsource( $patch, $wgDatabase ); |
218 | 218 | } else { |
219 | 219 | dbsource( archive($patch), $wgDatabase ); |
220 | 220 | } |
221 | | - echo "ok\n"; |
| 221 | + wfOut( "ok\n" ); |
222 | 222 | } |
223 | 223 | } |
224 | 224 | |
225 | 225 | function add_index( $table, $index, $patch, $fullpath=false ) { |
226 | 226 | global $wgDatabase; |
227 | 227 | if( $wgDatabase->indexExists( $table, $index ) ) { |
228 | | - echo "...$index key already set on $table table.\n"; |
| 228 | + wfOut( "...$index key already set on $table table.\n" ); |
229 | 229 | } else { |
230 | | - echo "Adding $index key to table $table... "; |
| 230 | + wfOut( "Adding $index key to table $table... " ); |
231 | 231 | if( $fullpath ) { |
232 | 232 | dbsource( $patch, $wgDatabase ); |
233 | 233 | } else { |
234 | 234 | dbsource( archive($patch), $wgDatabase ); |
235 | 235 | } |
236 | | - echo "ok\n"; |
| 236 | + wfOut( "ok\n" ); |
237 | 237 | } |
238 | 238 | } |
239 | 239 | |
— | — | @@ -248,11 +248,11 @@ |
249 | 249 | |
250 | 250 | global $wgDatabase; |
251 | 251 | $fname = "Update script: update_passwords()"; |
252 | | - print "\nIt appears that you need to update the user passwords in your\n" . |
| 252 | + wfOut( "\nIt appears that you need to update the user passwords in your\n" . |
253 | 253 | "database. If you have already done this (if you've run this update\n" . |
254 | 254 | "script once before, for example), doing so again will make all your\n" . |
255 | 255 | "user accounts inaccessible, so be sure you only do this once.\n" . |
256 | | - "Update user passwords? (yes/no)"; |
| 256 | + "Update user passwords? (yes/no)" ); |
257 | 257 | |
258 | 258 | $resp = readconsole(); |
259 | 259 | if ( ! ( "Y" == $resp{0} || "y" == $resp{0} ) ) { return; } |
— | — | @@ -275,15 +275,15 @@ |
276 | 276 | # Check that interwiki table exists; if it doesn't source it |
277 | 277 | global $wgDatabase, $IP; |
278 | 278 | if( $wgDatabase->tableExists( "interwiki" ) ) { |
279 | | - echo "...already have interwiki table\n"; |
| 279 | + wfOut( "...already have interwiki table\n" ); |
280 | 280 | return true; |
281 | 281 | } |
282 | | - echo "Creating interwiki table: "; |
| 282 | + wfOut( "Creating interwiki table: " ); |
283 | 283 | dbsource( archive("patch-interwiki.sql") ); |
284 | | - echo "ok\n"; |
285 | | - echo "Adding default interwiki definitions: "; |
| 284 | + wfOut( "ok\n" ); |
| 285 | + wfOut( "Adding default interwiki definitions: " ); |
286 | 286 | dbsource( "$IP/maintenance/interwiki.sql" ); |
287 | | - echo "ok\n"; |
| 287 | + wfOut( "ok\n" ); |
288 | 288 | } |
289 | 289 | |
290 | 290 | function do_index_update() { |
— | — | @@ -291,12 +291,12 @@ |
292 | 292 | global $wgDatabase; |
293 | 293 | $meta = $wgDatabase->fieldInfo( "recentchanges", "rc_timestamp" ); |
294 | 294 | if( !$meta->isMultipleKey() ) { |
295 | | - echo "Updating indexes to 20031107: "; |
| 295 | + wfOut( "Updating indexes to 20031107: " ); |
296 | 296 | dbsource( archive("patch-indexes.sql") ); |
297 | | - echo "ok\n"; |
| 297 | + wfOut( "ok\n" ); |
298 | 298 | return true; |
299 | 299 | } |
300 | | - echo "...indexes seem up to 20031107 standards\n"; |
| 300 | + wfOut( "...indexes seem up to 20031107 standards\n" ); |
301 | 301 | return false; |
302 | 302 | } |
303 | 303 | |
— | — | @@ -305,67 +305,67 @@ |
306 | 306 | |
307 | 307 | $meta = $wgDatabase->fieldInfo( "image", "img_major_mime" ); |
308 | 308 | if( !$meta->isMultipleKey() ) { |
309 | | - echo "Updating indexes to 20050912: "; |
| 309 | + wfOut( "Updating indexes to 20050912: " ); |
310 | 310 | dbsource( archive("patch-mimesearch-indexes.sql") ); |
311 | | - echo "ok\n"; |
| 311 | + wfOut( "ok\n" ); |
312 | 312 | return true; |
313 | 313 | } |
314 | | - echo "...indexes seem up to 20050912 standards\n"; |
| 314 | + wfOut( "...indexes seem up to 20050912 standards\n" ); |
315 | 315 | return false; |
316 | 316 | } |
317 | 317 | |
318 | 318 | function do_image_name_unique_update() { |
319 | 319 | global $wgDatabase; |
320 | 320 | if( $wgDatabase->indexExists( 'image', 'PRIMARY' ) ) { |
321 | | - echo "...image primary key already set.\n"; |
| 321 | + wfOut( "...image primary key already set.\n" ); |
322 | 322 | } else { |
323 | | - echo "Making img_name the primary key... "; |
| 323 | + wfOut( "Making img_name the primary key... " ); |
324 | 324 | dbsource( archive("patch-image_name_primary.sql"), $wgDatabase ); |
325 | | - echo "ok\n"; |
| 325 | + wfOut( "ok\n" ); |
326 | 326 | } |
327 | 327 | } |
328 | 328 | |
329 | 329 | function do_logging_timestamp_index() { |
330 | 330 | global $wgDatabase; |
331 | 331 | if( $wgDatabase->indexExists( 'logging', 'times' ) ) { |
332 | | - echo "...timestamp key on logging already exists.\n"; |
| 332 | + wfOut( "...timestamp key on logging already exists.\n" ); |
333 | 333 | } else { |
334 | | - echo "Adding timestamp key on logging table... "; |
| 334 | + wfOut( "Adding timestamp key on logging table... " ); |
335 | 335 | dbsource( archive("patch-logging-times-index.sql"), $wgDatabase ); |
336 | | - echo "ok\n"; |
| 336 | + wfOut( "ok\n" ); |
337 | 337 | } |
338 | 338 | } |
339 | 339 | |
340 | 340 | function do_archive_user_index() { |
341 | 341 | global $wgDatabase; |
342 | 342 | if( $wgDatabase->indexExists( 'archive', 'usertext_timestamp' ) ) { |
343 | | - echo "...usertext,timestamp key on archive already exists.\n"; |
| 343 | + wfOut( "...usertext,timestamp key on archive already exists.\n" ); |
344 | 344 | } else { |
345 | | - echo "Adding usertext,timestamp key on archive table... "; |
| 345 | + wfOut( "Adding usertext,timestamp key on archive table... " ); |
346 | 346 | dbsource( archive("patch-archive-user-index.sql"), $wgDatabase ); |
347 | | - echo "ok\n"; |
| 347 | + wfOut( "ok\n" ); |
348 | 348 | } |
349 | 349 | } |
350 | 350 | |
351 | 351 | function do_image_user_index() { |
352 | 352 | global $wgDatabase; |
353 | 353 | if( $wgDatabase->indexExists( 'image', 'img_usertext_timestamp' ) ) { |
354 | | - echo "...usertext,timestamp key on image already exists.\n"; |
| 354 | + wfOut( "...usertext,timestamp key on image already exists.\n" ); |
355 | 355 | } else { |
356 | | - echo "Adding usertext,timestamp key on image table... "; |
| 356 | + wfOut( "Adding usertext,timestamp key on image table... " ); |
357 | 357 | dbsource( archive("patch-image-user-index.sql"), $wgDatabase ); |
358 | | - echo "ok\n"; |
| 358 | + wfOut( "ok\n" ); |
359 | 359 | } |
360 | 360 | } |
361 | 361 | |
362 | 362 | function do_oldimage_user_index() { |
363 | 363 | global $wgDatabase; |
364 | 364 | if( $wgDatabase->indexExists( 'oldimage', 'oi_usertext_timestamp' ) ) { |
365 | | - echo "...usertext,timestamp key on oldimage already exists.\n"; |
| 365 | + wfOut( "...usertext,timestamp key on oldimage already exists.\n" ); |
366 | 366 | } else { |
367 | | - echo "Adding usertext,timestamp key on oldimage table... "; |
| 367 | + wfOut( "Adding usertext,timestamp key on oldimage table... " ); |
368 | 368 | dbsource( archive("patch-oldimage-user-index.sql"), $wgDatabase ); |
369 | | - echo "ok\n"; |
| 369 | + wfOut( "ok\n" ); |
370 | 370 | } |
371 | 371 | } |
372 | 372 | |
— | — | @@ -373,18 +373,18 @@ |
374 | 374 | global $wgDatabase; |
375 | 375 | $fname = 'do_watchlist_update'; |
376 | 376 | if( $wgDatabase->fieldExists( 'watchlist', 'wl_notificationtimestamp' ) ) { |
377 | | - echo "The watchlist table is already set up for email notification.\n"; |
| 377 | + wfOut( "The watchlist table is already set up for email notification.\n" ); |
378 | 378 | } else { |
379 | | - echo "Adding wl_notificationtimestamp field for email notification management."; |
| 379 | + wfOut( "Adding wl_notificationtimestamp field for email notification management." ); |
380 | 380 | /* ALTER TABLE watchlist ADD (wl_notificationtimestamp varchar(14) binary NOT NULL default '0'); */ |
381 | 381 | dbsource( archive( 'patch-email-notification.sql' ), $wgDatabase ); |
382 | | - echo "ok\n"; |
| 382 | + wfOut( "ok\n" ); |
383 | 383 | } |
384 | 384 | # Check if we need to add talk page rows to the watchlist |
385 | 385 | $talk = $wgDatabase->selectField( 'watchlist', 'count(*)', 'wl_namespace & 1', $fname ); |
386 | 386 | $nontalk = $wgDatabase->selectField( 'watchlist', 'count(*)', 'NOT (wl_namespace & 1)', $fname ); |
387 | 387 | if ( $talk != $nontalk ) { |
388 | | - echo "Adding missing watchlist talk page rows... "; |
| 388 | + wfOut( "Adding missing watchlist talk page rows... " ); |
389 | 389 | flush(); |
390 | 390 | |
391 | 391 | $wgDatabase->insertSelect( 'watchlist', 'watchlist', |
— | — | @@ -394,9 +394,9 @@ |
395 | 395 | 'wl_title' => 'wl_title', |
396 | 396 | 'wl_notificationtimestamp' => 'wl_notificationtimestamp' |
397 | 397 | ), array( 'NOT (wl_namespace & 1)' ), $fname, 'IGNORE' ); |
398 | | - echo "ok\n"; |
| 398 | + wfOut( "ok\n" ); |
399 | 399 | } else { |
400 | | - echo "...watchlist talk page rows already present\n"; |
| 400 | + wfOut( "...watchlist talk page rows already present\n" ); |
401 | 401 | } |
402 | 402 | } |
403 | 403 | |
— | — | @@ -407,7 +407,7 @@ |
408 | 408 | $res = $wgDatabase->safeQuery( 'SELECT user_id, user_ip FROM !', |
409 | 409 | $wgDatabase->tableName( 'user_newtalk' ) ); |
410 | 410 | $num_newtalks=$wgDatabase->numRows($res); |
411 | | - echo "Now converting ".$num_newtalks." user_newtalk entries to watchlist table entries ... \n"; |
| 411 | + wfOut( "Now converting $num_newtalks user_newtalk entries to watchlist table entries ... \n" ); |
412 | 412 | |
413 | 413 | $user = new User(); |
414 | 414 | for ( $i = 1; $i <= $num_newtalks; $i++ ) { |
— | — | @@ -435,18 +435,18 @@ |
436 | 436 | ); |
437 | 437 | } |
438 | 438 | } |
439 | | - echo "Done.\n"; |
| 439 | + wfOut( "Done.\n" ); |
440 | 440 | } |
441 | 441 | |
442 | 442 | |
443 | 443 | function do_user_update() { |
444 | 444 | global $wgDatabase; |
445 | 445 | if( $wgDatabase->fieldExists( 'user', 'user_emailauthenticationtimestamp' ) ) { |
446 | | - echo "User table contains old email authentication field. Dropping... "; |
| 446 | + wfOut( "User table contains old email authentication field. Dropping... " ); |
447 | 447 | dbsource( archive( 'patch-email-authentication.sql' ), $wgDatabase ); |
448 | | - echo "ok\n"; |
| 448 | + wfOut( "ok\n" ); |
449 | 449 | } else { |
450 | | - echo "...user table does not contain old email authentication field.\n"; |
| 450 | + wfOut( "...user table does not contain old email authentication field.\n" ); |
451 | 451 | } |
452 | 452 | } |
453 | 453 | |
— | — | @@ -464,11 +464,11 @@ |
465 | 465 | $wgDatabase->freeResult( $res ); |
466 | 466 | |
467 | 467 | if( in_array( 'binary', $flags ) ) { |
468 | | - echo "$table table has correct $field encoding.\n"; |
| 468 | + wfOut( "$table table has correct $field encoding.\n" ); |
469 | 469 | } else { |
470 | | - echo "Fixing $field encoding on $table table... "; |
| 470 | + wfOut( "Fixing $field encoding on $table table... " ); |
471 | 471 | dbsource( archive( $patchFile ), $wgDatabase ); |
472 | | - echo "ok\n"; |
| 472 | + wfOut( "ok\n" ); |
473 | 473 | } |
474 | 474 | } |
475 | 475 | |
— | — | @@ -476,11 +476,11 @@ |
477 | 477 | global $wgDatabase; |
478 | 478 | $fname="do_schema_restructuring"; |
479 | 479 | if ( $wgDatabase->tableExists( 'page' ) ) { |
480 | | - echo "...page table already exists.\n"; |
| 480 | + wfOut( "...page table already exists.\n" ); |
481 | 481 | } else { |
482 | | - echo "...converting from cur/old to page/revision/text DB structure.\n"; flush(); |
483 | | - echo wfTimestamp( TS_DB ); |
484 | | - echo "......checking for duplicate entries.\n"; flush(); |
| 482 | + wfOut( "...converting from cur/old to page/revision/text DB structure.\n" ); |
| 483 | + wfOut( wfTimestamp( TS_DB ) ); |
| 484 | + wfOut( "......checking for duplicate entries.\n" ); |
485 | 485 | |
486 | 486 | list ($cur, $old, $page, $revision, $text) = $wgDatabase->tableNamesN( 'cur', 'old', 'page', 'revision', 'text' ); |
487 | 487 | |
— | — | @@ -488,15 +488,15 @@ |
489 | 489 | FROM $cur GROUP BY cur_title, cur_namespace HAVING c>1", $fname ); |
490 | 490 | |
491 | 491 | if ( $wgDatabase->numRows( $rows ) > 0 ) { |
492 | | - echo wfTimestamp( TS_DB ); |
493 | | - echo "......<b>Found duplicate entries</b>\n"; |
494 | | - echo ( sprintf( "<b> %-60s %3s %5s</b>\n", 'Title', 'NS', 'Count' ) ); |
| 492 | + wfOut( wfTimestamp( TS_DB ) ); |
| 493 | + wfOut( "......<b>Found duplicate entries</b>\n" ); |
| 494 | + wfOut( sprintf( "<b> %-60s %3s %5s</b>\n", 'Title', 'NS', 'Count' ) ); |
495 | 495 | while ( $row = $wgDatabase->fetchObject( $rows ) ) { |
496 | 496 | if ( ! isset( $duplicate[$row->cur_namespace] ) ) { |
497 | 497 | $duplicate[$row->cur_namespace] = array(); |
498 | 498 | } |
499 | 499 | $duplicate[$row->cur_namespace][] = $row->cur_title; |
500 | | - echo ( sprintf( " %-60s %3s %5s\n", $row->cur_title, $row->cur_namespace, $row->c ) ); |
| 500 | + wfOut( sprintf( " %-60s %3s %5s\n", $row->cur_title, $row->cur_namespace, $row->c ) ); |
501 | 501 | } |
502 | 502 | $sql = "SELECT cur_title, cur_namespace, cur_id, cur_timestamp FROM $cur WHERE "; |
503 | 503 | $firstCond = true; |
— | — | @@ -536,13 +536,13 @@ |
537 | 537 | } |
538 | 538 | $sql = "DELETE FROM $cur WHERE cur_id IN ( " . join( ',', $deleteId ) . ')'; |
539 | 539 | $rows = $wgDatabase->query( $sql, $fname ); |
540 | | - echo wfTimestamp( TS_DB ); |
541 | | - echo "......<b>Deleted</b> ".$wgDatabase->affectedRows()." records.\n"; |
| 540 | + wfOut( wfTimestamp( TS_DB ) ); |
| 541 | + wfOut( "......<b>Deleted</b> ".$wgDatabase->affectedRows()." records.\n" ); |
542 | 542 | } |
543 | 543 | |
544 | 544 | |
545 | | - echo wfTimestamp( TS_DB ); |
546 | | - echo "......Creating tables.\n"; |
| 545 | + wfOut( wfTimestamp( TS_DB ) ); |
| 546 | + wfOut( "......Creating tables.\n" ); |
547 | 547 | $wgDatabase->query("CREATE TABLE $page ( |
548 | 548 | page_id int(8) unsigned NOT NULL auto_increment, |
549 | 549 | page_namespace int NOT NULL, |
— | — | @@ -580,26 +580,26 @@ |
581 | 581 | INDEX usertext_timestamp (rev_user_text,rev_timestamp) |
582 | 582 | ) ENGINE=InnoDB", $fname ); |
583 | 583 | |
584 | | - echo wfTimestamp( TS_DB ); |
585 | | - echo "......Locking tables.\n"; |
| 584 | + wfOut( wfTimestamp( TS_DB ) ); |
| 585 | + wfOut( "......Locking tables.\n" ); |
586 | 586 | $wgDatabase->query( "LOCK TABLES $page WRITE, $revision WRITE, $old WRITE, $cur WRITE", $fname ); |
587 | 587 | |
588 | 588 | $maxold = intval( $wgDatabase->selectField( 'old', 'max(old_id)', '', $fname ) ); |
589 | | - echo wfTimestamp( TS_DB ); |
590 | | - echo "......maxold is {$maxold}\n"; |
| 589 | + wfOut( wfTimestamp( TS_DB ) ); |
| 590 | + wfOut( "......maxold is {$maxold}\n" ); |
591 | 591 | |
592 | | - echo wfTimestamp( TS_DB ); |
| 592 | + wfOut( wfTimestamp( TS_DB ) ); |
593 | 593 | global $wgLegacySchemaConversion; |
594 | 594 | if( $wgLegacySchemaConversion ) { |
595 | 595 | // Create HistoryBlobCurStub entries. |
596 | 596 | // Text will be pulled from the leftover 'cur' table at runtime. |
597 | | - echo "......Moving metadata from cur; using blob references to text in cur table.\n"; |
| 597 | + wfOut( "......Moving metadata from cur; using blob references to text in cur table.\n" ); |
598 | 598 | $cur_text = "concat('O:18:\"historyblobcurstub\":1:{s:6:\"mCurId\";i:',cur_id,';}')"; |
599 | 599 | $cur_flags = "'object'"; |
600 | 600 | } else { |
601 | 601 | // Copy all cur text in immediately: this may take longer but avoids |
602 | 602 | // having to keep an extra table around. |
603 | | - echo "......Moving text from cur.\n"; |
| 603 | + wfOut( "......Moving text from cur.\n" ); |
604 | 604 | $cur_text = 'cur_text'; |
605 | 605 | $cur_flags = "''"; |
606 | 606 | } |
— | — | @@ -608,16 +608,16 @@ |
609 | 609 | SELECT cur_namespace, cur_title, $cur_text, cur_comment, cur_user, cur_user_text, cur_timestamp, cur_minor_edit, $cur_flags |
610 | 610 | FROM $cur", $fname ); |
611 | 611 | |
612 | | - echo wfTimestamp( TS_DB ); |
613 | | - echo "......Setting up revision table.\n"; |
| 612 | + wfOut( wfTimestamp( TS_DB ) ); |
| 613 | + wfOut( "......Setting up revision table.\n" ); |
614 | 614 | $wgDatabase->query( "INSERT INTO $revision (rev_id, rev_page, rev_comment, rev_user, rev_user_text, rev_timestamp, |
615 | 615 | rev_minor_edit) |
616 | 616 | SELECT old_id, cur_id, old_comment, old_user, old_user_text, |
617 | 617 | old_timestamp, old_minor_edit |
618 | 618 | FROM $old,$cur WHERE old_namespace=cur_namespace AND old_title=cur_title", $fname ); |
619 | 619 | |
620 | | - echo wfTimestamp( TS_DB ); |
621 | | - echo "......Setting up page table.\n"; |
| 620 | + wfOut( wfTimestamp( TS_DB ) ); |
| 621 | + wfOut( "......Setting up page table.\n" ); |
622 | 622 | $wgDatabase->query( "INSERT INTO $page (page_id, page_namespace, page_title, page_restrictions, page_counter, |
623 | 623 | page_is_redirect, page_is_new, page_random, page_touched, page_latest, page_len) |
624 | 624 | SELECT cur_id, cur_namespace, cur_title, cur_restrictions, cur_counter, cur_is_redirect, cur_is_new, |
— | — | @@ -625,38 +625,38 @@ |
626 | 626 | FROM $cur,$revision |
627 | 627 | WHERE cur_id=rev_page AND rev_timestamp=cur_timestamp AND rev_id > {$maxold}", $fname ); |
628 | 628 | |
629 | | - echo wfTimestamp( TS_DB ); |
630 | | - echo "......Unlocking tables.\n"; |
| 629 | + wfOut( wfTimestamp( TS_DB ) ); |
| 630 | + wfOut( "......Unlocking tables.\n" ); |
631 | 631 | $wgDatabase->query( "UNLOCK TABLES", $fname ); |
632 | 632 | |
633 | | - echo wfTimestamp( TS_DB ); |
634 | | - echo "......Renaming old.\n"; |
| 633 | + wfOut( wfTimestamp( TS_DB ) ); |
| 634 | + wfOut( "......Renaming old.\n" ); |
635 | 635 | $wgDatabase->query( "ALTER TABLE $old RENAME TO $text", $fname ); |
636 | 636 | |
637 | | - echo wfTimestamp( TS_DB ); |
638 | | - echo "...done.\n"; |
| 637 | + wfOut( wfTimestamp( TS_DB ) ); |
| 638 | + wfOut( "...done.\n" ); |
639 | 639 | } |
640 | 640 | } |
641 | 641 | |
642 | 642 | function do_inverse_timestamp() { |
643 | 643 | global $wgDatabase; |
644 | 644 | if( $wgDatabase->fieldExists( 'revision', 'inverse_timestamp' ) ) { |
645 | | - echo "Removing revision.inverse_timestamp and fixing indexes... "; |
| 645 | + wfOut( "Removing revision.inverse_timestamp and fixing indexes... " ); |
646 | 646 | dbsource( archive( 'patch-inverse_timestamp.sql' ), $wgDatabase ); |
647 | | - echo "ok\n"; |
| 647 | + wfOut( "ok\n" ); |
648 | 648 | } else { |
649 | | - echo "revision timestamp indexes already up to 2005-03-13\n"; |
| 649 | + wfOut( "revision timestamp indexes already up to 2005-03-13\n" ); |
650 | 650 | } |
651 | 651 | } |
652 | 652 | |
653 | 653 | function do_text_id() { |
654 | 654 | global $wgDatabase; |
655 | 655 | if( $wgDatabase->fieldExists( 'revision', 'rev_text_id' ) ) { |
656 | | - echo "...rev_text_id already in place.\n"; |
| 656 | + wfOut( "...rev_text_id already in place.\n" ); |
657 | 657 | } else { |
658 | | - echo "Adding rev_text_id field... "; |
| 658 | + wfOut( "Adding rev_text_id field... " ); |
659 | 659 | dbsource( archive( 'patch-rev_text_id.sql' ), $wgDatabase ); |
660 | | - echo "ok\n"; |
| 660 | + wfOut( "ok\n" ); |
661 | 661 | } |
662 | 662 | } |
663 | 663 | |
— | — | @@ -687,25 +687,25 @@ |
688 | 688 | $wgDatabase->freeResult( $result ); |
689 | 689 | |
690 | 690 | if( substr( $info->Type, 0, 3 ) == 'int' ) { |
691 | | - echo "...$field is already a full int ($info->Type).\n"; |
| 691 | + wfOut( "...$field is already a full int ($info->Type).\n" ); |
692 | 692 | } else { |
693 | | - echo "Promoting $field from $info->Type to int... "; |
| 693 | + wfOut( "Promoting $field from $info->Type to int... " ); |
694 | 694 | |
695 | 695 | $sql = "ALTER TABLE $tablename MODIFY $field int NOT NULL"; |
696 | 696 | $wgDatabase->query( $sql ); |
697 | 697 | |
698 | | - echo "ok\n"; |
| 698 | + wfOut( "ok\n" ); |
699 | 699 | } |
700 | 700 | } |
701 | 701 | |
702 | 702 | function do_pagelinks_update() { |
703 | 703 | global $wgDatabase; |
704 | 704 | if( $wgDatabase->tableExists( 'pagelinks' ) ) { |
705 | | - echo "...already have pagelinks table.\n"; |
| 705 | + wfOut( "...already have pagelinks table.\n" ); |
706 | 706 | } else { |
707 | | - echo "Converting links and brokenlinks tables to pagelinks... "; |
| 707 | + wfOut( "Converting links and brokenlinks tables to pagelinks... " ); |
708 | 708 | dbsource( archive( 'patch-pagelinks.sql' ), $wgDatabase ); |
709 | | - echo "ok\n"; |
| 709 | + wfOut( "ok\n" ); |
710 | 710 | flush(); |
711 | 711 | |
712 | 712 | global $wgCanonicalNamespaceNames; |
— | — | @@ -721,7 +721,7 @@ |
722 | 722 | global $wgDatabase, $wgContLang; |
723 | 723 | |
724 | 724 | $ns = intval( $namespace ); |
725 | | - echo "Cleaning up broken links for namespace $ns... "; |
| 725 | + wfOut( "Cleaning up broken links for namespace $ns... " ); |
726 | 726 | |
727 | 727 | $pagelinks = $wgDatabase->tableName( 'pagelinks' ); |
728 | 728 | $name = $wgContLang->getNsText( $ns ); |
— | — | @@ -735,25 +735,25 @@ |
736 | 736 | AND pl_title LIKE '$likeprefix:%'"; |
737 | 737 | |
738 | 738 | $wgDatabase->query( $sql, 'do_pagelinks_namespace' ); |
739 | | - echo "ok\n"; |
| 739 | + wfOut( "ok\n" ); |
740 | 740 | } |
741 | 741 | |
742 | 742 | function do_drop_img_type() { |
743 | 743 | global $wgDatabase; |
744 | 744 | |
745 | 745 | if( $wgDatabase->fieldExists( 'image', 'img_type' ) ) { |
746 | | - echo "Dropping unused img_type field in image table... "; |
| 746 | + wfOut( "Dropping unused img_type field in image table... " ); |
747 | 747 | dbsource( archive( 'patch-drop_img_type.sql' ), $wgDatabase ); |
748 | | - echo "ok\n"; |
| 748 | + wfOut( "ok\n" ); |
749 | 749 | } else { |
750 | | - echo "No img_type field in image table; Good.\n"; |
| 750 | + wfOut( "No img_type field in image table; Good.\n" ); |
751 | 751 | } |
752 | 752 | } |
753 | 753 | |
754 | 754 | function do_old_links_update() { |
755 | 755 | global $wgDatabase; |
756 | 756 | if( $wgDatabase->tableExists( 'pagelinks' ) ) { |
757 | | - echo "Already have pagelinks; skipping old links table updates.\n"; |
| 757 | + wfOut( "Already have pagelinks; skipping old links table updates.\n" ); |
758 | 758 | } else { |
759 | 759 | convertLinks(); flush(); |
760 | 760 | } |
— | — | @@ -763,14 +763,14 @@ |
764 | 764 | global $wgDatabase; |
765 | 765 | $duper = new UserDupes( $wgDatabase ); |
766 | 766 | if( $duper->hasUniqueIndex() ) { |
767 | | - echo "Already have unique user_name index.\n"; |
| 767 | + wfOut( "Already have unique user_name index.\n" ); |
768 | 768 | } else { |
769 | 769 | if( !$duper->clearDupes() ) { |
770 | | - echo "WARNING: This next step will probably fail due to unfixed duplicates...\n"; |
| 770 | + wfOut( "WARNING: This next step will probably fail due to unfixed duplicates...\n" ); |
771 | 771 | } |
772 | | - echo "Adding unique index on user_name... "; |
| 772 | + wfOut( "Adding unique index on user_name... " ); |
773 | 773 | dbsource( archive( 'patch-user_nameindex.sql' ), $wgDatabase ); |
774 | | - echo "ok\n"; |
| 774 | + wfOut( "ok\n" ); |
775 | 775 | } |
776 | 776 | } |
777 | 777 | |
— | — | @@ -779,28 +779,28 @@ |
780 | 780 | global $wgDatabase; |
781 | 781 | |
782 | 782 | if( $wgDatabase->tableExists( 'user_groups' ) ) { |
783 | | - echo "...user_groups table already exists.\n"; |
| 783 | + wfOut( "...user_groups table already exists.\n" ); |
784 | 784 | return do_user_groups_reformat(); |
785 | 785 | } |
786 | 786 | |
787 | | - echo "Adding user_groups table... "; |
| 787 | + wfOut( "Adding user_groups table... " ); |
788 | 788 | dbsource( archive( 'patch-user_groups.sql' ), $wgDatabase ); |
789 | | - echo "ok\n"; |
| 789 | + wfOut( "ok\n" ); |
790 | 790 | |
791 | 791 | if( !$wgDatabase->tableExists( 'user_rights' ) ) { |
792 | 792 | if( $wgDatabase->fieldExists( 'user', 'user_rights' ) ) { |
793 | | - echo "Upgrading from a 1.3 or older database? Breaking out user_rights for conversion..."; |
| 793 | + wfOut( "Upgrading from a 1.3 or older database? Breaking out user_rights for conversion..." ); |
794 | 794 | dbsource( archive( 'patch-user_rights.sql' ), $wgDatabase ); |
795 | | - echo "ok\n"; |
| 795 | + wfOut( "ok\n" ); |
796 | 796 | } else { |
797 | | - echo "*** WARNING: couldn't locate user_rights table or field for upgrade.\n"; |
798 | | - echo "*** You may need to manually configure some sysops by manipulating\n"; |
799 | | - echo "*** the user_groups table.\n"; |
| 797 | + wfOut( "*** WARNING: couldn't locate user_rights table or field for upgrade.\n" ); |
| 798 | + wfOut( "*** You may need to manually configure some sysops by manipulating\n" ); |
| 799 | + wfOut( "*** the user_groups table.\n" ); |
800 | 800 | return; |
801 | 801 | } |
802 | 802 | } |
803 | 803 | |
804 | | - echo "Converting user_rights table to user_groups... "; |
| 804 | + wfOut( "Converting user_rights table to user_groups... " ); |
805 | 805 | $result = $wgDatabase->select( 'user_rights', |
806 | 806 | array( 'ur_user', 'ur_rights' ), |
807 | 807 | array( "ur_rights != ''" ), |
— | — | @@ -820,7 +820,7 @@ |
821 | 821 | } |
822 | 822 | } |
823 | 823 | $wgDatabase->freeResult( $result ); |
824 | | - echo "ok\n"; |
| 824 | + wfOut( "ok\n" ); |
825 | 825 | } |
826 | 826 | |
827 | 827 | function do_user_groups_reformat() { |
— | — | @@ -831,20 +831,20 @@ |
832 | 832 | if( $info->type() == 'int' ) { |
833 | 833 | $oldug = $wgDatabase->tableName( 'user_groups' ); |
834 | 834 | $newug = $wgDatabase->tableName( 'user_groups_bogus' ); |
835 | | - echo "user_groups is in bogus intermediate format. Renaming to $newug... "; |
| 835 | + wfOut( "user_groups is in bogus intermediate format. Renaming to $newug... " ); |
836 | 836 | $wgDatabase->query( "ALTER TABLE $oldug RENAME TO $newug" ); |
837 | | - echo "ok\n"; |
| 837 | + wfOut( "ok\n" ); |
838 | 838 | |
839 | | - echo "Re-adding fresh user_groups table... "; |
| 839 | + wfOut( "Re-adding fresh user_groups table... " ); |
840 | 840 | dbsource( archive( 'patch-user_groups.sql' ), $wgDatabase ); |
841 | | - echo "ok\n"; |
| 841 | + wfOut( "ok\n" ); |
842 | 842 | |
843 | | - echo "***\n"; |
844 | | - echo "*** WARNING: You will need to manually fix up user permissions in the user_groups\n"; |
845 | | - echo "*** table. Old 1.5 alpha versions did some pretty funky stuff...\n"; |
846 | | - echo "***\n"; |
| 843 | + wfOut( "***\n" ); |
| 844 | + wfOut( "*** WARNING: You will need to manually fix up user permissions in the user_groups\n" ); |
| 845 | + wfOut( "*** table. Old 1.5 alpha versions did some pretty funky stuff...\n" ); |
| 846 | + wfOut( "***\n" ); |
847 | 847 | } else { |
848 | | - echo "...user_groups is in current format.\n"; |
| 848 | + wfOut( "...user_groups is in current format.\n" ); |
849 | 849 | } |
850 | 850 | |
851 | 851 | } |
— | — | @@ -856,11 +856,11 @@ |
857 | 857 | $info = $wgDatabase->fieldInfo( 'watchlist', 'wl_notificationtimestamp' ); |
858 | 858 | |
859 | 859 | if( !$info->nullable() ) { |
860 | | - echo "Making wl_notificationtimestamp nullable... "; |
| 860 | + wfOut( "Making wl_notificationtimestamp nullable... " ); |
861 | 861 | dbsource( archive( 'patch-watchlist-null.sql' ), $wgDatabase ); |
862 | | - echo "ok\n"; |
| 862 | + wfOut( "ok\n" ); |
863 | 863 | } else { |
864 | | - echo "...wl_notificationtimestamp is already nullable.\n"; |
| 864 | + wfOut( "...wl_notificationtimestamp is already nullable.\n" ); |
865 | 865 | } |
866 | 866 | |
867 | 867 | } |
— | — | @@ -871,13 +871,13 @@ |
872 | 872 | function do_page_random_update() { |
873 | 873 | global $wgDatabase; |
874 | 874 | |
875 | | - echo "Setting page_random to a random value on rows where it equals 0..."; |
| 875 | + wfOut( "Setting page_random to a random value on rows where it equals 0..." ); |
876 | 876 | |
877 | 877 | $page = $wgDatabase->tableName( 'page' ); |
878 | 878 | $wgDatabase->query( "UPDATE $page SET page_random = RAND() WHERE page_random = 0", 'do_page_random_update' ); |
879 | 879 | $rows = $wgDatabase->affectedRows(); |
880 | 880 | |
881 | | - echo "changed $rows rows\n"; |
| 881 | + wfOut( "changed $rows rows\n" ); |
882 | 882 | } |
883 | 883 | |
884 | 884 | function do_templatelinks_update() { |
— | — | @@ -885,12 +885,12 @@ |
886 | 886 | $fname = 'do_templatelinks_update'; |
887 | 887 | |
888 | 888 | if ( $wgDatabase->tableExists( 'templatelinks' ) ) { |
889 | | - echo "...templatelinks table already exists\n"; |
| 889 | + wfOut( "...templatelinks table already exists\n" ); |
890 | 890 | return; |
891 | 891 | } |
892 | | - echo "Creating templatelinks table...\n"; |
| 892 | + wfOut( "Creating templatelinks table...\n" ); |
893 | 893 | dbsource( archive('patch-templatelinks.sql'), $wgDatabase ); |
894 | | - echo "Populating...\n"; |
| 894 | + wfOut( "Populating...\n" ); |
895 | 895 | if ( isset( $wgLoadBalancer ) && $wgLoadBalancer->getServerCount() > 1 ) { |
896 | 896 | // Slow, replication-friendly update |
897 | 897 | $res = $wgDatabase->select( 'pagelinks', array( 'pl_from', 'pl_namespace', 'pl_title' ), |
— | — | @@ -927,14 +927,14 @@ |
928 | 928 | ), $fname |
929 | 929 | ); |
930 | 930 | } |
931 | | - echo "Done. Please run maintenance/refreshLinks.php for a more thorough templatelinks update.\n"; |
| 931 | + wfOut( "Done. Please run maintenance/refreshLinks.php for a more thorough templatelinks update.\n" ); |
932 | 932 | } |
933 | 933 | |
934 | 934 | // Add index on ( rc_namespace, rc_user_text ) [Jul. 2006] |
935 | 935 | // Add index on ( rc_user_text, rc_timestamp ) [Nov. 2006] |
936 | 936 | function do_rc_indices_update() { |
937 | 937 | global $wgDatabase; |
938 | | - echo( "Checking for additional recent changes indices...\n" ); |
| 938 | + wfOut( "Checking for additional recent changes indices...\n" ); |
939 | 939 | |
940 | 940 | $indexes = array( |
941 | 941 | 'rc_ns_usertext' => 'patch-recentchanges-utindex.sql', |
— | — | @@ -944,59 +944,59 @@ |
945 | 945 | foreach( $indexes as $index => $patch ) { |
946 | 946 | $info = $wgDatabase->indexInfo( 'recentchanges', $index, __METHOD__ ); |
947 | 947 | if( !$info ) { |
948 | | - echo( "...index `{$index}` not found; adding..." ); |
| 948 | + wfOut( "...index `{$index}` not found; adding..." ); |
949 | 949 | dbsource( archive( $patch ) ); |
950 | | - echo( "done.\n" ); |
| 950 | + wfOut( "done.\n" ); |
951 | 951 | } else { |
952 | | - echo( "...index `{$index}` seems ok.\n" ); |
| 952 | + wfOut( "...index `{$index}` seems ok.\n" ); |
953 | 953 | } |
954 | 954 | } |
955 | 955 | } |
956 | 956 | |
957 | 957 | function index_has_field($table, $index, $field) { |
958 | 958 | global $wgDatabase; |
959 | | - echo( "Checking if $table index $index includes field $field...\n" ); |
| 959 | + wfOut( "Checking if $table index $index includes field $field...\n" ); |
960 | 960 | $info = $wgDatabase->indexInfo( $table, $index, __METHOD__ ); |
961 | 961 | if( $info ) { |
962 | 962 | foreach($info as $row) { |
963 | 963 | if($row->Column_name == $field) { |
964 | | - echo( "...index $index on table $table seems to be ok\n" ); |
| 964 | + wfOut( "...index $index on table $table seems to be ok\n" ); |
965 | 965 | return true; |
966 | 966 | } |
967 | 967 | } |
968 | 968 | } |
969 | | - echo( "...index $index on table $table has no field $field; adding\n" ); |
| 969 | + wfOut( "...index $index on table $table has no field $field; adding\n" ); |
970 | 970 | return false; |
971 | 971 | } |
972 | 972 | |
973 | 973 | function do_backlinking_indices_update() { |
974 | | - echo( "Checking for backlinking indices...\n" ); |
| 974 | + wfOut( "Checking for backlinking indices...\n" ); |
975 | 975 | if (!index_has_field('pagelinks', 'pl_namespace', 'pl_from') || |
976 | 976 | !index_has_field('templatelinks', 'tl_namespace', 'tl_from') || |
977 | 977 | !index_has_field('imagelinks', 'il_to', 'il_from')) |
978 | 978 | { |
979 | 979 | dbsource( archive( 'patch-backlinkindexes.sql' ) ); |
980 | | - echo( "...backlinking indices updated\n" ); |
| 980 | + wfOut( "...backlinking indices updated\n" ); |
981 | 981 | } |
982 | 982 | } |
983 | 983 | |
984 | 984 | function do_categorylinks_indices_update() { |
985 | | - echo( "Checking for categorylinks indices...\n" ); |
| 985 | + wfOut( "Checking for categorylinks indices...\n" ); |
986 | 986 | if (!index_has_field('categorylinks', 'cl_sortkey', 'cl_from')) |
987 | 987 | { |
988 | 988 | dbsource( archive( 'patch-categorylinksindex.sql' ) ); |
989 | | - echo( "...categorylinks indices updated\n" ); |
| 989 | + wfOut( "...categorylinks indices updated\n" ); |
990 | 990 | } |
991 | 991 | } |
992 | 992 | |
993 | 993 | function do_filearchive_indices_update() { |
994 | 994 | global $wgDatabase; |
995 | | - echo( "Checking filearchive indices...\n" ); |
| 995 | + wfOut( "Checking filearchive indices...\n" ); |
996 | 996 | $info = $wgDatabase->indexInfo( 'filearchive', 'fa_user_timestamp', __METHOD__ ); |
997 | 997 | if ( !$info ) |
998 | 998 | { |
999 | 999 | dbsource( archive( 'patch-filearhive-user-index.sql' ) ); |
1000 | | - echo( "...filearchive indices updated\n" ); |
| 1000 | + wfOut( "...filearchive indices updated\n" ); |
1001 | 1001 | } |
1002 | 1002 | } |
1003 | 1003 | |
— | — | @@ -1005,25 +1005,25 @@ |
1006 | 1006 | if ( !$wgDatabase->tableExists( 'profiling' ) ) { |
1007 | 1007 | // Simply ignore |
1008 | 1008 | } elseif ( $wgDatabase->fieldExists( 'profiling', 'pf_memory' ) ) { |
1009 | | - echo "profiling table has pf_memory field.\n"; |
| 1009 | + wfOut( "profiling table has pf_memory field.\n" ); |
1010 | 1010 | } else { |
1011 | | - echo "Adding pf_memory field to table profiling..."; |
| 1011 | + wfOut( "Adding pf_memory field to table profiling..." ); |
1012 | 1012 | dbsource( archive( 'patch-profiling-memory.sql' ), $wgDatabase ); |
1013 | | - echo "ok\n"; |
| 1013 | + wfOut( "ok\n" ); |
1014 | 1014 | } |
1015 | 1015 | } |
1016 | 1016 | |
1017 | 1017 | function do_stats_init() { |
1018 | 1018 | // Sometimes site_stats table is not properly populated. |
1019 | 1019 | global $wgDatabase; |
1020 | | - echo "Checking site_stats row..."; |
| 1020 | + wfOut( "Checking site_stats row..." ); |
1021 | 1021 | $row = $wgDatabase->selectRow( 'site_stats', '*', array( 'ss_row_id' => 1 ), __METHOD__ ); |
1022 | 1022 | if( $row === false ) { |
1023 | | - echo "data is missing! rebuilding...\n"; |
| 1023 | + wfOut( "data is missing! rebuilding...\n" ); |
1024 | 1024 | } elseif ( isset( $row->site_stats ) && $row->ss_total_pages == -1 ) { |
1025 | | - echo "missing ss_total_pages, rebuilding...\n"; |
| 1025 | + wfOut( "missing ss_total_pages, rebuilding...\n" ); |
1026 | 1026 | } else { |
1027 | | - echo "ok.\n"; |
| 1027 | + wfOut( "ok.\n" ); |
1028 | 1028 | return; |
1029 | 1029 | } |
1030 | 1030 | |
— | — | @@ -1045,16 +1045,16 @@ |
1046 | 1046 | array( 'ss_row_id' => 1 ), __METHOD__, array( 'LIMIT' => 1 ) |
1047 | 1047 | ); |
1048 | 1048 | } |
1049 | | - echo( "...ss_active_users user count set...\n" ); |
| 1049 | + wfOut( "...ss_active_users user count set...\n" ); |
1050 | 1050 | } |
1051 | 1051 | |
1052 | 1052 | function purge_cache() { |
1053 | 1053 | global $wgDatabase; |
1054 | 1054 | # We can't guarantee that the user will be able to use TRUNCATE, |
1055 | 1055 | # but we know that DELETE is available to us |
1056 | | - echo( "Purging caches..." ); |
| 1056 | + wfOut( "Purging caches..." ); |
1057 | 1057 | $wgDatabase->delete( 'objectcache', '*', __METHOD__ ); |
1058 | | - echo( "done.\n" ); |
| 1058 | + wfOut( "done.\n" ); |
1059 | 1059 | } |
1060 | 1060 | |
1061 | 1061 | function do_all_updates( $shared = false, $purge = true ) { |
— | — | @@ -1098,15 +1098,14 @@ |
1099 | 1099 | } |
1100 | 1100 | |
1101 | 1101 | |
1102 | | - echo "Deleting old default messages (this may take a long time!)..."; flush(); |
| 1102 | + wfOut( "Deleting old default messages (this may take a long time!)..." ); |
1103 | 1103 | deleteDefaultMessages(); |
1104 | | - echo "Done\n"; flush(); |
| 1104 | + wfOut( "Done\n" ); |
1105 | 1105 | |
1106 | | - do_stats_init(); flush(); |
| 1106 | + do_stats_init(); |
1107 | 1107 | |
1108 | 1108 | if( $purge ) { |
1109 | 1109 | purge_cache(); |
1110 | | - flush(); |
1111 | 1110 | } |
1112 | 1111 | } |
1113 | 1112 | |
— | — | @@ -1132,14 +1131,14 @@ |
1133 | 1132 | $patch2 = 'patch-page_restrictions_sortkey.sql'; |
1134 | 1133 | |
1135 | 1134 | if ( $wgDatabase->tableExists( $name ) ) { |
1136 | | - echo "...$name table already exists.\n"; |
| 1135 | + wfOut( "...$name table already exists.\n" ); |
1137 | 1136 | } else { |
1138 | | - echo "Creating $name table..."; |
| 1137 | + wfOut( "Creating $name table..." ); |
1139 | 1138 | dbsource( archive($patch), $wgDatabase ); |
1140 | 1139 | dbsource( archive($patch2), $wgDatabase ); |
1141 | | - echo "ok\n"; |
| 1140 | + wfOut( "ok\n" ); |
1142 | 1141 | |
1143 | | - echo "Migrating old restrictions to new table..."; |
| 1142 | + wfOut( "Migrating old restrictions to new table..." ); |
1144 | 1143 | |
1145 | 1144 | $res = $wgDatabase->select( 'page', array( 'page_id', 'page_restrictions' ), array("page_restrictions!=''", "page_restrictions!='edit=:move='"), __METHOD__ ); |
1146 | 1145 | |
— | — | @@ -1191,27 +1190,27 @@ |
1192 | 1191 | __METHOD__ ); |
1193 | 1192 | } |
1194 | 1193 | } |
1195 | | - print "ok\n"; |
| 1194 | + wfOut( "ok\n" ); |
1196 | 1195 | } |
1197 | 1196 | } |
1198 | 1197 | |
1199 | 1198 | function do_category_population() { |
1200 | 1199 | if( update_row_exists( 'populate category' ) ) { |
1201 | | - echo "...category table already populated.\n"; |
| 1200 | + wfOut( "...category table already populated.\n" ); |
1202 | 1201 | return; |
1203 | 1202 | } |
1204 | 1203 | require_once( 'populateCategory.inc' ); |
1205 | | - echo "Populating category table, printing progress markers. ". |
| 1204 | + wfOut( "Populating category table, printing progress markers. " ). |
1206 | 1205 | "For large databases, you\n". |
1207 | 1206 | "may want to hit Ctrl-C and do this manually with maintenance/\n". |
1208 | 1207 | "populateCategory.php.\n"; |
1209 | 1208 | populateCategory( '', 10, 0, true ); |
1210 | | - echo "Done populating category table.\n"; |
| 1209 | + wfOut( "Done populating category table.\n" ); |
1211 | 1210 | } |
1212 | 1211 | |
1213 | 1212 | function do_populate_parent_id() { |
1214 | 1213 | if( update_row_exists( 'populate rev_parent_id' ) ) { |
1215 | | - echo "...rev_parent_id column already populated.\n"; |
| 1214 | + wfOut( "...rev_parent_id column already populated.\n" ); |
1216 | 1215 | return; |
1217 | 1216 | } |
1218 | 1217 | require_once( 'populateParentId.inc' ); |
— | — | @@ -1222,11 +1221,11 @@ |
1223 | 1222 | |
1224 | 1223 | function update_password_format() { |
1225 | 1224 | if ( update_row_exists( 'password format' ) ) { |
1226 | | - echo "...password hash format already changed\n"; |
| 1225 | + wfOut( "...password hash format already changed\n" ); |
1227 | 1226 | return; |
1228 | 1227 | } |
1229 | 1228 | |
1230 | | - echo "Updating password hash format..."; |
| 1229 | + wfOut( "Updating password hash format..." ); |
1231 | 1230 | |
1232 | 1231 | global $wgDatabase, $wgPasswordSalt; |
1233 | 1232 | $user = $wgDatabase->tableName( 'user' ); |
— | — | @@ -1240,7 +1239,7 @@ |
1241 | 1240 | $wgDatabase->query( $sql, __METHOD__ ); |
1242 | 1241 | $wgDatabase->insert( 'updatelog', array( 'ul_key' => 'password format' ), __METHOD__ ); |
1243 | 1242 | |
1244 | | - echo "done\n"; |
| 1243 | + wfOut( "done\n" ); |
1245 | 1244 | } |
1246 | 1245 | |
1247 | 1246 | function |
— | — | @@ -1400,11 +1399,11 @@ |
1401 | 1400 | $search_path = $conf['search_path']; |
1402 | 1401 | } |
1403 | 1402 | if( strpos( $search_path, $wgDBmwschema ) === false ) { |
1404 | | - echo "Adding in schema \"$wgDBmwschema\" to search_path for user \"$wgDBuser\"\n"; |
| 1403 | + wfOut( "Adding in schema \"$wgDBmwschema\" to search_path for user \"$wgDBuser\"\n" ); |
1405 | 1404 | $search_path = "$wgDBmwschema, $search_path"; |
1406 | 1405 | } |
1407 | 1406 | if( strpos( $search_path, $wgDBts2schema ) === false ) { |
1408 | | - echo "Adding in schema \"$wgDBts2schema\" to search_path for user \"$wgDBuser\"\n"; |
| 1407 | + wfOut( "Adding in schema \"$wgDBts2schema\" to search_path for user \"$wgDBuser\"\n" ); |
1409 | 1408 | $search_path = "$search_path, $wgDBts2schema"; |
1410 | 1409 | } |
1411 | 1410 | if( array_key_exists( 'search_path', $conf ) === false || $search_path != $conf['search_path'] ) { |
— | — | @@ -1413,7 +1412,7 @@ |
1414 | 1413 | } |
1415 | 1414 | else { |
1416 | 1415 | $path = $conf['search_path']; |
1417 | | - echo "... search_path for user \"$wgDBuser\" looks correct ($path)\n"; |
| 1416 | + wfOut( "... search_path for user \"$wgDBuser\" looks correct ($path)\n" ); |
1418 | 1417 | } |
1419 | 1418 | $goodconf = array( |
1420 | 1419 | 'client_min_messages' => 'error', |
— | — | @@ -1423,12 +1422,12 @@ |
1424 | 1423 | foreach( array_keys( $goodconf ) AS $key ) { |
1425 | 1424 | $value = $goodconf[$key]; |
1426 | 1425 | if( !array_key_exists( $key, $conf ) or $conf[$key] !== $value ) { |
1427 | | - echo "Setting $key to '$value' for user \"$wgDBuser\"\n"; |
| 1426 | + wfOut( "Setting $key to '$value' for user \"$wgDBuser\"\n" ); |
1428 | 1427 | $wgDatabase->doQuery( "ALTER USER $wgDBuser SET $key = '$value'" ); |
1429 | 1428 | $wgDatabase->doQuery( "SET $key = '$value'" ); |
1430 | 1429 | } |
1431 | 1430 | else { |
1432 | | - echo "... default value of \"$key\" is correctly set to \"$value\" for user \"$wgDBuser\"\n"; |
| 1431 | + wfOut( "... default value of \"$key\" is correctly set to \"$value\" for user \"$wgDBuser\"\n" ); |
1433 | 1432 | } |
1434 | 1433 | } |
1435 | 1434 | |
— | — | @@ -1557,62 +1556,62 @@ |
1558 | 1557 | |
1559 | 1558 | foreach ($newsequences as $ns) { |
1560 | 1559 | if ($wgDatabase->sequenceExists($ns)) { |
1561 | | - echo "... sequence \"$ns\" already exists\n"; |
| 1560 | + wfOut( "... sequence \"$ns\" already exists\n" ); |
1562 | 1561 | continue; |
1563 | 1562 | } |
1564 | 1563 | |
1565 | | - echo "Creating sequence \"$ns\"\n"; |
| 1564 | + wfOut( "Creating sequence \"$ns\"\n" ); |
1566 | 1565 | $wgDatabase->query("CREATE SEQUENCE $ns"); |
1567 | 1566 | } |
1568 | 1567 | |
1569 | 1568 | foreach ($newtables as $nt) { |
1570 | 1569 | if ($wgDatabase->tableExists($nt[0])) { |
1571 | | - echo "... table \"$nt[0]\" already exists\n"; |
| 1570 | + wfOut( "... table \"$nt[0]\" already exists\n" ); |
1572 | 1571 | continue; |
1573 | 1572 | } |
1574 | 1573 | |
1575 | | - echo "Creating table \"$nt[0]\"\n"; |
| 1574 | + wfOut( "Creating table \"$nt[0]\"\n" ); |
1576 | 1575 | dbsource(archive($nt[1])); |
1577 | 1576 | } |
1578 | 1577 | |
1579 | 1578 | ## Needed before newcols |
1580 | 1579 | if ($wgDatabase->tableExists("archive2")) { |
1581 | | - echo "Converting \"archive2\" back to normal archive table\n"; |
| 1580 | + wfOut( "Converting \"archive2\" back to normal archive table\n" ); |
1582 | 1581 | if ($wgDatabase->ruleExists("archive", "archive_insert")) { |
1583 | | - echo "Dropping rule \"archive_insert\"\n"; |
| 1582 | + wfOut( "Dropping rule \"archive_insert\"\n" ); |
1584 | 1583 | $wgDatabase->query("DROP RULE archive_insert ON archive"); |
1585 | 1584 | } |
1586 | 1585 | if ($wgDatabase->ruleExists("archive", "archive_delete")) { |
1587 | | - echo "Dropping rule \"archive_delete\"\n"; |
| 1586 | + wfOut( "Dropping rule \"archive_delete\"\n" ); |
1588 | 1587 | $wgDatabase->query("DROP RULE archive_delete ON archive"); |
1589 | 1588 | } |
1590 | 1589 | dbsource(archive("patch-remove-archive2.sql")); |
1591 | 1590 | } |
1592 | 1591 | else |
1593 | | - echo "... obsolete table \"archive2\" does not exist\n"; |
| 1592 | + wfOut( "... obsolete table \"archive2\" does not exist\n" ); |
1594 | 1593 | |
1595 | 1594 | foreach ($newcols as $nc) { |
1596 | 1595 | $fi = $wgDatabase->fieldInfo($nc[0], $nc[1]); |
1597 | 1596 | if (!is_null($fi)) { |
1598 | | - echo "... column \"$nc[0].$nc[1]\" already exists\n"; |
| 1597 | + wfOut( "... column \"$nc[0].$nc[1]\" already exists\n" ); |
1599 | 1598 | continue; |
1600 | 1599 | } |
1601 | 1600 | |
1602 | | - echo "Adding column \"$nc[0].$nc[1]\"\n"; |
| 1601 | + wfOut( "Adding column \"$nc[0].$nc[1]\"\n" ); |
1603 | 1602 | $wgDatabase->query("ALTER TABLE $nc[0] ADD $nc[1] $nc[2]"); |
1604 | 1603 | } |
1605 | 1604 | |
1606 | 1605 | foreach ($typechanges as $tc) { |
1607 | 1606 | $fi = $wgDatabase->fieldInfo($tc[0], $tc[1]); |
1608 | 1607 | if (is_null($fi)) { |
1609 | | - echo "... error: expected column $tc[0].$tc[1] to exist\n"; |
| 1608 | + wfOut( "... error: expected column $tc[0].$tc[1] to exist\n" ); |
1610 | 1609 | exit(1); |
1611 | 1610 | } |
1612 | 1611 | |
1613 | 1612 | if ($fi->type() === $tc[2]) |
1614 | | - echo "... column \"$tc[0].$tc[1]\" is already of type \"$tc[2]\"\n"; |
| 1613 | + wfOut( "... column \"$tc[0].$tc[1]\" is already of type \"$tc[2]\"\n" ); |
1615 | 1614 | else { |
1616 | | - echo "Changing column type of \"$tc[0].$tc[1]\" from \"{$fi->type()}\" to \"$tc[2]\"\n"; |
| 1615 | + wfOut( "Changing column type of \"$tc[0].$tc[1]\" from \"{$fi->type()}\" to \"$tc[2]\"\n" ); |
1617 | 1616 | $sql = "ALTER TABLE $tc[0] ALTER $tc[1] TYPE $tc[2]"; |
1618 | 1617 | if (strlen($tc[3])) { |
1619 | 1618 | $default = array(); |
— | — | @@ -1629,91 +1628,91 @@ |
1630 | 1629 | } |
1631 | 1630 | |
1632 | 1631 | if ($wgDatabase->fieldInfo('oldimage','oi_deleted')->type() !== 'smallint') { |
1633 | | - echo "Changing \"oldimage.oi_deleted\" to type \"smallint\"\n"; |
| 1632 | + wfOut( "Changing \"oldimage.oi_deleted\" to type \"smallint\"\n" ); |
1634 | 1633 | $wgDatabase->query( "ALTER TABLE oldimage ALTER oi_deleted DROP DEFAULT" ); |
1635 | 1634 | $wgDatabase->query( "ALTER TABLE oldimage ALTER oi_deleted TYPE SMALLINT USING (oi_deleted::smallint)" ); |
1636 | 1635 | $wgDatabase->query( "ALTER TABLE oldimage ALTER oi_deleted SET DEFAULT 0" ); |
1637 | 1636 | } |
1638 | 1637 | else |
1639 | | - echo "... column \"oldimage.oi_deleted\" is already of type \"smallint\"\n"; |
| 1638 | + wfOut( "... column \"oldimage.oi_deleted\" is already of type \"smallint\"\n" ); |
1640 | 1639 | |
1641 | 1640 | |
1642 | 1641 | foreach ($newindexes as $ni) { |
1643 | 1642 | if (pg_index_exists($ni[0], $ni[1])) { |
1644 | | - echo "... index \"$ni[1]\" on table \"$ni[0]\" already exists\n"; |
| 1643 | + wfOut( "... index \"$ni[1]\" on table \"$ni[0]\" already exists\n" ); |
1645 | 1644 | continue; |
1646 | 1645 | } |
1647 | | - echo "Creating index \"$ni[1]\" on table \"$ni[0]\" $ni[2]\n"; |
| 1646 | + wfOut( "Creating index \"$ni[1]\" on table \"$ni[0]\" $ni[2]\n" ); |
1648 | 1647 | $wgDatabase->query( "CREATE INDEX $ni[1] ON $ni[0] $ni[2]" ); |
1649 | 1648 | } |
1650 | 1649 | |
1651 | 1650 | foreach ($newrules as $nr) { |
1652 | 1651 | if ($wgDatabase->ruleExists($nr[0], $nr[1])) { |
1653 | | - echo "... rule \"$nr[1]\" on table \"$nr[0]\" already exists\n"; |
| 1652 | + wfOut( "... rule \"$nr[1]\" on table \"$nr[0]\" already exists\n" ); |
1654 | 1653 | continue; |
1655 | 1654 | } |
1656 | | - echo "Adding rule \"$nr[1]\" to table \"$nr[0]\"\n"; |
| 1655 | + wfOut( "Adding rule \"$nr[1]\" to table \"$nr[0]\"\n" ); |
1657 | 1656 | dbsource(archive($nr[2])); |
1658 | 1657 | } |
1659 | 1658 | |
1660 | 1659 | if ($wgDatabase->hasConstraint("oldimage_oi_name_fkey")) { |
1661 | | - echo "Making foriegn key on table \"oldimage\" (to image) a cascade delete\n"; |
| 1660 | + wfOut( "Making foriegn key on table \"oldimage\" (to image) a cascade delete\n" ); |
1662 | 1661 | $wgDatabase->query( "ALTER TABLE oldimage DROP CONSTRAINT oldimage_oi_name_fkey" ); |
1663 | 1662 | $wgDatabase->query( "ALTER TABLE oldimage ADD CONSTRAINT oldimage_oi_name_fkey_cascade ". |
1664 | 1663 | "FOREIGN KEY (oi_name) REFERENCES image(img_name) ON DELETE CASCADE" ); |
1665 | 1664 | } |
1666 | 1665 | else |
1667 | | - echo "... table \"oldimage\" has correct cascade delete foreign key to image\n"; |
| 1666 | + wfOut( "... table \"oldimage\" has correct cascade delete foreign key to image\n" ); |
1668 | 1667 | |
1669 | 1668 | if (!$wgDatabase->triggerExists("page", "page_deleted")) { |
1670 | | - echo "Adding function and trigger \"page_deleted\" to table \"page\"\n"; |
| 1669 | + wfOut( "Adding function and trigger \"page_deleted\" to table \"page\"\n" ); |
1671 | 1670 | dbsource(archive('patch-page_deleted.sql')); |
1672 | 1671 | } |
1673 | 1672 | else |
1674 | | - echo "... table \"page\" has \"page_deleted\" trigger\n"; |
| 1673 | + wfOut( "... table \"page\" has \"page_deleted\" trigger\n" ); |
1675 | 1674 | |
1676 | 1675 | $fi = $wgDatabase->fieldInfo("recentchanges", "rc_cur_id"); |
1677 | 1676 | if (!$fi->nullable()) { |
1678 | | - echo "Removing NOT NULL constraint from \"recentchanges.rc_cur_id\"\n"; |
| 1677 | + wfOut( "Removing NOT NULL constraint from \"recentchanges.rc_cur_id\"\n" ); |
1679 | 1678 | dbsource(archive('patch-rc_cur_id-not-null.sql')); |
1680 | 1679 | } |
1681 | 1680 | else |
1682 | | - echo "... column \"recentchanges.rc_cur_id\" has a NOT NULL constraint\n"; |
| 1681 | + wfOut( "... column \"recentchanges.rc_cur_id\" has a NOT NULL constraint\n" ); |
1683 | 1682 | |
1684 | 1683 | $pu = pg_describe_index("pagelink_unique"); |
1685 | 1684 | if (!is_null($pu) && ($pu[0] != "pl_from" || $pu[1] != "pl_namespace" || $pu[2] != "pl_title")) { |
1686 | | - echo "Dropping obsolete version of index \"pagelink_unique index\"\n"; |
| 1685 | + wfOut( "Dropping obsolete version of index \"pagelink_unique index\"\n" ); |
1687 | 1686 | $wgDatabase->query("DROP INDEX pagelink_unique"); |
1688 | 1687 | $pu = null; |
1689 | 1688 | } |
1690 | 1689 | else |
1691 | | - echo "... obsolete version of index \"pagelink_unique index\" does not exist\n"; |
| 1690 | + wfOut( "... obsolete version of index \"pagelink_unique index\" does not exist\n" ); |
1692 | 1691 | |
1693 | 1692 | if (is_null($pu)) { |
1694 | | - echo "Creating index \"pagelink_unique index\"\n"; |
| 1693 | + wfOut( "Creating index \"pagelink_unique index\"\n" ); |
1695 | 1694 | $wgDatabase->query("CREATE UNIQUE INDEX pagelink_unique ON pagelinks (pl_from,pl_namespace,pl_title)"); |
1696 | 1695 | } |
1697 | 1696 | else |
1698 | | - echo "... index \"pagelink_unique_index\" already exists\n"; |
| 1697 | + wfOut( "... index \"pagelink_unique_index\" already exists\n" ); |
1699 | 1698 | |
1700 | 1699 | if (pg_fkey_deltype("revision_rev_user_fkey") == 'r') { |
1701 | | - echo "... constraint \"revision_rev_user_fkey\" is ON DELETE RESTRICT\n"; |
| 1700 | + wfOut( "... constraint \"revision_rev_user_fkey\" is ON DELETE RESTRICT\n" ); |
1702 | 1701 | } |
1703 | 1702 | else { |
1704 | | - echo "Changing constraint \"revision_rev_user_fkey\" to ON DELETE RESTRICT\n"; |
| 1703 | + wfOut( "Changing constraint \"revision_rev_user_fkey\" to ON DELETE RESTRICT\n" ); |
1705 | 1704 | dbsource(archive('patch-revision_rev_user_fkey.sql')); |
1706 | 1705 | } |
1707 | 1706 | |
1708 | 1707 | # Fix ipb_address index |
1709 | 1708 | if (pg_index_exists('ipblocks', 'ipb_address' )) { |
1710 | | - echo "Removing deprecated index 'ipb_address'...\n"; |
| 1709 | + wfOut( "Removing deprecated index 'ipb_address'...\n" ); |
1711 | 1710 | $wgDatabase->query('DROP INDEX ipb_address'); |
1712 | 1711 | } |
1713 | 1712 | if (pg_index_exists('ipblocks', 'ipb_address_unique' )) { |
1714 | | - echo "... have ipb_address_unique\n"; |
| 1713 | + wfOut( "... have ipb_address_unique\n" ); |
1715 | 1714 | } |
1716 | 1715 | else { |
1717 | | - echo "Adding ipb_address_unique index\n"; |
| 1716 | + wfOut( "Adding ipb_address_unique index\n" ); |
1718 | 1717 | dbsource(archive('patch-ipb_address_unique.sql')); |
1719 | 1718 | } |
1720 | 1719 | |
— | — | @@ -1721,29 +1720,29 @@ |
1722 | 1721 | # Add missing extension tables |
1723 | 1722 | foreach ( $wgExtNewTables as $nt ) { |
1724 | 1723 | if ($wgDatabase->tableExists($nt[0])) { |
1725 | | - echo "... table \"$nt[0]\" already exists\n"; |
| 1724 | + wfOut( "... table \"$nt[0]\" already exists\n" ); |
1726 | 1725 | continue; |
1727 | 1726 | } |
1728 | | - echo "Creating table \"$nt[0]\"\n"; |
| 1727 | + wfOut( "Creating table \"$nt[0]\"\n" ); |
1729 | 1728 | dbsource($nt[1]); |
1730 | 1729 | } |
1731 | 1730 | # Add missing extension fields |
1732 | 1731 | foreach ( $wgExtPGNewFields as $nc ) { |
1733 | 1732 | $fi = $wgDatabase->fieldInfo($nc[0], $nc[1]); |
1734 | 1733 | if (!is_null($fi)) { |
1735 | | - echo "... column \"$nc[0].$nc[1]\" already exists\n"; |
| 1734 | + wfOut( "... column \"$nc[0].$nc[1]\" already exists\n" ); |
1736 | 1735 | continue; |
1737 | 1736 | } |
1738 | | - echo "Adding column \"$nc[0].$nc[1]\"\n"; |
| 1737 | + wfOut( "Adding column \"$nc[0].$nc[1]\"\n" ); |
1739 | 1738 | $wgDatabase->query( "ALTER TABLE $nc[0] ADD $nc[1] $nc[2]" ); |
1740 | 1739 | } |
1741 | 1740 | # Add missing extension indexes |
1742 | 1741 | foreach ( $wgExtNewIndexes as $ni ) { |
1743 | 1742 | if (pg_index_exists($ni[0], $ni[1])) { |
1744 | | - echo "... index \"$ni[1]\" on table \"$ni[0]\" already exists\n"; |
| 1743 | + wfOut( "... index \"$ni[1]\" on table \"$ni[0]\" already exists\n" ); |
1745 | 1744 | continue; |
1746 | 1745 | } |
1747 | | - echo "Creating index \"$ni[1]\" on table \"$ni[0]\"\n"; |
| 1746 | + wfOut( "Creating index \"$ni[1]\" on table \"$ni[0]\"\n" ); |
1748 | 1747 | dbsource($ni[2]); |
1749 | 1748 | } |
1750 | 1749 | |
Index: branches/REL1_14/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: branches/REL1_14/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: branches/REL1_14/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: branches/REL1_14/phase3/includes/GlobalFunctions.php |
— | — | @@ -2904,6 +2904,21 @@ |
2905 | 2905 | } |
2906 | 2906 | } |
2907 | 2907 | |
| 2908 | +/** |
| 2909 | + * Output some plain text in command-line mode or in the installer (updaters.inc). |
| 2910 | + * Do not use it in any other context, its behaviour is subject to change. |
| 2911 | + */ |
| 2912 | +function wfOut( $s ) { |
| 2913 | + static $lineStarted = false; |
| 2914 | + global $wgCommandLineMode; |
| 2915 | + if ( $wgCommandLineMode && !defined( 'MEDIAWIKI_INSTALL' ) ) { |
| 2916 | + echo $s; |
| 2917 | + } else { |
| 2918 | + echo htmlspecialchars( $s ); |
| 2919 | + } |
| 2920 | + flush(); |
| 2921 | +} |
| 2922 | + |
2908 | 2923 | /** Generate a random 32-character hexadecimal token. |
2909 | 2924 | * @param mixed $salt Some sort of salt, if necessary, to add to random characters before hashing. |
2910 | 2925 | */ |
Index: branches/REL1_14/phase3/includes/db/DatabasePostgres.php |
— | — | @@ -208,10 +208,10 @@ |
209 | 209 | $version = $this->getServerVersion(); |
210 | 210 | $PGMINVER = '8.1'; |
211 | 211 | if ($version < $PGMINVER) { |
212 | | - print "<b>FAILED</b>. Required version is $PGMINVER. You have $version</li>\n"; |
| 212 | + print "<b>FAILED</b>. Required version is $PGMINVER. You have " . htmlspecialchars( $version ) . "</li>\n"; |
213 | 213 | dieout("</ul>"); |
214 | 214 | } |
215 | | - print "version $this->numeric_version is OK.</li>\n"; |
| 215 | + print "version " . htmlspecialchars( $this->numeric_version ) . " is OK.</li>\n"; |
216 | 216 | |
217 | 217 | $safeuser = $this->quote_ident($wgDBuser); |
218 | 218 | // Are we connecting as a superuser for the first time? |
— | — | @@ -225,7 +225,7 @@ |
226 | 226 | FROM pg_catalog.pg_user WHERE usename = " . $this->addQuotes($wgDBsuperuser); |
227 | 227 | $rows = $this->numRows($res = $this->doQuery($SQL)); |
228 | 228 | if (!$rows) { |
229 | | - print "<li>ERROR: Could not read permissions for user \"$wgDBsuperuser\"</li>\n"; |
| 229 | + print "<li>ERROR: Could not read permissions for user \"" . htmlspecialchars( $wgDBsuperuser ) . "\"</li>\n"; |
230 | 230 | dieout('</ul>'); |
231 | 231 | } |
232 | 232 | $perms = pg_fetch_result($res, 0, 0); |
— | — | @@ -233,15 +233,15 @@ |
234 | 234 | $SQL = "SELECT 1 FROM pg_catalog.pg_user WHERE usename = " . $this->addQuotes($wgDBuser); |
235 | 235 | $rows = $this->numRows($this->doQuery($SQL)); |
236 | 236 | if ($rows) { |
237 | | - print "<li>User \"$wgDBuser\" already exists, skipping account creation.</li>"; |
| 237 | + print "<li>User \"" . htmlspecialchars( $wgDBuser ) . "\" already exists, skipping account creation.</li>"; |
238 | 238 | } |
239 | 239 | else { |
240 | 240 | if ($perms != 1 and $perms != 3) { |
241 | | - print "<li>ERROR: the user \"$wgDBsuperuser\" cannot create other users. "; |
| 241 | + print "<li>ERROR: the user \"" . htmlspecialchars( $wgDBsuperuser ) . "\" cannot create other users. "; |
242 | 242 | print 'Please use a different Postgres user.</li>'; |
243 | 243 | dieout('</ul>'); |
244 | 244 | } |
245 | | - print "<li>Creating user <b>$wgDBuser</b>..."; |
| 245 | + print "<li>Creating user <b>" . htmlspecialchars( $wgDBuser ) . "</b>..."; |
246 | 246 | $safepass = $this->addQuotes($wgDBpassword); |
247 | 247 | $SQL = "CREATE USER $safeuser NOCREATEDB PASSWORD $safepass"; |
248 | 248 | $this->doQuery($SQL); |
— | — | @@ -252,15 +252,15 @@ |
253 | 253 | $SQL = "SELECT 1 FROM pg_catalog.pg_database WHERE datname = " . $this->addQuotes($wgDBname); |
254 | 254 | $rows = $this->numRows($this->doQuery($SQL)); |
255 | 255 | if ($rows) { |
256 | | - print "<li>Database \"$wgDBname\" already exists, skipping database creation.</li>"; |
| 256 | + print "<li>Database \"" . htmlspecialchars( $wgDBname ) . "\" already exists, skipping database creation.</li>"; |
257 | 257 | } |
258 | 258 | else { |
259 | 259 | if ($perms < 2) { |
260 | | - print "<li>ERROR: the user \"$wgDBsuperuser\" cannot create databases. "; |
| 260 | + print "<li>ERROR: the user \"" . htmlspecialchars( $wgDBsuperuser ) . "\" cannot create databases. "; |
261 | 261 | print 'Please use a different Postgres user.</li>'; |
262 | 262 | dieout('</ul>'); |
263 | 263 | } |
264 | | - print "<li>Creating database <b>$wgDBname</b>..."; |
| 264 | + print "<li>Creating database <b>" . htmlspecialchars( $wgDBname ) . "</b>..."; |
265 | 265 | $safename = $this->quote_ident($wgDBname); |
266 | 266 | $SQL = "CREATE DATABASE $safename OWNER $safeuser "; |
267 | 267 | $this->doQuery($SQL); |
— | — | @@ -269,17 +269,21 @@ |
270 | 270 | } |
271 | 271 | |
272 | 272 | // Reconnect to check out tsearch2 rights for this user |
273 | | - print "<li>Connecting to \"$wgDBname\" as superuser \"$wgDBsuperuser\" to check rights..."; |
| 273 | + print "<li>Connecting to \"" . htmlspecialchars( $wgDBname ) . "\" as superuser \"" . |
| 274 | + htmlspecialchars( $wgDBsuperuser ) . "\" to check rights..."; |
274 | 275 | |
275 | | - $hstring=""; |
| 276 | + $connectVars = array(); |
276 | 277 | if ($this->mServer!=false && $this->mServer!="") { |
277 | | - $hstring="host=$this->mServer "; |
| 278 | + $connectVars['host'] = $this->mServer; |
278 | 279 | } |
279 | 280 | if ($this->mPort!=false && $this->mPort!="") { |
280 | | - $hstring .= "port=$this->mPort "; |
| 281 | + $connectVars['port'] = $this->mPort; |
281 | 282 | } |
| 283 | + $connectVars['dbname'] = $wgDBname; |
| 284 | + $connectVars['user'] = $wgDBsuperuser; |
| 285 | + $connectVars['password'] = $password; |
282 | 286 | |
283 | | - @$this->mConn = pg_connect("$hstring dbname=$wgDBname user=$wgDBsuperuser password=$password"); |
| 287 | + @$this->mConn = pg_connect( $this->makeConnectionString( $connectVars ) ); |
284 | 288 | if ( $this->mConn == false ) { |
285 | 289 | print "<b>FAILED TO CONNECT!</b></li>"; |
286 | 290 | dieout("</ul>"); |
— | — | @@ -289,15 +293,18 @@ |
290 | 294 | |
291 | 295 | if ($this->numeric_version < 8.3) { |
292 | 296 | // Tsearch2 checks |
293 | | - print "<li>Checking that tsearch2 is installed in the database \"$wgDBname\"..."; |
| 297 | + print "<li>Checking that tsearch2 is installed in the database \"" . |
| 298 | + htmlspecialchars( $wgDBname ) . "\"..."; |
294 | 299 | if (! $this->tableExists("pg_ts_cfg", $wgDBts2schema)) { |
295 | | - print "<b>FAILED</b>. tsearch2 must be installed in the database \"$wgDBname\"."; |
| 300 | + print "<b>FAILED</b>. tsearch2 must be installed in the database \"" . |
| 301 | + htmlspecialchars( $wgDBname ) . "\"."; |
296 | 302 | print "Please see <a href='http://www.devx.com/opensource/Article/21674/0/page/2'>this article</a>"; |
297 | 303 | print " for instructions or ask on #postgresql on irc.freenode.net</li>\n"; |
298 | 304 | dieout("</ul>"); |
299 | 305 | } |
300 | 306 | print "OK</li>\n"; |
301 | | - print "<li>Ensuring that user \"$wgDBuser\" has select rights on the tsearch2 tables..."; |
| 307 | + print "<li>Ensuring that user \"" . htmlspecialchars( $wgDBuser ) . |
| 308 | + "\" has select rights on the tsearch2 tables..."; |
302 | 309 | foreach (array('cfg','cfgmap','dict','parser') as $table) { |
303 | 310 | $SQL = "GRANT SELECT ON pg_ts_$table TO $safeuser"; |
304 | 311 | $this->doQuery($SQL); |
— | — | @@ -309,7 +316,7 @@ |
310 | 317 | $result = $this->schemaExists($wgDBmwschema); |
311 | 318 | $safeschema = $this->quote_ident($wgDBmwschema); |
312 | 319 | if (!$result) { |
313 | | - print "<li>Creating schema <b>$wgDBmwschema</b> ..."; |
| 320 | + print "<li>Creating schema <b>" . htmlspecialchars( $wgDBmwschema ) . "</b> ..."; |
314 | 321 | $result = $this->doQuery("CREATE SCHEMA $safeschema AUTHORIZATION $safeuser"); |
315 | 322 | if (!$result) { |
316 | 323 | print "<b>FAILED</b>.</li>\n"; |
— | — | @@ -355,7 +362,7 @@ |
356 | 363 | |
357 | 364 | if ($this->numeric_version < 8.3) { |
358 | 365 | // Do we have the basic tsearch2 table? |
359 | | - print "<li>Checking for tsearch2 in the schema \"$wgDBts2schema\"..."; |
| 366 | + print "<li>Checking for tsearch2 in the schema \"" . htmlspecialchars( $wgDBts2schema ) . "\"..."; |
360 | 367 | if (! $this->tableExists("pg_ts_dict", $wgDBts2schema)) { |
361 | 368 | print "<b>FAILED</b>. Make sure tsearch2 is installed. See <a href="; |
362 | 369 | print "'http://www.devx.com/opensource/Article/21674/0/page/2'>this article</a>"; |
— | — | @@ -375,12 +382,13 @@ |
376 | 383 | $SQL = "SELECT count(*) FROM $safetsschema.pg_ts_$tname"; |
377 | 384 | $res = $this->doQuery($SQL); |
378 | 385 | if (!$res) { |
379 | | - print "<b>FAILED</b> to access pg_ts_$tname. Make sure that the user ". |
380 | | - "\"$wgDBuser\" has SELECT access to all four tsearch2 tables</li>\n"; |
| 386 | + print "<b>FAILED</b> to access " . htmlspecialchars( "pg_ts_$tname" ) . |
| 387 | + ". Make sure that the user \"". htmlspecialchars( $wgDBuser ) . |
| 388 | + "\" has SELECT access to all four tsearch2 tables</li>\n"; |
381 | 389 | dieout("</ul>"); |
382 | 390 | } |
383 | 391 | } |
384 | | - $SQL = "SELECT ts_name FROM $safetsschema.pg_ts_cfg WHERE locale = '$ctype'"; |
| 392 | + $SQL = "SELECT ts_name FROM $safetsschema.pg_ts_cfg WHERE locale = " . $this->addQuotes( $ctype ) ; |
385 | 393 | $SQL .= " ORDER BY CASE WHEN ts_name <> 'default' THEN 1 ELSE 0 END"; |
386 | 394 | $res = $this->doQuery($SQL); |
387 | 395 | error_reporting( E_ALL ); |
— | — | @@ -391,28 +399,30 @@ |
392 | 400 | print "OK</li>"; |
393 | 401 | |
394 | 402 | // Will the current locale work? Can we force it to? |
395 | | - print "<li>Verifying tsearch2 locale with $ctype..."; |
| 403 | + print "<li>Verifying tsearch2 locale with " . htmlspecialchars( $ctype ) . "..."; |
396 | 404 | $rows = $this->numRows($res); |
397 | 405 | $resetlocale = 0; |
398 | 406 | if (!$rows) { |
399 | 407 | print "<b>not found</b></li>\n"; |
400 | | - print "<li>Attempting to set default tsearch2 locale to \"$ctype\"..."; |
| 408 | + print "<li>Attempting to set default tsearch2 locale to \"" . htmlspecialchars( $ctype ) . "\"..."; |
401 | 409 | $resetlocale = 1; |
402 | 410 | } |
403 | 411 | else { |
404 | 412 | $tsname = pg_fetch_result($res, 0, 0); |
405 | 413 | if ($tsname != 'default') { |
406 | | - print "<b>not set to default ($tsname)</b>"; |
407 | | - print "<li>Attempting to change tsearch2 default locale to \"$ctype\"..."; |
| 414 | + print "<b>not set to default (" . htmlspecialchars( $tsname ) . ")</b>"; |
| 415 | + print "<li>Attempting to change tsearch2 default locale to \"" . |
| 416 | + htmlspecialchars( $ctype ) . "\"..."; |
408 | 417 | $resetlocale = 1; |
409 | 418 | } |
410 | 419 | } |
411 | 420 | if ($resetlocale) { |
412 | | - $SQL = "UPDATE $safetsschema.pg_ts_cfg SET locale = '$ctype' WHERE ts_name = 'default'"; |
| 421 | + $SQL = "UPDATE $safetsschema.pg_ts_cfg SET locale = " . $this->addQuotes( $ctype ) . " WHERE ts_name = 'default'"; |
413 | 422 | $res = $this->doQuery($SQL); |
414 | 423 | if (!$res) { |
415 | 424 | print "<b>FAILED</b>. "; |
416 | | - print "Please make sure that the locale in pg_ts_cfg for \"default\" is set to \"$ctype\"</li>\n"; |
| 425 | + print "Please make sure that the locale in pg_ts_cfg for \"default\" is set to \"" . |
| 426 | + htmlspecialchars( $ctype ) . "\"</li>\n"; |
417 | 427 | dieout("</ul>"); |
418 | 428 | } |
419 | 429 | print "OK</li>"; |
— | — | @@ -422,7 +432,7 @@ |
423 | 433 | $SQL = "SELECT $safetsschema.to_tsvector('default','MediaWiki tsearch2 testing')"; |
424 | 434 | $res = $this->doQuery($SQL); |
425 | 435 | if (!$res) { |
426 | | - print "<b>FAILED</b>. Specifically, \"$SQL\" did not work.</li>"; |
| 436 | + print "<b>FAILED</b>. Specifically, \"" . htmlspecialchars( $SQL ) . "\" did not work.</li>"; |
427 | 437 | dieout("</ul>"); |
428 | 438 | } |
429 | 439 | print "OK</li>"; |
— | — | @@ -434,28 +444,32 @@ |
435 | 445 | // Does the schema already exist? Who owns it? |
436 | 446 | $result = $this->schemaExists($wgDBmwschema); |
437 | 447 | if (!$result) { |
438 | | - print "<li>Creating schema <b>$wgDBmwschema</b> ..."; |
| 448 | + print "<li>Creating schema <b>" . htmlspecialchars( $wgDBmwschema ) . "</b> ..."; |
439 | 449 | error_reporting( 0 ); |
440 | 450 | $safeschema = $this->quote_ident($wgDBmwschema); |
441 | 451 | $result = $this->doQuery("CREATE SCHEMA $safeschema"); |
442 | 452 | error_reporting( E_ALL ); |
443 | 453 | if (!$result) { |
444 | | - print "<b>FAILED</b>. The user \"$wgDBuser\" must be able to access the schema. ". |
| 454 | + print "<b>FAILED</b>. The user \"" . htmlspecialchars( $wgDBuser ) . |
| 455 | + "\" must be able to access the schema. ". |
445 | 456 | "You can try making them the owner of the database, or try creating the schema with a ". |
446 | | - "different user, and then grant access to the \"$wgDBuser\" user.</li>\n"; |
| 457 | + "different user, and then grant access to the \"" . |
| 458 | + htmlspecialchars( $wgDBuser ) . "\" user.</li>\n"; |
447 | 459 | dieout("</ul>"); |
448 | 460 | } |
449 | 461 | print "OK</li>\n"; |
450 | 462 | } |
451 | 463 | else if ($result != $wgDBuser) { |
452 | | - print "<li>Schema \"$wgDBmwschema\" exists but is not owned by \"$wgDBuser\". Not ideal.</li>\n"; |
| 464 | + print "<li>Schema \"" . htmlspecialchars( $wgDBmwschema ) . "\" exists but is not owned by \"" . |
| 465 | + htmlspecialchars( $wgDBuser ) . "\". Not ideal.</li>\n"; |
453 | 466 | } |
454 | 467 | else { |
455 | | - print "<li>Schema \"$wgDBmwschema\" exists and is owned by \"$wgDBuser\". Excellent.</li>\n"; |
| 468 | + print "<li>Schema \"" . htmlspecialchars( $wgDBmwschema ) . "\" exists and is owned by \"" . |
| 469 | + htmlspecialchars( $wgDBuser ) . "\". Excellent.</li>\n"; |
456 | 470 | } |
457 | 471 | |
458 | 472 | // Always return GMT time to accomodate the existing integer-based timestamp assumption |
459 | | - print "<li>Setting the timezone to GMT for user \"$wgDBuser\" ..."; |
| 473 | + print "<li>Setting the timezone to GMT for user \"" . htmlspecialchars( $wgDBuser ) . "\" ..."; |
460 | 474 | $SQL = "ALTER USER $safeuser SET timezone = 'GMT'"; |
461 | 475 | $result = pg_query($this->mConn, $SQL); |
462 | 476 | if (!$result) { |
— | — | @@ -471,7 +485,7 @@ |
472 | 486 | dieout("</ul>"); |
473 | 487 | } |
474 | 488 | |
475 | | - print "<li>Setting the datestyle to ISO, YMD for user \"$wgDBuser\" ..."; |
| 489 | + print "<li>Setting the datestyle to ISO, YMD for user \"" . htmlspecialchars( $wgDBuser ) . "\" ..."; |
476 | 490 | $SQL = "ALTER USER $safeuser SET datestyle = 'ISO, YMD'"; |
477 | 491 | $result = pg_query($this->mConn, $SQL); |
478 | 492 | if (!$result) { |
— | — | @@ -488,7 +502,7 @@ |
489 | 503 | } |
490 | 504 | |
491 | 505 | // Fix up the search paths if needed |
492 | | - print "<li>Setting the search path for user \"$wgDBuser\" ..."; |
| 506 | + print "<li>Setting the search path for user \"" . htmlspecialchars( $wgDBuser ) . "\" ..."; |
493 | 507 | $path = $this->quote_ident($wgDBmwschema); |
494 | 508 | if ($wgDBts2schema !== $wgDBmwschema) |
495 | 509 | $path .= ", ". $this->quote_ident($wgDBts2schema); |
— | — | @@ -529,12 +543,14 @@ |
530 | 544 | $result = $this->doQuery("CREATE LANGUAGE plpgsql"); |
531 | 545 | error_reporting($olde); |
532 | 546 | if (!$result) { |
533 | | - print "<b>FAILED</b>. You need to install the language plpgsql in the database <tt>$wgDBname</tt></li>"; |
| 547 | + print "<b>FAILED</b>. You need to install the language plpgsql in the database <tt>" . |
| 548 | + htmlspecialchars( $wgDBname ) . "</tt></li>"; |
534 | 549 | dieout("</ul>"); |
535 | 550 | } |
536 | 551 | } |
537 | 552 | else { |
538 | | - print "<b>FAILED</b>. You need to install the language plpgsql in the database <tt>$wgDBname</tt></li>"; |
| 553 | + print "<b>FAILED</b>. You need to install the language plpgsql in the database <tt>" . |
| 554 | + htmlspecialchars( $wgDBname ) . "</tt></li>"; |
539 | 555 | dieout("</ul>"); |
540 | 556 | } |
541 | 557 | } |
— | — | @@ -1227,7 +1243,8 @@ |
1228 | 1244 | $res = $this->doQuery($SQL); |
1229 | 1245 | error_reporting( $olde ); |
1230 | 1246 | if (!$res) { |
1231 | | - print "<b>FAILED</b>. Make sure that the user \"$wgDBuser\" can write to the schema \"$wgDBmwschema\"</li>\n"; |
| 1247 | + print "<b>FAILED</b>. Make sure that the user \"" . htmlspecialchars( $wgDBuser ) . |
| 1248 | + "\" can write to the schema \"" . htmlspecialchars( $wgDBmwschema ) . "\"</li>\n"; |
1232 | 1249 | dieout("</ul>"); |
1233 | 1250 | } |
1234 | 1251 | $this->doQuery("DROP TABLE $safeschema.$ctest"); |
— | — | @@ -1242,11 +1259,11 @@ |
1243 | 1260 | $tss = $this->addQuotes($wgDBts2schema); |
1244 | 1261 | $pgp = $this->addQuotes($wgDBport); |
1245 | 1262 | $dbn = $this->addQuotes($this->mDBname); |
1246 | | - $ctype = pg_fetch_result($this->doQuery("SHOW lc_ctype"),0,0); |
| 1263 | + $ctype = $this->addQuotes( pg_fetch_result($this->doQuery("SHOW lc_ctype"),0,0) ); |
1247 | 1264 | |
1248 | 1265 | $SQL = "UPDATE mediawiki_version SET mw_version=$mwv, pg_version=$pgv, pg_user=$pgu, ". |
1249 | 1266 | "mw_schema = $mws, ts2_schema = $tss, pg_port=$pgp, pg_dbname=$dbn, ". |
1250 | | - "ctype = '$ctype' ". |
| 1267 | + "ctype = $ctype ". |
1251 | 1268 | "WHERE type = 'Creation'"; |
1252 | 1269 | $this->query($SQL); |
1253 | 1270 | |
Index: branches/REL1_14/phase3/config/index.php |
— | — | @@ -86,7 +86,8 @@ |
87 | 87 | <html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en" lang="en" dir="ltr"> |
88 | 88 | <head> |
89 | 89 | <meta http-equiv="Content-type" content="text/html; charset=utf-8" /> |
90 | | - <title>MediaWiki <?php echo( $wgVersion ); ?> Installation</title> |
| 90 | + <meta name="robots" content="noindex,nofollow"/> |
| 91 | + <title>MediaWiki <?php echo htmlspecialchars( $wgVersion ); ?> Installation</title> |
91 | 92 | <style type="text/css"> |
92 | 93 | |
93 | 94 | @import "../skins/monobook/main.css"; |
— | — | @@ -204,7 +205,7 @@ |
205 | 206 | <div id="content"> |
206 | 207 | <div id="bodyContent"> |
207 | 208 | |
208 | | -<h1>MediaWiki <?php print $wgVersion ?> Installation</h1> |
| 209 | +<h1>MediaWiki <?php print htmlspecialchars( $wgVersion ) ?> Installation</h1> |
209 | 210 | |
210 | 211 | <?php |
211 | 212 | $mainListOpened = false; # Is the main list (environement checking) opend ? Used by dieout |
— | — | @@ -304,7 +305,7 @@ |
305 | 306 | install_version_checks(); |
306 | 307 | $self = 'Installer'; # Maintenance script name, to please Setup.php |
307 | 308 | |
308 | | -print "<li>PHP " . phpversion() . " installed</li>\n"; |
| 309 | +print "<li>PHP " . htmlspecialchars( phpversion() ) . " installed</li>\n"; |
309 | 310 | |
310 | 311 | error_reporting( 0 ); |
311 | 312 | $phpdatabases = array(); |
— | — | @@ -404,7 +405,7 @@ |
405 | 406 | $conf->safeMode = false; |
406 | 407 | } |
407 | 408 | |
408 | | -$sapi = php_sapi_name(); |
| 409 | +$sapi = htmlspecialchars( php_sapi_name() ); |
409 | 410 | print "<li>PHP server API is $sapi; "; |
410 | 411 | $script = defined('MW_INSTALL_PHP5_EXT') ? 'index.php5' : 'index.php'; |
411 | 412 | if( $wgUsePathInfo ) { |
— | — | @@ -587,6 +588,9 @@ |
588 | 589 | : $_SERVER["SERVER_ADMIN"]; |
589 | 590 | $conf->EmergencyContact = importPost( "EmergencyContact", $defaultEmail ); |
590 | 591 | $conf->DBtype = importPost( "DBtype", $DefaultDBtype ); |
| 592 | + if ( !isset( $ourdb[$conf->DBtype] ) ) { |
| 593 | + $conf->DBtype = $DefaultDBtype; |
| 594 | + } |
591 | 595 | |
592 | 596 | $conf->DBserver = importPost( "DBserver", "localhost" ); |
593 | 597 | $conf->DBname = importPost( "DBname", "wikidb" ); |
— | — | @@ -769,7 +773,7 @@ |
770 | 774 | $errs["DBtype"] = "Unknown database type '$conf->DBtype'"; |
771 | 775 | continue; |
772 | 776 | } |
773 | | - print "<li>Database type: {$conf->DBtypename}</li>\n"; |
| 777 | + print "<li>Database type: " . htmlspecialchars( $conf->DBtypename ) . "</li>\n"; |
774 | 778 | $dbclass = 'Database'.ucfirst($conf->DBtype); |
775 | 779 | $wgDBtype = $conf->DBtype; |
776 | 780 | $wgDBadminuser = "root"; |
— | — | @@ -797,7 +801,7 @@ |
798 | 802 | |
799 | 803 | $wgTitle = Title::newFromText( "Installation script" ); |
800 | 804 | error_reporting( E_ALL ); |
801 | | - print "<li>Loading class: $dbclass</li>\n"; |
| 805 | + print "<li>Loading class: " . htmlspecialchars( $dbclass ) . "</li>\n"; |
802 | 806 | $dbc = new $dbclass; |
803 | 807 | |
804 | 808 | if( $conf->DBtype == 'mysql' ) { |
— | — | @@ -821,7 +825,7 @@ |
822 | 826 | } |
823 | 827 | |
824 | 828 | # Attempt to connect |
825 | | - echo( "<li>Attempting to connect to database server as $db_user..." ); |
| 829 | + echo( "<li>Attempting to connect to database server as " . htmlspecialchars( $db_user ) . "..." ); |
826 | 830 | $wgDatabase = Database::newFromParams( $wgDBserver, $db_user, $db_pass, '', 1 ); |
827 | 831 | |
828 | 832 | # Check the connection and respond to errors |
— | — | @@ -856,7 +860,7 @@ |
857 | 861 | case 2003: |
858 | 862 | default: |
859 | 863 | # General connection problem |
860 | | - echo( "failed with error [$errno] $errtx.</li>\n" ); |
| 864 | + echo( htmlspecialchars( "failed with error [$errno] $errtx." ) . "</li>\n" ); |
861 | 865 | $errs["DBserver"] = "Connection failed"; |
862 | 866 | break; |
863 | 867 | } # switch |
— | — | @@ -870,10 +874,11 @@ |
871 | 875 | ## Possible connect as a superuser |
872 | 876 | if( $useRoot && $conf->DBtype != 'sqlite' ) { |
873 | 877 | $wgDBsuperuser = $conf->RootUser; |
874 | | - echo( "<li>Attempting to connect to database \"postgres\" as superuser \"$wgDBsuperuser\"..." ); |
| 878 | + echo( "<li>Attempting to connect to database \"postgres\" as superuser \"" . |
| 879 | + htmlspecialchars( $wgDBsuperuser ) . "\"..." ); |
875 | 880 | $wgDatabase = $dbc->newFromParams($wgDBserver, $wgDBsuperuser, $conf->RootPW, "postgres", 1); |
876 | 881 | if (!$wgDatabase->isOpen()) { |
877 | | - print " error: " . $wgDatabase->lastError() . "</li>\n"; |
| 882 | + print " error: " . htmlspecialchars( $wgDatabase->lastError() ) . "</li>\n"; |
878 | 883 | $errs["DBserver"] = "Could not connect to database as superuser"; |
879 | 884 | $errs["RootUser"] = "Check username"; |
880 | 885 | $errs["RootPW"] = "and password"; |
— | — | @@ -881,10 +886,11 @@ |
882 | 887 | } |
883 | 888 | $wgDatabase->initial_setup($conf->RootPW, 'postgres'); |
884 | 889 | } |
885 | | - echo( "<li>Attempting to connect to database \"$wgDBname\" as \"$wgDBuser\"..." ); |
| 890 | + echo( "<li>Attempting to connect to database \"" . htmlspecialchars( $wgDBname ) . |
| 891 | + "\" as \"" . htmlspecialchars( $wgDBuser ) . "\"..." ); |
886 | 892 | $wgDatabase = $dbc->newFromParams($wgDBserver, $wgDBuser, $wgDBpassword, $wgDBname, 1); |
887 | 893 | if (!$wgDatabase->isOpen()) { |
888 | | - print " error: " . $wgDatabase->lastError() . "</li>\n"; |
| 894 | + print " error: " . htmlspecialchars( $wgDatabase->lastError() ) . "</li>\n"; |
889 | 895 | } else { |
890 | 896 | $myver = $wgDatabase->getServerVersion(); |
891 | 897 | } |
— | — | @@ -896,7 +902,7 @@ |
897 | 903 | continue; |
898 | 904 | } |
899 | 905 | |
900 | | - print "<li>Connected to {$conf->DBtype} $myver"; |
| 906 | + print "<li>Connected to " . htmlspecialchars( "{$conf->DBtype} $myver" ); |
901 | 907 | if ($conf->DBtype == 'mysql') { |
902 | 908 | if( version_compare( $myver, "4.0.14" ) < 0 ) { |
903 | 909 | print "</li>\n"; |
— | — | @@ -983,15 +989,19 @@ |
984 | 990 | } |
985 | 991 | } |
986 | 992 | if ( $existingSchema && $existingSchema != $conf->DBschema ) { |
987 | | - print "<li><strong>Warning:</strong> you requested the {$conf->DBschema} schema, " . |
988 | | - "but the existing database has the $existingSchema schema. This upgrade script ". |
989 | | - "can't convert it, so it will remain $existingSchema.</li>\n"; |
| 993 | + $encExisting = htmlspecialchars( $existingSchema ); |
| 994 | + $encRequested = htmlspecialchars( $conf->DBschema ); |
| 995 | + print "<li><strong>Warning:</strong> you requested the $encRequested schema, " . |
| 996 | + "but the existing database has the $encExisting schema. This upgrade script ". |
| 997 | + "can't convert it, so it will remain $encExisting.</li>\n"; |
990 | 998 | $conf->setSchema( $existingSchema, $conf->DBengine ); |
991 | 999 | } |
992 | 1000 | if ( $existingEngine && $existingEngine != $conf->DBengine ) { |
993 | | - print "<li><strong>Warning:</strong> you requested the {$conf->DBengine} storage " . |
994 | | - "engine, but the existing database uses the $existingEngine engine. This upgrade " . |
995 | | - "script can't convert it, so it will remain $existingEngine.</li>\n"; |
| 1001 | + $encExisting = htmlspecialchars( $existingEngine ); |
| 1002 | + $encRequested = htmlspecialchars( $conf->DBengine ); |
| 1003 | + print "<li><strong>Warning:</strong> you requested the $encRequested storage " . |
| 1004 | + "engine, but the existing database uses the $encExisting engine. This upgrade " . |
| 1005 | + "script can't convert it, so it will remain $encExisting.</li>\n"; |
996 | 1006 | $conf->setSchema( $conf->DBschema, $existingEngine ); |
997 | 1007 | } |
998 | 1008 | } |
— | — | @@ -1032,7 +1042,8 @@ |
1033 | 1043 | } |
1034 | 1044 | $wgDatabase->freeResult( $res ); |
1035 | 1045 | if ( !$found && $conf->DBengine != 'MyISAM' ) { |
1036 | | - echo "<li><strong>Warning:</strong> {$conf->DBengine} storage engine not available, " . |
| 1046 | + echo "<li><strong>Warning:</strong> " . htmlspecialchars( $conf->DBengine ) . |
| 1047 | + " storage engine not available, " . |
1037 | 1048 | "using MyISAM instead</li>\n"; |
1038 | 1049 | $conf->setSchema( $conf->DBschema, 'MyISAM' ); |
1039 | 1050 | } |
— | — | @@ -1071,10 +1082,10 @@ |
1072 | 1083 | if( $wgDatabase2->isOpen() ) { |
1073 | 1084 | # Nope, just close the test connection and continue |
1074 | 1085 | $wgDatabase2->close(); |
1075 | | - echo( "<li>User $wgDBuser exists. Skipping grants.</li>\n" ); |
| 1086 | + echo( "<li>User " . htmlspecialchars( $wgDBuser ) . " exists. Skipping grants.</li>\n" ); |
1076 | 1087 | } else { |
1077 | 1088 | # Yes, so run the grants |
1078 | | - echo( "<li>Granting user permissions to $wgDBuser on $wgDBname..." ); |
| 1089 | + echo( "<li>" . htmlspecialchars( "Granting user permissions to $wgDBuser on $wgDBname..." ) ); |
1079 | 1090 | dbsource( "../maintenance/users.sql", $wgDatabase ); |
1080 | 1091 | echo( "success.</li>\n" ); |
1081 | 1092 | } |
— | — | @@ -1177,7 +1188,9 @@ |
1178 | 1189 | $list = getLanguageList(); |
1179 | 1190 | foreach( $list as $code => $name ) { |
1180 | 1191 | $sel = ($code == $conf->LanguageCode) ? 'selected="selected"' : ''; |
1181 | | - echo "\n\t\t<option value=\"$code\" $sel>$name</option>"; |
| 1192 | + $encCode = htmlspecialchars( $code ); |
| 1193 | + $encName = htmlspecialchars( $name ); |
| 1194 | + echo "\n\t\t<option value=\"$encCode\" $sel>$encName</option>"; |
1182 | 1195 | } |
1183 | 1196 | echo "\n"; |
1184 | 1197 | ?> |
— | — | @@ -1344,7 +1357,11 @@ |
1345 | 1358 | <div class="config-section"> |
1346 | 1359 | <div class="config-input"> |
1347 | 1360 | <label class='column'>Database type:</label> |
1348 | | -<?php if (isset($errs['DBpicktype'])) print "\t<span class='error'>$errs[DBpicktype]</span>\n"; ?> |
| 1361 | +<?php |
| 1362 | + if (isset($errs['DBpicktype'])) { |
| 1363 | + print "\t<span class='error'>" . htmlspecialchars( $errs[DBpicktype] ) . "</span>\n"; |
| 1364 | + } |
| 1365 | +?> |
1349 | 1366 | <ul class='plain'><?php |
1350 | 1367 | database_picker($conf); |
1351 | 1368 | ?></ul> |
— | — | @@ -1478,7 +1495,7 @@ |
1479 | 1496 | </div> |
1480 | 1497 | </form> |
1481 | 1498 | <script type="text/javascript"> |
1482 | | -window.onload = toggleDBarea('<?php echo $conf->DBtype; ?>', |
| 1499 | +window.onload = toggleDBarea('<?php echo Xml::encodeJsVar( $conf->DBtype ); ?>', |
1483 | 1500 | <?php |
1484 | 1501 | ## If they passed in a root user name, don't populate it on page load |
1485 | 1502 | echo strlen(importPost('RootUser', '')) ? 0 : 1; |
— | — | @@ -1804,10 +1821,8 @@ |
1805 | 1822 | return importVar( $_REQUEST, $name, $default ); |
1806 | 1823 | } |
1807 | 1824 | |
1808 | | -$radioCount = 0; |
1809 | | - |
1810 | 1825 | function aField( &$conf, $field, $text, $type = "text", $value = "", $onclick = '' ) { |
1811 | | - global $radioCount; |
| 1826 | + static $radioCount = 0; |
1812 | 1827 | if( $type != "" ) { |
1813 | 1828 | $xtype = "type=\"$type\""; |
1814 | 1829 | } else { |
— | — | @@ -1847,7 +1862,9 @@ |
1848 | 1863 | } |
1849 | 1864 | |
1850 | 1865 | global $errs; |
1851 | | - if(isset($errs[$field])) echo "<span class='error'>" . $errs[$field] . "</span>\n"; |
| 1866 | + if(isset($errs[$field])) { |
| 1867 | + echo "<span class='error'>" . htmlspecialchars( $errs[$field] ) . "</span>\n"; |
| 1868 | + } |
1852 | 1869 | } |
1853 | 1870 | |
1854 | 1871 | function getLanguageList() { |
— | — | @@ -1940,7 +1957,7 @@ |
1941 | 1958 | fclose( $fp ); |
1942 | 1959 | } |
1943 | 1960 | if ( !$errstr ) { |
1944 | | - echo "<li>Connected to memcached on $host:$port successfully"; |
| 1961 | + echo "<li>Connected to memcached on " . htmlspecialchars( "$host:$port" ) ." successfully</li>"; |
1945 | 1962 | } |
1946 | 1963 | return $errstr; |
1947 | 1964 | } |