Index: branches/REL1_13/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_13/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_13/phase3/maintenance/updaters.inc |
— | — | @@ -171,11 +171,11 @@ |
172 | 172 | global $wgDatabase; |
173 | 173 | if ( $wgDatabase->tableExists( $from ) ) { |
174 | 174 | if ( $wgDatabase->tableExists( $to ) ) { |
175 | | - echo "...can't move table $from to $to, $to already exists.\n"; |
| 175 | + wfOut( "...can't move table $from to $to, $to already exists.\n" ); |
176 | 176 | } else { |
177 | | - echo "Moving table $from to $to..."; |
| 177 | + wfOut( "Moving table $from to $to..." ); |
178 | 178 | dbsource( archive($patch), $wgDatabase ); |
179 | | - echo "ok\n"; |
| 179 | + wfOut( "ok\n" ); |
180 | 180 | } |
181 | 181 | } else { |
182 | 182 | // Source table does not exist |
— | — | @@ -187,47 +187,47 @@ |
188 | 188 | function add_table( $name, $patch, $fullpath=false ) { |
189 | 189 | global $wgDatabase; |
190 | 190 | if ( $wgDatabase->tableExists( $name ) ) { |
191 | | - echo "...$name table already exists.\n"; |
| 191 | + wfOut( "...$name table already exists.\n" ); |
192 | 192 | } else { |
193 | | - echo "Creating $name table..."; |
| 193 | + wfOut( "Creating $name table..." ); |
194 | 194 | if( $fullpath ) { |
195 | 195 | dbsource( $patch, $wgDatabase ); |
196 | 196 | } else { |
197 | 197 | dbsource( archive($patch), $wgDatabase ); |
198 | 198 | } |
199 | | - echo "ok\n"; |
| 199 | + wfOut( "ok\n" ); |
200 | 200 | } |
201 | 201 | } |
202 | 202 | |
203 | 203 | function add_field( $table, $field, $patch, $fullpath=false ) { |
204 | 204 | global $wgDatabase; |
205 | 205 | if ( !$wgDatabase->tableExists( $table ) ) { |
206 | | - echo "...$table table does not exist, skipping new field patch\n"; |
| 206 | + wfOut( "...$table table does not exist, skipping new field patch\n" ); |
207 | 207 | } elseif ( $wgDatabase->fieldExists( $table, $field ) ) { |
208 | | - echo "...have $field field in $table table.\n"; |
| 208 | + wfOut( "...have $field field in $table table.\n" ); |
209 | 209 | } else { |
210 | | - echo "Adding $field field to table $table..."; |
| 210 | + wfOut( "Adding $field field to table $table..." ); |
211 | 211 | if( $fullpath ) { |
212 | 212 | dbsource( $patch, $wgDatabase ); |
213 | 213 | } else { |
214 | 214 | dbsource( archive($patch), $wgDatabase ); |
215 | 215 | } |
216 | | - echo "ok\n"; |
| 216 | + wfOut( "ok\n" ); |
217 | 217 | } |
218 | 218 | } |
219 | 219 | |
220 | 220 | function add_index( $table, $index, $patch, $fullpath=false ) { |
221 | 221 | global $wgDatabase; |
222 | 222 | if( $wgDatabase->indexExists( $table, $index ) ) { |
223 | | - echo "...$index key already set on $table table.\n"; |
| 223 | + wfOut( "...$index key already set on $table table.\n" ); |
224 | 224 | } else { |
225 | | - echo "Adding $index key to table $table... "; |
| 225 | + wfOut( "Adding $index key to table $table... " ); |
226 | 226 | if( $fullpath ) { |
227 | 227 | dbsource( $patch, $wgDatabase ); |
228 | 228 | } else { |
229 | 229 | dbsource( archive($patch), $wgDatabase ); |
230 | 230 | } |
231 | | - echo "ok\n"; |
| 231 | + wfOut( "ok\n" ); |
232 | 232 | } |
233 | 233 | } |
234 | 234 | |
— | — | @@ -243,11 +243,11 @@ |
244 | 244 | |
245 | 245 | global $wgDatabase; |
246 | 246 | $fname = "Update script: update_passwords()"; |
247 | | - print "\nIt appears that you need to update the user passwords in your\n" . |
| 247 | + wfOut( "\nIt appears that you need to update the user passwords in your\n" . |
248 | 248 | "database. If you have already done this (if you've run this update\n" . |
249 | 249 | "script once before, for example), doing so again will make all your\n" . |
250 | 250 | "user accounts inaccessible, so be sure you only do this once.\n" . |
251 | | - "Update user passwords? (yes/no)"; |
| 251 | + "Update user passwords? (yes/no)" ); |
252 | 252 | |
253 | 253 | $resp = readconsole(); |
254 | 254 | if ( ! ( "Y" == $resp{0} || "y" == $resp{0} ) ) { return; } |
— | — | @@ -270,15 +270,15 @@ |
271 | 271 | # Check that interwiki table exists; if it doesn't source it |
272 | 272 | global $wgDatabase, $IP; |
273 | 273 | if( $wgDatabase->tableExists( "interwiki" ) ) { |
274 | | - echo "...already have interwiki table\n"; |
| 274 | + wfOut( "...already have interwiki table\n" ); |
275 | 275 | return true; |
276 | 276 | } |
277 | | - echo "Creating interwiki table: "; |
| 277 | + wfOut( "Creating interwiki table: " ); |
278 | 278 | dbsource( archive("patch-interwiki.sql") ); |
279 | | - echo "ok\n"; |
280 | | - echo "Adding default interwiki definitions: "; |
| 279 | + wfOut( "ok\n" ); |
| 280 | + wfOut( "Adding default interwiki definitions: " ); |
281 | 281 | dbsource( "$IP/maintenance/interwiki.sql" ); |
282 | | - echo "ok\n"; |
| 282 | + wfOut( "ok\n" ); |
283 | 283 | } |
284 | 284 | |
285 | 285 | function do_index_update() { |
— | — | @@ -286,12 +286,12 @@ |
287 | 287 | global $wgDatabase; |
288 | 288 | $meta = $wgDatabase->fieldInfo( "recentchanges", "rc_timestamp" ); |
289 | 289 | if( !$meta->isMultipleKey() ) { |
290 | | - echo "Updating indexes to 20031107: "; |
| 290 | + wfOut( "Updating indexes to 20031107: " ); |
291 | 291 | dbsource( archive("patch-indexes.sql") ); |
292 | | - echo "ok\n"; |
| 292 | + wfOut( "ok\n" ); |
293 | 293 | return true; |
294 | 294 | } |
295 | | - echo "...indexes seem up to 20031107 standards\n"; |
| 295 | + wfOut( "...indexes seem up to 20031107 standards\n" ); |
296 | 296 | return false; |
297 | 297 | } |
298 | 298 | |
— | — | @@ -300,67 +300,67 @@ |
301 | 301 | |
302 | 302 | $meta = $wgDatabase->fieldInfo( "image", "img_major_mime" ); |
303 | 303 | if( !$meta->isMultipleKey() ) { |
304 | | - echo "Updating indexes to 20050912: "; |
| 304 | + wfOut( "Updating indexes to 20050912: " ); |
305 | 305 | dbsource( archive("patch-mimesearch-indexes.sql") ); |
306 | | - echo "ok\n"; |
| 306 | + wfOut( "ok\n" ); |
307 | 307 | return true; |
308 | 308 | } |
309 | | - echo "...indexes seem up to 20050912 standards\n"; |
| 309 | + wfOut( "...indexes seem up to 20050912 standards\n" ); |
310 | 310 | return false; |
311 | 311 | } |
312 | 312 | |
313 | 313 | function do_image_name_unique_update() { |
314 | 314 | global $wgDatabase; |
315 | 315 | if( $wgDatabase->indexExists( 'image', 'PRIMARY' ) ) { |
316 | | - echo "...image primary key already set.\n"; |
| 316 | + wfOut( "...image primary key already set.\n" ); |
317 | 317 | } else { |
318 | | - echo "Making img_name the primary key... "; |
| 318 | + wfOut( "Making img_name the primary key... " ); |
319 | 319 | dbsource( archive("patch-image_name_primary.sql"), $wgDatabase ); |
320 | | - echo "ok\n"; |
| 320 | + wfOut( "ok\n" ); |
321 | 321 | } |
322 | 322 | } |
323 | 323 | |
324 | 324 | function do_logging_timestamp_index() { |
325 | 325 | global $wgDatabase; |
326 | 326 | if( $wgDatabase->indexExists( 'logging', 'times' ) ) { |
327 | | - echo "...timestamp key on logging already exists.\n"; |
| 327 | + wfOut( "...timestamp key on logging already exists.\n" ); |
328 | 328 | } else { |
329 | | - echo "Adding timestamp key on logging table... "; |
| 329 | + wfOut( "Adding timestamp key on logging table... " ); |
330 | 330 | dbsource( archive("patch-logging-times-index.sql"), $wgDatabase ); |
331 | | - echo "ok\n"; |
| 331 | + wfOut( "ok\n" ); |
332 | 332 | } |
333 | 333 | } |
334 | 334 | |
335 | 335 | function do_archive_user_index() { |
336 | 336 | global $wgDatabase; |
337 | 337 | if( $wgDatabase->indexExists( 'archive', 'usertext_timestamp' ) ) { |
338 | | - echo "...usertext,timestamp key on archive already exists.\n"; |
| 338 | + wfOut( "...usertext,timestamp key on archive already exists.\n" ); |
339 | 339 | } else { |
340 | | - echo "Adding usertext,timestamp key on archive table... "; |
| 340 | + wfOut( "Adding usertext,timestamp key on archive table... " ); |
341 | 341 | dbsource( archive("patch-archive-user-index.sql"), $wgDatabase ); |
342 | | - echo "ok\n"; |
| 342 | + wfOut( "ok\n" ); |
343 | 343 | } |
344 | 344 | } |
345 | 345 | |
346 | 346 | function do_image_user_index() { |
347 | 347 | global $wgDatabase; |
348 | 348 | if( $wgDatabase->indexExists( 'image', 'img_usertext_timestamp' ) ) { |
349 | | - echo "...usertext,timestamp key on image already exists.\n"; |
| 349 | + wfOut( "...usertext,timestamp key on image already exists.\n" ); |
350 | 350 | } else { |
351 | | - echo "Adding usertext,timestamp key on image table... "; |
| 351 | + wfOut( "Adding usertext,timestamp key on image table... " ); |
352 | 352 | dbsource( archive("patch-image-user-index.sql"), $wgDatabase ); |
353 | | - echo "ok\n"; |
| 353 | + wfOut( "ok\n" ); |
354 | 354 | } |
355 | 355 | } |
356 | 356 | |
357 | 357 | function do_oldimage_user_index() { |
358 | 358 | global $wgDatabase; |
359 | 359 | if( $wgDatabase->indexExists( 'oldimage', 'oi_usertext_timestamp' ) ) { |
360 | | - echo "...usertext,timestamp key on oldimage already exists.\n"; |
| 360 | + wfOut( "...usertext,timestamp key on oldimage already exists.\n" ); |
361 | 361 | } else { |
362 | | - echo "Adding usertext,timestamp key on oldimage table... "; |
| 362 | + wfOut( "Adding usertext,timestamp key on oldimage table... " ); |
363 | 363 | dbsource( archive("patch-oldimage-user-index.sql"), $wgDatabase ); |
364 | | - echo "ok\n"; |
| 364 | + wfOut( "ok\n" ); |
365 | 365 | } |
366 | 366 | } |
367 | 367 | |
— | — | @@ -368,18 +368,18 @@ |
369 | 369 | global $wgDatabase; |
370 | 370 | $fname = 'do_watchlist_update'; |
371 | 371 | if( $wgDatabase->fieldExists( 'watchlist', 'wl_notificationtimestamp' ) ) { |
372 | | - echo "The watchlist table is already set up for email notification.\n"; |
| 372 | + wfOut( "The watchlist table is already set up for email notification.\n" ); |
373 | 373 | } else { |
374 | | - echo "Adding wl_notificationtimestamp field for email notification management."; |
| 374 | + wfOut( "Adding wl_notificationtimestamp field for email notification management." ); |
375 | 375 | /* ALTER TABLE watchlist ADD (wl_notificationtimestamp varchar(14) binary NOT NULL default '0'); */ |
376 | 376 | dbsource( archive( 'patch-email-notification.sql' ), $wgDatabase ); |
377 | | - echo "ok\n"; |
| 377 | + wfOut( "ok\n" ); |
378 | 378 | } |
379 | 379 | # Check if we need to add talk page rows to the watchlist |
380 | 380 | $talk = $wgDatabase->selectField( 'watchlist', 'count(*)', 'wl_namespace & 1', $fname ); |
381 | 381 | $nontalk = $wgDatabase->selectField( 'watchlist', 'count(*)', 'NOT (wl_namespace & 1)', $fname ); |
382 | 382 | if ( $talk != $nontalk ) { |
383 | | - echo "Adding missing watchlist talk page rows... "; |
| 383 | + wfOut( "Adding missing watchlist talk page rows... " ); |
384 | 384 | flush(); |
385 | 385 | |
386 | 386 | $wgDatabase->insertSelect( 'watchlist', 'watchlist', |
— | — | @@ -389,9 +389,9 @@ |
390 | 390 | 'wl_title' => 'wl_title', |
391 | 391 | 'wl_notificationtimestamp' => 'wl_notificationtimestamp' |
392 | 392 | ), array( 'NOT (wl_namespace & 1)' ), $fname, 'IGNORE' ); |
393 | | - echo "ok\n"; |
| 393 | + wfOut( "ok\n" ); |
394 | 394 | } else { |
395 | | - echo "...watchlist talk page rows already present\n"; |
| 395 | + wfOut( "...watchlist talk page rows already present\n" ); |
396 | 396 | } |
397 | 397 | } |
398 | 398 | |
— | — | @@ -402,7 +402,7 @@ |
403 | 403 | $res = $wgDatabase->safeQuery( 'SELECT user_id, user_ip FROM !', |
404 | 404 | $wgDatabase->tableName( 'user_newtalk' ) ); |
405 | 405 | $num_newtalks=$wgDatabase->numRows($res); |
406 | | - echo "Now converting ".$num_newtalks." user_newtalk entries to watchlist table entries ... \n"; |
| 406 | + wfOut( "Now converting $num_newtalks user_newtalk entries to watchlist table entries ... \n" ); |
407 | 407 | |
408 | 408 | $user = new User(); |
409 | 409 | for ( $i = 1; $i <= $num_newtalks; $i++ ) { |
— | — | @@ -430,18 +430,18 @@ |
431 | 431 | ); |
432 | 432 | } |
433 | 433 | } |
434 | | - echo "Done.\n"; |
| 434 | + wfOut( "Done.\n" ); |
435 | 435 | } |
436 | 436 | |
437 | 437 | |
438 | 438 | function do_user_update() { |
439 | 439 | global $wgDatabase; |
440 | 440 | if( $wgDatabase->fieldExists( 'user', 'user_emailauthenticationtimestamp' ) ) { |
441 | | - echo "User table contains old email authentication field. Dropping... "; |
| 441 | + wfOut( "User table contains old email authentication field. Dropping... " ); |
442 | 442 | dbsource( archive( 'patch-email-authentication.sql' ), $wgDatabase ); |
443 | | - echo "ok\n"; |
| 443 | + wfOut( "ok\n" ); |
444 | 444 | } else { |
445 | | - echo "...user table does not contain old email authentication field.\n"; |
| 445 | + wfOut( "...user table does not contain old email authentication field.\n" ); |
446 | 446 | } |
447 | 447 | } |
448 | 448 | |
— | — | @@ -459,11 +459,11 @@ |
460 | 460 | $wgDatabase->freeResult( $res ); |
461 | 461 | |
462 | 462 | if( in_array( 'binary', $flags ) ) { |
463 | | - echo "$table table has correct $field encoding.\n"; |
| 463 | + wfOut( "$table table has correct $field encoding.\n" ); |
464 | 464 | } else { |
465 | | - echo "Fixing $field encoding on $table table... "; |
| 465 | + wfOut( "Fixing $field encoding on $table table... " ); |
466 | 466 | dbsource( archive( $patchFile ), $wgDatabase ); |
467 | | - echo "ok\n"; |
| 467 | + wfOut( "ok\n" ); |
468 | 468 | } |
469 | 469 | } |
470 | 470 | |
— | — | @@ -471,11 +471,11 @@ |
472 | 472 | global $wgDatabase; |
473 | 473 | $fname="do_schema_restructuring"; |
474 | 474 | if ( $wgDatabase->tableExists( 'page' ) ) { |
475 | | - echo "...page table already exists.\n"; |
| 475 | + wfOut( "...page table already exists.\n" ); |
476 | 476 | } else { |
477 | | - echo "...converting from cur/old to page/revision/text DB structure.\n"; flush(); |
478 | | - echo wfTimestamp( TS_DB ); |
479 | | - echo "......checking for duplicate entries.\n"; flush(); |
| 477 | + wfOut( "...converting from cur/old to page/revision/text DB structure.\n" ); |
| 478 | + wfOut( wfTimestamp( TS_DB ) ); |
| 479 | + wfOut( "......checking for duplicate entries.\n" ); |
480 | 480 | |
481 | 481 | list ($cur, $old, $page, $revision, $text) = $wgDatabase->tableNamesN( 'cur', 'old', 'page', 'revision', 'text' ); |
482 | 482 | |
— | — | @@ -483,15 +483,15 @@ |
484 | 484 | FROM $cur GROUP BY cur_title, cur_namespace HAVING c>1", $fname ); |
485 | 485 | |
486 | 486 | if ( $wgDatabase->numRows( $rows ) > 0 ) { |
487 | | - echo wfTimestamp( TS_DB ); |
488 | | - echo "......<b>Found duplicate entries</b>\n"; |
489 | | - echo ( sprintf( "<b> %-60s %3s %5s</b>\n", 'Title', 'NS', 'Count' ) ); |
| 487 | + wfOut( wfTimestamp( TS_DB ) ); |
| 488 | + wfOut( "......<b>Found duplicate entries</b>\n" ); |
| 489 | + wfOut( sprintf( "<b> %-60s %3s %5s</b>\n", 'Title', 'NS', 'Count' ) ); |
490 | 490 | while ( $row = $wgDatabase->fetchObject( $rows ) ) { |
491 | 491 | if ( ! isset( $duplicate[$row->cur_namespace] ) ) { |
492 | 492 | $duplicate[$row->cur_namespace] = array(); |
493 | 493 | } |
494 | 494 | $duplicate[$row->cur_namespace][] = $row->cur_title; |
495 | | - echo ( sprintf( " %-60s %3s %5s\n", $row->cur_title, $row->cur_namespace, $row->c ) ); |
| 495 | + wfOut( sprintf( " %-60s %3s %5s\n", $row->cur_title, $row->cur_namespace, $row->c ) ); |
496 | 496 | } |
497 | 497 | $sql = "SELECT cur_title, cur_namespace, cur_id, cur_timestamp FROM $cur WHERE "; |
498 | 498 | $firstCond = true; |
— | — | @@ -531,13 +531,13 @@ |
532 | 532 | } |
533 | 533 | $sql = "DELETE FROM $cur WHERE cur_id IN ( " . join( ',', $deleteId ) . ')'; |
534 | 534 | $rows = $wgDatabase->query( $sql, $fname ); |
535 | | - echo wfTimestamp( TS_DB ); |
536 | | - echo "......<b>Deleted</b> ".$wgDatabase->affectedRows()." records.\n"; |
| 535 | + wfOut( wfTimestamp( TS_DB ) ); |
| 536 | + wfOut( "......<b>Deleted</b> ".$wgDatabase->affectedRows()." records.\n" ); |
537 | 537 | } |
538 | 538 | |
539 | 539 | |
540 | | - echo wfTimestamp( TS_DB ); |
541 | | - echo "......Creating tables.\n"; |
| 540 | + wfOut( wfTimestamp( TS_DB ) ); |
| 541 | + wfOut( "......Creating tables.\n" ); |
542 | 542 | $wgDatabase->query("CREATE TABLE $page ( |
543 | 543 | page_id int(8) unsigned NOT NULL auto_increment, |
544 | 544 | page_namespace int NOT NULL, |
— | — | @@ -575,26 +575,26 @@ |
576 | 576 | INDEX usertext_timestamp (rev_user_text,rev_timestamp) |
577 | 577 | ) ENGINE=InnoDB", $fname ); |
578 | 578 | |
579 | | - echo wfTimestamp( TS_DB ); |
580 | | - echo "......Locking tables.\n"; |
| 579 | + wfOut( wfTimestamp( TS_DB ) ); |
| 580 | + wfOut( "......Locking tables.\n" ); |
581 | 581 | $wgDatabase->query( "LOCK TABLES $page WRITE, $revision WRITE, $old WRITE, $cur WRITE", $fname ); |
582 | 582 | |
583 | 583 | $maxold = intval( $wgDatabase->selectField( 'old', 'max(old_id)', '', $fname ) ); |
584 | | - echo wfTimestamp( TS_DB ); |
585 | | - echo "......maxold is {$maxold}\n"; |
| 584 | + wfOut( wfTimestamp( TS_DB ) ); |
| 585 | + wfOut( "......maxold is {$maxold}\n" ); |
586 | 586 | |
587 | | - echo wfTimestamp( TS_DB ); |
| 587 | + wfOut( wfTimestamp( TS_DB ) ); |
588 | 588 | global $wgLegacySchemaConversion; |
589 | 589 | if( $wgLegacySchemaConversion ) { |
590 | 590 | // Create HistoryBlobCurStub entries. |
591 | 591 | // Text will be pulled from the leftover 'cur' table at runtime. |
592 | | - echo "......Moving metadata from cur; using blob references to text in cur table.\n"; |
| 592 | + wfOut( "......Moving metadata from cur; using blob references to text in cur table.\n" ); |
593 | 593 | $cur_text = "concat('O:18:\"historyblobcurstub\":1:{s:6:\"mCurId\";i:',cur_id,';}')"; |
594 | 594 | $cur_flags = "'object'"; |
595 | 595 | } else { |
596 | 596 | // Copy all cur text in immediately: this may take longer but avoids |
597 | 597 | // having to keep an extra table around. |
598 | | - echo "......Moving text from cur.\n"; |
| 598 | + wfOut( "......Moving text from cur.\n" ); |
599 | 599 | $cur_text = 'cur_text'; |
600 | 600 | $cur_flags = "''"; |
601 | 601 | } |
— | — | @@ -603,16 +603,16 @@ |
604 | 604 | SELECT cur_namespace, cur_title, $cur_text, cur_comment, cur_user, cur_user_text, cur_timestamp, cur_minor_edit, $cur_flags |
605 | 605 | FROM $cur", $fname ); |
606 | 606 | |
607 | | - echo wfTimestamp( TS_DB ); |
608 | | - echo "......Setting up revision table.\n"; |
| 607 | + wfOut( wfTimestamp( TS_DB ) ); |
| 608 | + wfOut( "......Setting up revision table.\n" ); |
609 | 609 | $wgDatabase->query( "INSERT INTO $revision (rev_id, rev_page, rev_comment, rev_user, rev_user_text, rev_timestamp, |
610 | 610 | rev_minor_edit) |
611 | 611 | SELECT old_id, cur_id, old_comment, old_user, old_user_text, |
612 | 612 | old_timestamp, old_minor_edit |
613 | 613 | FROM $old,$cur WHERE old_namespace=cur_namespace AND old_title=cur_title", $fname ); |
614 | 614 | |
615 | | - echo wfTimestamp( TS_DB ); |
616 | | - echo "......Setting up page table.\n"; |
| 615 | + wfOut( wfTimestamp( TS_DB ) ); |
| 616 | + wfOut( "......Setting up page table.\n" ); |
617 | 617 | $wgDatabase->query( "INSERT INTO $page (page_id, page_namespace, page_title, page_restrictions, page_counter, |
618 | 618 | page_is_redirect, page_is_new, page_random, page_touched, page_latest, page_len) |
619 | 619 | SELECT cur_id, cur_namespace, cur_title, cur_restrictions, cur_counter, cur_is_redirect, cur_is_new, |
— | — | @@ -620,38 +620,38 @@ |
621 | 621 | FROM $cur,$revision |
622 | 622 | WHERE cur_id=rev_page AND rev_timestamp=cur_timestamp AND rev_id > {$maxold}", $fname ); |
623 | 623 | |
624 | | - echo wfTimestamp( TS_DB ); |
625 | | - echo "......Unlocking tables.\n"; |
| 624 | + wfOut( wfTimestamp( TS_DB ) ); |
| 625 | + wfOut( "......Unlocking tables.\n" ); |
626 | 626 | $wgDatabase->query( "UNLOCK TABLES", $fname ); |
627 | 627 | |
628 | | - echo wfTimestamp( TS_DB ); |
629 | | - echo "......Renaming old.\n"; |
| 628 | + wfOut( wfTimestamp( TS_DB ) ); |
| 629 | + wfOut( "......Renaming old.\n" ); |
630 | 630 | $wgDatabase->query( "ALTER TABLE $old RENAME TO $text", $fname ); |
631 | 631 | |
632 | | - echo wfTimestamp( TS_DB ); |
633 | | - echo "...done.\n"; |
| 632 | + wfOut( wfTimestamp( TS_DB ) ); |
| 633 | + wfOut( "...done.\n" ); |
634 | 634 | } |
635 | 635 | } |
636 | 636 | |
637 | 637 | function do_inverse_timestamp() { |
638 | 638 | global $wgDatabase; |
639 | 639 | if( $wgDatabase->fieldExists( 'revision', 'inverse_timestamp' ) ) { |
640 | | - echo "Removing revision.inverse_timestamp and fixing indexes... "; |
| 640 | + wfOut( "Removing revision.inverse_timestamp and fixing indexes... " ); |
641 | 641 | dbsource( archive( 'patch-inverse_timestamp.sql' ), $wgDatabase ); |
642 | | - echo "ok\n"; |
| 642 | + wfOut( "ok\n" ); |
643 | 643 | } else { |
644 | | - echo "revision timestamp indexes already up to 2005-03-13\n"; |
| 644 | + wfOut( "revision timestamp indexes already up to 2005-03-13\n" ); |
645 | 645 | } |
646 | 646 | } |
647 | 647 | |
648 | 648 | function do_text_id() { |
649 | 649 | global $wgDatabase; |
650 | 650 | if( $wgDatabase->fieldExists( 'revision', 'rev_text_id' ) ) { |
651 | | - echo "...rev_text_id already in place.\n"; |
| 651 | + wfOut( "...rev_text_id already in place.\n" ); |
652 | 652 | } else { |
653 | | - echo "Adding rev_text_id field... "; |
| 653 | + wfOut( "Adding rev_text_id field... " ); |
654 | 654 | dbsource( archive( 'patch-rev_text_id.sql' ), $wgDatabase ); |
655 | | - echo "ok\n"; |
| 655 | + wfOut( "ok\n" ); |
656 | 656 | } |
657 | 657 | } |
658 | 658 | |
— | — | @@ -682,25 +682,25 @@ |
683 | 683 | $wgDatabase->freeResult( $result ); |
684 | 684 | |
685 | 685 | if( substr( $info->Type, 0, 3 ) == 'int' ) { |
686 | | - echo "...$field is already a full int ($info->Type).\n"; |
| 686 | + wfOut( "...$field is already a full int ($info->Type).\n" ); |
687 | 687 | } else { |
688 | | - echo "Promoting $field from $info->Type to int... "; |
| 688 | + wfOut( "Promoting $field from $info->Type to int... " ); |
689 | 689 | |
690 | 690 | $sql = "ALTER TABLE $tablename MODIFY $field int NOT NULL"; |
691 | 691 | $wgDatabase->query( $sql ); |
692 | 692 | |
693 | | - echo "ok\n"; |
| 693 | + wfOut( "ok\n" ); |
694 | 694 | } |
695 | 695 | } |
696 | 696 | |
697 | 697 | function do_pagelinks_update() { |
698 | 698 | global $wgDatabase; |
699 | 699 | if( $wgDatabase->tableExists( 'pagelinks' ) ) { |
700 | | - echo "...already have pagelinks table.\n"; |
| 700 | + wfOut( "...already have pagelinks table.\n" ); |
701 | 701 | } else { |
702 | | - echo "Converting links and brokenlinks tables to pagelinks... "; |
| 702 | + wfOut( "Converting links and brokenlinks tables to pagelinks... " ); |
703 | 703 | dbsource( archive( 'patch-pagelinks.sql' ), $wgDatabase ); |
704 | | - echo "ok\n"; |
| 704 | + wfOut( "ok\n" ); |
705 | 705 | flush(); |
706 | 706 | |
707 | 707 | global $wgCanonicalNamespaceNames; |
— | — | @@ -716,7 +716,7 @@ |
717 | 717 | global $wgDatabase, $wgContLang; |
718 | 718 | |
719 | 719 | $ns = intval( $namespace ); |
720 | | - echo "Cleaning up broken links for namespace $ns... "; |
| 720 | + wfOut( "Cleaning up broken links for namespace $ns... " ); |
721 | 721 | |
722 | 722 | $pagelinks = $wgDatabase->tableName( 'pagelinks' ); |
723 | 723 | $name = $wgContLang->getNsText( $ns ); |
— | — | @@ -730,25 +730,25 @@ |
731 | 731 | AND pl_title LIKE '$likeprefix:%'"; |
732 | 732 | |
733 | 733 | $wgDatabase->query( $sql, 'do_pagelinks_namespace' ); |
734 | | - echo "ok\n"; |
| 734 | + wfOut( "ok\n" ); |
735 | 735 | } |
736 | 736 | |
737 | 737 | function do_drop_img_type() { |
738 | 738 | global $wgDatabase; |
739 | 739 | |
740 | 740 | if( $wgDatabase->fieldExists( 'image', 'img_type' ) ) { |
741 | | - echo "Dropping unused img_type field in image table... "; |
| 741 | + wfOut( "Dropping unused img_type field in image table... " ); |
742 | 742 | dbsource( archive( 'patch-drop_img_type.sql' ), $wgDatabase ); |
743 | | - echo "ok\n"; |
| 743 | + wfOut( "ok\n" ); |
744 | 744 | } else { |
745 | | - echo "No img_type field in image table; Good.\n"; |
| 745 | + wfOut( "No img_type field in image table; Good.\n" ); |
746 | 746 | } |
747 | 747 | } |
748 | 748 | |
749 | 749 | function do_old_links_update() { |
750 | 750 | global $wgDatabase; |
751 | 751 | if( $wgDatabase->tableExists( 'pagelinks' ) ) { |
752 | | - echo "Already have pagelinks; skipping old links table updates.\n"; |
| 752 | + wfOut( "Already have pagelinks; skipping old links table updates.\n" ); |
753 | 753 | } else { |
754 | 754 | convertLinks(); flush(); |
755 | 755 | } |
— | — | @@ -758,14 +758,14 @@ |
759 | 759 | global $wgDatabase; |
760 | 760 | $duper = new UserDupes( $wgDatabase ); |
761 | 761 | if( $duper->hasUniqueIndex() ) { |
762 | | - echo "Already have unique user_name index.\n"; |
| 762 | + wfOut( "Already have unique user_name index.\n" ); |
763 | 763 | } else { |
764 | 764 | if( !$duper->clearDupes() ) { |
765 | | - echo "WARNING: This next step will probably fail due to unfixed duplicates...\n"; |
| 765 | + wfOut( "WARNING: This next step will probably fail due to unfixed duplicates...\n" ); |
766 | 766 | } |
767 | | - echo "Adding unique index on user_name... "; |
| 767 | + wfOut( "Adding unique index on user_name... " ); |
768 | 768 | dbsource( archive( 'patch-user_nameindex.sql' ), $wgDatabase ); |
769 | | - echo "ok\n"; |
| 769 | + wfOut( "ok\n" ); |
770 | 770 | } |
771 | 771 | } |
772 | 772 | |
— | — | @@ -774,28 +774,28 @@ |
775 | 775 | global $wgDatabase; |
776 | 776 | |
777 | 777 | if( $wgDatabase->tableExists( 'user_groups' ) ) { |
778 | | - echo "...user_groups table already exists.\n"; |
| 778 | + wfOut( "...user_groups table already exists.\n" ); |
779 | 779 | return do_user_groups_reformat(); |
780 | 780 | } |
781 | 781 | |
782 | | - echo "Adding user_groups table... "; |
| 782 | + wfOut( "Adding user_groups table... " ); |
783 | 783 | dbsource( archive( 'patch-user_groups.sql' ), $wgDatabase ); |
784 | | - echo "ok\n"; |
| 784 | + wfOut( "ok\n" ); |
785 | 785 | |
786 | 786 | if( !$wgDatabase->tableExists( 'user_rights' ) ) { |
787 | 787 | if( $wgDatabase->fieldExists( 'user', 'user_rights' ) ) { |
788 | | - echo "Upgrading from a 1.3 or older database? Breaking out user_rights for conversion..."; |
| 788 | + wfOut( "Upgrading from a 1.3 or older database? Breaking out user_rights for conversion..." ); |
789 | 789 | dbsource( archive( 'patch-user_rights.sql' ), $wgDatabase ); |
790 | | - echo "ok\n"; |
| 790 | + wfOut( "ok\n" ); |
791 | 791 | } else { |
792 | | - echo "*** WARNING: couldn't locate user_rights table or field for upgrade.\n"; |
793 | | - echo "*** You may need to manually configure some sysops by manipulating\n"; |
794 | | - echo "*** the user_groups table.\n"; |
| 792 | + wfOut( "*** WARNING: couldn't locate user_rights table or field for upgrade.\n" ); |
| 793 | + wfOut( "*** You may need to manually configure some sysops by manipulating\n" ); |
| 794 | + wfOut( "*** the user_groups table.\n" ); |
795 | 795 | return; |
796 | 796 | } |
797 | 797 | } |
798 | 798 | |
799 | | - echo "Converting user_rights table to user_groups... "; |
| 799 | + wfOut( "Converting user_rights table to user_groups... " ); |
800 | 800 | $result = $wgDatabase->select( 'user_rights', |
801 | 801 | array( 'ur_user', 'ur_rights' ), |
802 | 802 | array( "ur_rights != ''" ), |
— | — | @@ -815,7 +815,7 @@ |
816 | 816 | } |
817 | 817 | } |
818 | 818 | $wgDatabase->freeResult( $result ); |
819 | | - echo "ok\n"; |
| 819 | + wfOut( "ok\n" ); |
820 | 820 | } |
821 | 821 | |
822 | 822 | function do_user_groups_reformat() { |
— | — | @@ -826,20 +826,20 @@ |
827 | 827 | if( $info->type() == 'int' ) { |
828 | 828 | $oldug = $wgDatabase->tableName( 'user_groups' ); |
829 | 829 | $newug = $wgDatabase->tableName( 'user_groups_bogus' ); |
830 | | - echo "user_groups is in bogus intermediate format. Renaming to $newug... "; |
| 830 | + wfOut( "user_groups is in bogus intermediate format. Renaming to $newug... " ); |
831 | 831 | $wgDatabase->query( "ALTER TABLE $oldug RENAME TO $newug" ); |
832 | | - echo "ok\n"; |
| 832 | + wfOut( "ok\n" ); |
833 | 833 | |
834 | | - echo "Re-adding fresh user_groups table... "; |
| 834 | + wfOut( "Re-adding fresh user_groups table... " ); |
835 | 835 | dbsource( archive( 'patch-user_groups.sql' ), $wgDatabase ); |
836 | | - echo "ok\n"; |
| 836 | + wfOut( "ok\n" ); |
837 | 837 | |
838 | | - echo "***\n"; |
839 | | - echo "*** WARNING: You will need to manually fix up user permissions in the user_groups\n"; |
840 | | - echo "*** table. Old 1.5 alpha versions did some pretty funky stuff...\n"; |
841 | | - echo "***\n"; |
| 838 | + wfOut( "***\n" ); |
| 839 | + wfOut( "*** WARNING: You will need to manually fix up user permissions in the user_groups\n" ); |
| 840 | + wfOut( "*** table. Old 1.5 alpha versions did some pretty funky stuff...\n" ); |
| 841 | + wfOut( "***\n" ); |
842 | 842 | } else { |
843 | | - echo "...user_groups is in current format.\n"; |
| 843 | + wfOut( "...user_groups is in current format.\n" ); |
844 | 844 | } |
845 | 845 | |
846 | 846 | } |
— | — | @@ -851,11 +851,11 @@ |
852 | 852 | $info = $wgDatabase->fieldInfo( 'watchlist', 'wl_notificationtimestamp' ); |
853 | 853 | |
854 | 854 | if( !$info->nullable() ) { |
855 | | - echo "Making wl_notificationtimestamp nullable... "; |
| 855 | + wfOut( "Making wl_notificationtimestamp nullable... " ); |
856 | 856 | dbsource( archive( 'patch-watchlist-null.sql' ), $wgDatabase ); |
857 | | - echo "ok\n"; |
| 857 | + wfOut( "ok\n" ); |
858 | 858 | } else { |
859 | | - echo "...wl_notificationtimestamp is already nullable.\n"; |
| 859 | + wfOut( "...wl_notificationtimestamp is already nullable.\n" ); |
860 | 860 | } |
861 | 861 | |
862 | 862 | } |
— | — | @@ -866,13 +866,13 @@ |
867 | 867 | function do_page_random_update() { |
868 | 868 | global $wgDatabase; |
869 | 869 | |
870 | | - echo "Setting page_random to a random value on rows where it equals 0..."; |
| 870 | + wfOut( "Setting page_random to a random value on rows where it equals 0..." ); |
871 | 871 | |
872 | 872 | $page = $wgDatabase->tableName( 'page' ); |
873 | 873 | $wgDatabase->query( "UPDATE $page SET page_random = RAND() WHERE page_random = 0", 'do_page_random_update' ); |
874 | 874 | $rows = $wgDatabase->affectedRows(); |
875 | 875 | |
876 | | - echo "changed $rows rows\n"; |
| 876 | + wfOut( "changed $rows rows\n" ); |
877 | 877 | } |
878 | 878 | |
879 | 879 | function do_templatelinks_update() { |
— | — | @@ -880,12 +880,12 @@ |
881 | 881 | $fname = 'do_templatelinks_update'; |
882 | 882 | |
883 | 883 | if ( $wgDatabase->tableExists( 'templatelinks' ) ) { |
884 | | - echo "...templatelinks table already exists\n"; |
| 884 | + wfOut( "...templatelinks table already exists\n" ); |
885 | 885 | return; |
886 | 886 | } |
887 | | - echo "Creating templatelinks table...\n"; |
| 887 | + wfOut( "Creating templatelinks table...\n" ); |
888 | 888 | dbsource( archive('patch-templatelinks.sql'), $wgDatabase ); |
889 | | - echo "Populating...\n"; |
| 889 | + wfOut( "Populating...\n" ); |
890 | 890 | if ( isset( $wgLoadBalancer ) && $wgLoadBalancer->getServerCount() > 1 ) { |
891 | 891 | // Slow, replication-friendly update |
892 | 892 | $res = $wgDatabase->select( 'pagelinks', array( 'pl_from', 'pl_namespace', 'pl_title' ), |
— | — | @@ -922,14 +922,14 @@ |
923 | 923 | ), $fname |
924 | 924 | ); |
925 | 925 | } |
926 | | - echo "Done. Please run maintenance/refreshLinks.php for a more thorough templatelinks update.\n"; |
| 926 | + wfOut( "Done. Please run maintenance/refreshLinks.php for a more thorough templatelinks update.\n" ); |
927 | 927 | } |
928 | 928 | |
929 | 929 | // Add index on ( rc_namespace, rc_user_text ) [Jul. 2006] |
930 | 930 | // Add index on ( rc_user_text, rc_timestamp ) [Nov. 2006] |
931 | 931 | function do_rc_indices_update() { |
932 | 932 | global $wgDatabase; |
933 | | - echo( "Checking for additional recent changes indices...\n" ); |
| 933 | + wfOut( "Checking for additional recent changes indices...\n" ); |
934 | 934 | |
935 | 935 | $indexes = array( |
936 | 936 | 'rc_ns_usertext' => 'patch-recentchanges-utindex.sql', |
— | — | @@ -939,59 +939,59 @@ |
940 | 940 | foreach( $indexes as $index => $patch ) { |
941 | 941 | $info = $wgDatabase->indexInfo( 'recentchanges', $index, __METHOD__ ); |
942 | 942 | if( !$info ) { |
943 | | - echo( "...index `{$index}` not found; adding..." ); |
| 943 | + wfOut( "...index `{$index}` not found; adding..." ); |
944 | 944 | dbsource( archive( $patch ) ); |
945 | | - echo( "done.\n" ); |
| 945 | + wfOut( "done.\n" ); |
946 | 946 | } else { |
947 | | - echo( "...index `{$index}` seems ok.\n" ); |
| 947 | + wfOut( "...index `{$index}` seems ok.\n" ); |
948 | 948 | } |
949 | 949 | } |
950 | 950 | } |
951 | 951 | |
952 | 952 | function index_has_field($table, $index, $field) { |
953 | 953 | global $wgDatabase; |
954 | | - echo( "Checking if $table index $index includes field $field...\n" ); |
| 954 | + wfOut( "Checking if $table index $index includes field $field...\n" ); |
955 | 955 | $info = $wgDatabase->indexInfo( $table, $index, __METHOD__ ); |
956 | 956 | if( $info ) { |
957 | 957 | foreach($info as $row) { |
958 | 958 | if($row->Column_name == $field) { |
959 | | - echo( "...index $index on table $table seems to be ok\n" ); |
| 959 | + wfOut( "...index $index on table $table seems to be ok\n" ); |
960 | 960 | return true; |
961 | 961 | } |
962 | 962 | } |
963 | 963 | } |
964 | | - echo( "...index $index on table $table has no field $field; adding\n" ); |
| 964 | + wfOut( "...index $index on table $table has no field $field; adding\n" ); |
965 | 965 | return false; |
966 | 966 | } |
967 | 967 | |
968 | 968 | function do_backlinking_indices_update() { |
969 | | - echo( "Checking for backlinking indices...\n" ); |
| 969 | + wfOut( "Checking for backlinking indices...\n" ); |
970 | 970 | if (!index_has_field('pagelinks', 'pl_namespace', 'pl_from') || |
971 | 971 | !index_has_field('templatelinks', 'tl_namespace', 'tl_from') || |
972 | 972 | !index_has_field('imagelinks', 'il_to', 'il_from')) |
973 | 973 | { |
974 | 974 | dbsource( archive( 'patch-backlinkindexes.sql' ) ); |
975 | | - echo( "...backlinking indices updated\n" ); |
| 975 | + wfOut( "...backlinking indices updated\n" ); |
976 | 976 | } |
977 | 977 | } |
978 | 978 | |
979 | 979 | function do_categorylinks_indices_update() { |
980 | | - echo( "Checking for categorylinks indices...\n" ); |
| 980 | + wfOut( "Checking for categorylinks indices...\n" ); |
981 | 981 | if (!index_has_field('categorylinks', 'cl_sortkey', 'cl_from')) |
982 | 982 | { |
983 | 983 | dbsource( archive( 'patch-categorylinksindex.sql' ) ); |
984 | | - echo( "...categorylinks indices updated\n" ); |
| 984 | + wfOut( "...categorylinks indices updated\n" ); |
985 | 985 | } |
986 | 986 | } |
987 | 987 | |
988 | 988 | function do_filearchive_indices_update() { |
989 | 989 | global $wgDatabase; |
990 | | - echo( "Checking filearchive indices...\n" ); |
| 990 | + wfOut( "Checking filearchive indices...\n" ); |
991 | 991 | $info = $wgDatabase->indexInfo( 'filearchive', 'fa_user_timestamp', __METHOD__ ); |
992 | 992 | if ( !$info ) |
993 | 993 | { |
994 | 994 | dbsource( archive( 'patch-filearhive-user-index.sql' ) ); |
995 | | - echo( "...filearchive indices updated\n" ); |
| 995 | + wfOut( "...filearchive indices updated\n" ); |
996 | 996 | } |
997 | 997 | } |
998 | 998 | |
— | — | @@ -1000,27 +1000,26 @@ |
1001 | 1001 | if ( !$wgDatabase->tableExists( 'profiling' ) ) { |
1002 | 1002 | // Simply ignore |
1003 | 1003 | } elseif ( $wgDatabase->fieldExists( 'profiling', 'pf_memory' ) ) { |
1004 | | - echo "profiling table has pf_memory field.\n"; |
| 1004 | + wfOut( "profiling table has pf_memory field.\n" ); |
1005 | 1005 | } else { |
1006 | | - echo "Adding pf_memory field to table profiling..."; |
| 1006 | + wfOut( "Adding pf_memory field to table profiling..." ); |
1007 | 1007 | dbsource( archive( 'patch-profiling-memory.sql' ), $wgDatabase ); |
1008 | | - echo "ok\n"; |
| 1008 | + wfOut( "ok\n" ); |
1009 | 1009 | } |
1010 | 1010 | } |
1011 | 1011 | |
1012 | 1012 | function do_stats_init() { |
1013 | 1013 | // Sometimes site_stats table is not properly populated. |
1014 | 1014 | global $wgDatabase; |
1015 | | - echo "Checking site_stats row..."; |
| 1015 | + wfOut( "Checking site_stats row..." ); |
1016 | 1016 | $row = $wgDatabase->selectRow( 'site_stats', '*', array( 'ss_row_id' => 1 ), __METHOD__ ); |
1017 | 1017 | if( $row === false ) { |
1018 | | - echo "data is missing! rebuilding...\n"; |
1019 | | - |
| 1018 | + wfOut( "data is missing! rebuilding...\n" ); |
1020 | 1019 | global $IP; |
1021 | 1020 | require_once "$IP/maintenance/initStats.inc"; |
1022 | 1021 | wfInitStats(); |
1023 | 1022 | } else { |
1024 | | - echo "ok.\n"; |
| 1023 | + wfOut( "ok.\n" ); |
1025 | 1024 | } |
1026 | 1025 | } |
1027 | 1026 | |
— | — | @@ -1028,9 +1027,9 @@ |
1029 | 1028 | global $wgDatabase; |
1030 | 1029 | # We can't guarantee that the user will be able to use TRUNCATE, |
1031 | 1030 | # but we know that DELETE is available to us |
1032 | | - echo( "Purging caches..." ); |
| 1031 | + wfOut( "Purging caches..." ); |
1033 | 1032 | $wgDatabase->delete( 'objectcache', '*', __METHOD__ ); |
1034 | | - echo( "done.\n" ); |
| 1033 | + wfOut( "done.\n" ); |
1035 | 1034 | } |
1036 | 1035 | |
1037 | 1036 | function do_all_updates( $shared = false, $purge = true ) { |
— | — | @@ -1074,15 +1073,14 @@ |
1075 | 1074 | } |
1076 | 1075 | |
1077 | 1076 | |
1078 | | - echo "Deleting old default messages (this may take a long time!)..."; flush(); |
| 1077 | + wfOut( "Deleting old default messages (this may take a long time!)..." ); |
1079 | 1078 | deleteDefaultMessages(); |
1080 | | - echo "Done\n"; flush(); |
| 1079 | + wfOut( "Done\n" ); |
1081 | 1080 | |
1082 | | - do_stats_init(); flush(); |
| 1081 | + do_stats_init(); |
1083 | 1082 | |
1084 | 1083 | if( $purge ) { |
1085 | 1084 | purge_cache(); |
1086 | | - flush(); |
1087 | 1085 | } |
1088 | 1086 | } |
1089 | 1087 | |
— | — | @@ -1108,14 +1106,14 @@ |
1109 | 1107 | $patch2 = 'patch-page_restrictions_sortkey.sql'; |
1110 | 1108 | |
1111 | 1109 | if ( $wgDatabase->tableExists( $name ) ) { |
1112 | | - echo "...$name table already exists.\n"; |
| 1110 | + wfOut( "...$name table already exists.\n" ); |
1113 | 1111 | } else { |
1114 | | - echo "Creating $name table..."; |
| 1112 | + wfOut( "Creating $name table..." ); |
1115 | 1113 | dbsource( archive($patch), $wgDatabase ); |
1116 | 1114 | dbsource( archive($patch2), $wgDatabase ); |
1117 | | - echo "ok\n"; |
| 1115 | + wfOut( "ok\n" ); |
1118 | 1116 | |
1119 | | - echo "Migrating old restrictions to new table..."; |
| 1117 | + wfOut( "Migrating old restrictions to new table..." ); |
1120 | 1118 | |
1121 | 1119 | $res = $wgDatabase->select( 'page', array( 'page_id', 'page_restrictions' ), array("page_restrictions!=''", "page_restrictions!='edit=:move='"), __METHOD__ ); |
1122 | 1120 | |
— | — | @@ -1167,27 +1165,27 @@ |
1168 | 1166 | __METHOD__ ); |
1169 | 1167 | } |
1170 | 1168 | } |
1171 | | - print "ok\n"; |
| 1169 | + wfOut( "ok\n" ); |
1172 | 1170 | } |
1173 | 1171 | } |
1174 | 1172 | |
1175 | 1173 | function do_category_population() { |
1176 | 1174 | if( update_row_exists( 'populate category' ) ) { |
1177 | | - echo "...category table already populated.\n"; |
| 1175 | + wfOut( "...category table already populated.\n" ); |
1178 | 1176 | return; |
1179 | 1177 | } |
1180 | 1178 | require_once( 'populateCategory.inc' ); |
1181 | | - echo "Populating category table, printing progress markers. ". |
| 1179 | + wfOut( "Populating category table, printing progress markers. " ). |
1182 | 1180 | "For large databases, you\n". |
1183 | 1181 | "may want to hit Ctrl-C and do this manually with maintenance/\n". |
1184 | 1182 | "populateCategory.php.\n"; |
1185 | 1183 | populateCategory( '', 10, 0, true ); |
1186 | | - echo "Done populating category table.\n"; |
| 1184 | + wfOut( "Done populating category table.\n" ); |
1187 | 1185 | } |
1188 | 1186 | |
1189 | 1187 | function do_populate_parent_id() { |
1190 | 1188 | if( update_row_exists( 'populate rev_parent_id' ) ) { |
1191 | | - echo "...rev_parent_id column already populated.\n"; |
| 1189 | + wfOut( "...rev_parent_id column already populated.\n" ); |
1192 | 1190 | return; |
1193 | 1191 | } |
1194 | 1192 | require_once( 'populateParentId.inc' ); |
— | — | @@ -1198,11 +1196,11 @@ |
1199 | 1197 | |
1200 | 1198 | function update_password_format() { |
1201 | 1199 | if ( update_row_exists( 'password format' ) ) { |
1202 | | - echo "...password hash format already changed\n"; |
| 1200 | + wfOut( "...password hash format already changed\n" ); |
1203 | 1201 | return; |
1204 | 1202 | } |
1205 | 1203 | |
1206 | | - echo "Updating password hash format..."; |
| 1204 | + wfOut( "Updating password hash format..." ); |
1207 | 1205 | |
1208 | 1206 | global $wgDatabase, $wgPasswordSalt; |
1209 | 1207 | $user = $wgDatabase->tableName( 'user' ); |
— | — | @@ -1216,7 +1214,7 @@ |
1217 | 1215 | $wgDatabase->query( $sql, __METHOD__ ); |
1218 | 1216 | $wgDatabase->insert( 'updatelog', array( 'ul_key' => 'password format' ), __METHOD__ ); |
1219 | 1217 | |
1220 | | - echo "done\n"; |
| 1218 | + wfOut( "done\n" ); |
1221 | 1219 | } |
1222 | 1220 | |
1223 | 1221 | function |
— | — | @@ -1376,11 +1374,11 @@ |
1377 | 1375 | $search_path = $conf['search_path']; |
1378 | 1376 | } |
1379 | 1377 | if( strpos( $search_path, $wgDBmwschema ) === false ) { |
1380 | | - echo "Adding in schema \"$wgDBmwschema\" to search_path for user \"$wgDBuser\"\n"; |
| 1378 | + wfOut( "Adding in schema \"$wgDBmwschema\" to search_path for user \"$wgDBuser\"\n" ); |
1381 | 1379 | $search_path = "$wgDBmwschema, $search_path"; |
1382 | 1380 | } |
1383 | 1381 | if( strpos( $search_path, $wgDBts2schema ) === false ) { |
1384 | | - echo "Adding in schema \"$wgDBts2schema\" to search_path for user \"$wgDBuser\"\n"; |
| 1382 | + wfOut( "Adding in schema \"$wgDBts2schema\" to search_path for user \"$wgDBuser\"\n" ); |
1385 | 1383 | $search_path = "$search_path, $wgDBts2schema"; |
1386 | 1384 | } |
1387 | 1385 | if( array_key_exists( 'search_path', $conf ) === false || $search_path != $conf['search_path'] ) { |
— | — | @@ -1389,7 +1387,7 @@ |
1390 | 1388 | } |
1391 | 1389 | else { |
1392 | 1390 | $path = $conf['search_path']; |
1393 | | - echo "... search_path for user \"$wgDBuser\" looks correct ($path)\n"; |
| 1391 | + wfOut( "... search_path for user \"$wgDBuser\" looks correct ($path)\n" ); |
1394 | 1392 | } |
1395 | 1393 | $goodconf = array( |
1396 | 1394 | 'client_min_messages' => 'error', |
— | — | @@ -1399,12 +1397,12 @@ |
1400 | 1398 | foreach( array_keys( $goodconf ) AS $key ) { |
1401 | 1399 | $value = $goodconf[$key]; |
1402 | 1400 | if( !array_key_exists( $key, $conf ) or $conf[$key] !== $value ) { |
1403 | | - echo "Setting $key to '$value' for user \"$wgDBuser\"\n"; |
| 1401 | + wfOut( "Setting $key to '$value' for user \"$wgDBuser\"\n" ); |
1404 | 1402 | $wgDatabase->doQuery( "ALTER USER $wgDBuser SET $key = '$value'" ); |
1405 | 1403 | $wgDatabase->doQuery( "SET $key = '$value'" ); |
1406 | 1404 | } |
1407 | 1405 | else { |
1408 | | - echo "... default value of \"$key\" is correctly set to \"$value\" for user \"$wgDBuser\"\n"; |
| 1406 | + wfOut( "... default value of \"$key\" is correctly set to \"$value\" for user \"$wgDBuser\"\n" ); |
1409 | 1407 | } |
1410 | 1408 | } |
1411 | 1409 | |
— | — | @@ -1526,62 +1524,62 @@ |
1527 | 1525 | |
1528 | 1526 | foreach ($newsequences as $ns) { |
1529 | 1527 | if ($wgDatabase->sequenceExists($ns)) { |
1530 | | - echo "... sequence \"$ns\" already exists\n"; |
| 1528 | + wfOut( "... sequence \"$ns\" already exists\n" ); |
1531 | 1529 | continue; |
1532 | 1530 | } |
1533 | 1531 | |
1534 | | - echo "Creating sequence \"$ns\"\n"; |
| 1532 | + wfOut( "Creating sequence \"$ns\"\n" ); |
1535 | 1533 | $wgDatabase->query("CREATE SEQUENCE $ns"); |
1536 | 1534 | } |
1537 | 1535 | |
1538 | 1536 | foreach ($newtables as $nt) { |
1539 | 1537 | if ($wgDatabase->tableExists($nt[0])) { |
1540 | | - echo "... table \"$nt[0]\" already exists\n"; |
| 1538 | + wfOut( "... table \"$nt[0]\" already exists\n" ); |
1541 | 1539 | continue; |
1542 | 1540 | } |
1543 | 1541 | |
1544 | | - echo "Creating table \"$nt[0]\"\n"; |
| 1542 | + wfOut( "Creating table \"$nt[0]\"\n" ); |
1545 | 1543 | dbsource(archive($nt[1])); |
1546 | 1544 | } |
1547 | 1545 | |
1548 | 1546 | ## Needed before newcols |
1549 | 1547 | if ($wgDatabase->tableExists("archive2")) { |
1550 | | - echo "Converting \"archive2\" back to normal archive table\n"; |
| 1548 | + wfOut( "Converting \"archive2\" back to normal archive table\n" ); |
1551 | 1549 | if ($wgDatabase->ruleExists("archive", "archive_insert")) { |
1552 | | - echo "Dropping rule \"archive_insert\"\n"; |
| 1550 | + wfOut( "Dropping rule \"archive_insert\"\n" ); |
1553 | 1551 | $wgDatabase->query("DROP RULE archive_insert ON archive"); |
1554 | 1552 | } |
1555 | 1553 | if ($wgDatabase->ruleExists("archive", "archive_delete")) { |
1556 | | - echo "Dropping rule \"archive_delete\"\n"; |
| 1554 | + wfOut( "Dropping rule \"archive_delete\"\n" ); |
1557 | 1555 | $wgDatabase->query("DROP RULE archive_delete ON archive"); |
1558 | 1556 | } |
1559 | 1557 | dbsource(archive("patch-remove-archive2.sql")); |
1560 | 1558 | } |
1561 | 1559 | else |
1562 | | - echo "... obsolete table \"archive2\" does not exist\n"; |
| 1560 | + wfOut( "... obsolete table \"archive2\" does not exist\n" ); |
1563 | 1561 | |
1564 | 1562 | foreach ($newcols as $nc) { |
1565 | 1563 | $fi = $wgDatabase->fieldInfo($nc[0], $nc[1]); |
1566 | 1564 | if (!is_null($fi)) { |
1567 | | - echo "... column \"$nc[0].$nc[1]\" already exists\n"; |
| 1565 | + wfOut( "... column \"$nc[0].$nc[1]\" already exists\n" ); |
1568 | 1566 | continue; |
1569 | 1567 | } |
1570 | 1568 | |
1571 | | - echo "Adding column \"$nc[0].$nc[1]\"\n"; |
| 1569 | + wfOut( "Adding column \"$nc[0].$nc[1]\"\n" ); |
1572 | 1570 | $wgDatabase->query("ALTER TABLE $nc[0] ADD $nc[1] $nc[2]"); |
1573 | 1571 | } |
1574 | 1572 | |
1575 | 1573 | foreach ($typechanges as $tc) { |
1576 | 1574 | $fi = $wgDatabase->fieldInfo($tc[0], $tc[1]); |
1577 | 1575 | if (is_null($fi)) { |
1578 | | - echo "... error: expected column $tc[0].$tc[1] to exist\n"; |
| 1576 | + wfOut( "... error: expected column $tc[0].$tc[1] to exist\n" ); |
1579 | 1577 | exit(1); |
1580 | 1578 | } |
1581 | 1579 | |
1582 | 1580 | if ($fi->type() === $tc[2]) |
1583 | | - echo "... column \"$tc[0].$tc[1]\" is already of type \"$tc[2]\"\n"; |
| 1581 | + wfOut( "... column \"$tc[0].$tc[1]\" is already of type \"$tc[2]\"\n" ); |
1584 | 1582 | else { |
1585 | | - echo "Changing column type of \"$tc[0].$tc[1]\" from \"{$fi->type()}\" to \"$tc[2]\"\n"; |
| 1583 | + wfOut( "Changing column type of \"$tc[0].$tc[1]\" from \"{$fi->type()}\" to \"$tc[2]\"\n" ); |
1586 | 1584 | $sql = "ALTER TABLE $tc[0] ALTER $tc[1] TYPE $tc[2]"; |
1587 | 1585 | if (strlen($tc[3])) { |
1588 | 1586 | $default = array(); |
— | — | @@ -1598,86 +1596,86 @@ |
1599 | 1597 | } |
1600 | 1598 | |
1601 | 1599 | if ($wgDatabase->fieldInfo('oldimage','oi_deleted')->type() !== 'smallint') { |
1602 | | - echo "Changing \"oldimage.oi_deleted\" to type \"smallint\"\n"; |
| 1600 | + wfOut( "Changing \"oldimage.oi_deleted\" to type \"smallint\"\n" ); |
1603 | 1601 | $wgDatabase->query( "ALTER TABLE oldimage ALTER oi_deleted DROP DEFAULT" ); |
1604 | 1602 | $wgDatabase->query( "ALTER TABLE oldimage ALTER oi_deleted TYPE SMALLINT USING (oi_deleted::smallint)" ); |
1605 | 1603 | $wgDatabase->query( "ALTER TABLE oldimage ALTER oi_deleted SET DEFAULT 0" ); |
1606 | 1604 | } |
1607 | 1605 | else |
1608 | | - echo "... column \"oldimage.oi_deleted\" is already of type \"smallint\"\n"; |
| 1606 | + wfOut( "... column \"oldimage.oi_deleted\" is already of type \"smallint\"\n" ); |
1609 | 1607 | |
1610 | 1608 | |
1611 | 1609 | foreach ($newindexes as $ni) { |
1612 | 1610 | if (pg_index_exists($ni[0], $ni[1])) { |
1613 | | - echo "... index \"$ni[1]\" on table \"$ni[0]\" already exists\n"; |
| 1611 | + wfOut( "... index \"$ni[1]\" on table \"$ni[0]\" already exists\n" ); |
1614 | 1612 | continue; |
1615 | 1613 | } |
1616 | | - echo "Creating index \"$ni[1]\" on table \"$ni[0]\" $ni[2]\n"; |
| 1614 | + wfOut( "Creating index \"$ni[1]\" on table \"$ni[0]\" $ni[2]\n" ); |
1617 | 1615 | $wgDatabase->query( "CREATE INDEX $ni[1] ON $ni[0] $ni[2]" ); |
1618 | 1616 | } |
1619 | 1617 | |
1620 | 1618 | foreach ($newrules as $nr) { |
1621 | 1619 | if ($wgDatabase->ruleExists($nr[0], $nr[1])) { |
1622 | | - echo "... rule \"$nr[1]\" on table \"$nr[0]\" already exists\n"; |
| 1620 | + wfOut( "... rule \"$nr[1]\" on table \"$nr[0]\" already exists\n" ); |
1623 | 1621 | continue; |
1624 | 1622 | } |
1625 | | - echo "Adding rule \"$nr[1]\" to table \"$nr[0]\"\n"; |
| 1623 | + wfOut( "Adding rule \"$nr[1]\" to table \"$nr[0]\"\n" ); |
1626 | 1624 | dbsource(archive($nr[2])); |
1627 | 1625 | } |
1628 | 1626 | |
1629 | 1627 | if ($wgDatabase->hasConstraint("oldimage_oi_name_fkey")) { |
1630 | | - echo "Making foriegn key on table \"oldimage\" (to image) a cascade delete\n"; |
| 1628 | + wfOut( "Making foriegn key on table \"oldimage\" (to image) a cascade delete\n" ); |
1631 | 1629 | $wgDatabase->query( "ALTER TABLE oldimage DROP CONSTRAINT oldimage_oi_name_fkey" ); |
1632 | 1630 | $wgDatabase->query( "ALTER TABLE oldimage ADD CONSTRAINT oldimage_oi_name_fkey_cascade ". |
1633 | 1631 | "FOREIGN KEY (oi_name) REFERENCES image(img_name) ON DELETE CASCADE" ); |
1634 | 1632 | } |
1635 | 1633 | else |
1636 | | - echo "... table \"oldimage\" has correct cascade delete foreign key to image\n"; |
| 1634 | + wfOut( "... table \"oldimage\" has correct cascade delete foreign key to image\n" ); |
1637 | 1635 | |
1638 | 1636 | if (!$wgDatabase->triggerExists("page", "page_deleted")) { |
1639 | | - echo "Adding function and trigger \"page_deleted\" to table \"page\"\n"; |
| 1637 | + wfOut( "Adding function and trigger \"page_deleted\" to table \"page\"\n" ); |
1640 | 1638 | dbsource(archive('patch-page_deleted.sql')); |
1641 | 1639 | } |
1642 | 1640 | else |
1643 | | - echo "... table \"page\" has \"page_deleted\" trigger\n"; |
| 1641 | + wfOut( "... table \"page\" has \"page_deleted\" trigger\n" ); |
1644 | 1642 | |
1645 | 1643 | $fi = $wgDatabase->fieldInfo("recentchanges", "rc_cur_id"); |
1646 | 1644 | if (!$fi->nullable()) { |
1647 | | - echo "Removing NOT NULL constraint from \"recentchanges.rc_cur_id\"\n"; |
| 1645 | + wfOut( "Removing NOT NULL constraint from \"recentchanges.rc_cur_id\"\n" ); |
1648 | 1646 | dbsource(archive('patch-rc_cur_id-not-null.sql')); |
1649 | 1647 | } |
1650 | 1648 | else |
1651 | | - echo "... column \"recentchanges.rc_cur_id\" has a NOT NULL constraint\n"; |
| 1649 | + wfOut( "... column \"recentchanges.rc_cur_id\" has a NOT NULL constraint\n" ); |
1652 | 1650 | |
1653 | 1651 | $pu = pg_describe_index("pagelink_unique"); |
1654 | 1652 | if (!is_null($pu) && ($pu[0] != "pl_from" || $pu[1] != "pl_namespace" || $pu[2] != "pl_title")) { |
1655 | | - echo "Dropping obsolete version of index \"pagelink_unique index\"\n"; |
| 1653 | + wfOut( "Dropping obsolete version of index \"pagelink_unique index\"\n" ); |
1656 | 1654 | $wgDatabase->query("DROP INDEX pagelink_unique"); |
1657 | 1655 | $pu = null; |
1658 | 1656 | } |
1659 | 1657 | else |
1660 | | - echo "... obsolete version of index \"pagelink_unique index\" does not exist\n"; |
| 1658 | + wfOut( "... obsolete version of index \"pagelink_unique index\" does not exist\n" ); |
1661 | 1659 | |
1662 | 1660 | if (is_null($pu)) { |
1663 | | - echo "Creating index \"pagelink_unique index\"\n"; |
| 1661 | + wfOut( "Creating index \"pagelink_unique index\"\n" ); |
1664 | 1662 | $wgDatabase->query("CREATE UNIQUE INDEX pagelink_unique ON pagelinks (pl_from,pl_namespace,pl_title)"); |
1665 | 1663 | } |
1666 | 1664 | else |
1667 | | - echo "... index \"pagelink_unique_index\" already exists\n"; |
| 1665 | + wfOut( "... index \"pagelink_unique_index\" already exists\n" ); |
1668 | 1666 | |
1669 | 1667 | if (pg_fkey_deltype("revision_rev_user_fkey") == 'r') { |
1670 | | - echo "... constraint \"revision_rev_user_fkey\" is ON DELETE RESTRICT\n"; |
| 1668 | + wfOut( "... constraint \"revision_rev_user_fkey\" is ON DELETE RESTRICT\n" ); |
1671 | 1669 | } |
1672 | 1670 | else { |
1673 | | - echo "Changing constraint \"revision_rev_user_fkey\" to ON DELETE RESTRICT\n"; |
| 1671 | + wfOut( "Changing constraint \"revision_rev_user_fkey\" to ON DELETE RESTRICT\n" ); |
1674 | 1672 | dbsource(archive('patch-revision_rev_user_fkey.sql')); |
1675 | 1673 | } |
1676 | 1674 | |
1677 | 1675 | # Fix ipb_address index |
1678 | 1676 | if (pg_index_exists('ipblocks', 'ipb_address_unique' )) { |
1679 | | - echo "... have ipb_address_unique\n"; |
| 1677 | + wfOut( "... have ipb_address_unique\n" ); |
1680 | 1678 | } else { |
1681 | | - echo "Adding ipb_address_unique index\n"; |
| 1679 | + wfOut( "Adding ipb_address_unique index\n" ); |
1682 | 1680 | dbsource(archive('patch-ipb_address_unique.sql')); |
1683 | 1681 | } |
1684 | 1682 | |
— | — | @@ -1685,29 +1683,29 @@ |
1686 | 1684 | # Add missing extension tables |
1687 | 1685 | foreach ( $wgExtNewTables as $nt ) { |
1688 | 1686 | if ($wgDatabase->tableExists($nt[0])) { |
1689 | | - echo "... table \"$nt[0]\" already exists\n"; |
| 1687 | + wfOut( "... table \"$nt[0]\" already exists\n" ); |
1690 | 1688 | continue; |
1691 | 1689 | } |
1692 | | - echo "Creating table \"$nt[0]\"\n"; |
| 1690 | + wfOut( "Creating table \"$nt[0]\"\n" ); |
1693 | 1691 | dbsource($nt[1]); |
1694 | 1692 | } |
1695 | 1693 | # Add missing extension fields |
1696 | 1694 | foreach ( $wgExtPGNewFields as $nc ) { |
1697 | 1695 | $fi = $wgDatabase->fieldInfo($nc[0], $nc[1]); |
1698 | 1696 | if (!is_null($fi)) { |
1699 | | - echo "... column \"$nc[0].$nc[1]\" already exists\n"; |
| 1697 | + wfOut( "... column \"$nc[0].$nc[1]\" already exists\n" ); |
1700 | 1698 | continue; |
1701 | 1699 | } |
1702 | | - echo "Adding column \"$nc[0].$nc[1]\"\n"; |
| 1700 | + wfOut( "Adding column \"$nc[0].$nc[1]\"\n" ); |
1703 | 1701 | $wgDatabase->query( "ALTER TABLE $nc[0] ADD $nc[1] $nc[2]" ); |
1704 | 1702 | } |
1705 | 1703 | # Add missing extension indexes |
1706 | 1704 | foreach ( $wgExtNewIndexes as $ni ) { |
1707 | 1705 | if (pg_index_exists($ni[0], $ni[1])) { |
1708 | | - echo "... index \"$ni[1]\" on table \"$ni[0]\" already exists\n"; |
| 1706 | + wfOut( "... index \"$ni[1]\" on table \"$ni[0]\" already exists\n" ); |
1709 | 1707 | continue; |
1710 | 1708 | } |
1711 | | - echo "Creating index \"$ni[1]\" on table \"$ni[0]\"\n"; |
| 1709 | + wfOut( "Creating index \"$ni[1]\" on table \"$ni[0]\"\n" ); |
1712 | 1710 | dbsource($ni[2]); |
1713 | 1711 | } |
1714 | 1712 | |
Index: branches/REL1_13/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_13/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_13/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_13/phase3/includes/GlobalFunctions.php |
— | — | @@ -2769,6 +2769,21 @@ |
2770 | 2770 | } |
2771 | 2771 | } |
2772 | 2772 | |
| 2773 | +/** |
| 2774 | + * Output some plain text in command-line mode or in the installer (updaters.inc). |
| 2775 | + * Do not use it in any other context, its behaviour is subject to change. |
| 2776 | + */ |
| 2777 | +function wfOut( $s ) { |
| 2778 | + static $lineStarted = false; |
| 2779 | + global $wgCommandLineMode; |
| 2780 | + if ( $wgCommandLineMode && !defined( 'MEDIAWIKI_INSTALL' ) ) { |
| 2781 | + echo $s; |
| 2782 | + } else { |
| 2783 | + echo htmlspecialchars( $s ); |
| 2784 | + } |
| 2785 | + flush(); |
| 2786 | +} |
| 2787 | + |
2773 | 2788 | /** Generate a random 32-character hexadecimal token. |
2774 | 2789 | * @param mixed $salt Some sort of salt, if necessary, to add to random characters before hashing. |
2775 | 2790 | */ |
Index: branches/REL1_13/phase3/includes/db/DatabasePostgres.php |
— | — | @@ -198,10 +198,11 @@ |
199 | 199 | $version = $this->getServerVersion(); |
200 | 200 | $PGMINVER = '8.1'; |
201 | 201 | if ($this->numeric_version < $PGMINVER) { |
202 | | - print "<b>FAILED</b>. Required version is $PGMINVER. You have $this->numeric_version ($version)</li>\n"; |
| 202 | + print "<b>FAILED</b>. Required version is $PGMINVER. You have " . |
| 203 | + htmlspecialchars( $this->numeric_version ) . " (" . htmlspecialchars( $version ) . ")</li>\n"; |
203 | 204 | dieout("</ul>"); |
204 | 205 | } |
205 | | - print "version $this->numeric_version is OK.</li>\n"; |
| 206 | + print "version " . htmlspecialchars( $this->numeric_version ) . " is OK.</li>\n"; |
206 | 207 | |
207 | 208 | $safeuser = $this->quote_ident($wgDBuser); |
208 | 209 | // Are we connecting as a superuser for the first time? |
— | — | @@ -215,7 +216,7 @@ |
216 | 217 | FROM pg_catalog.pg_user WHERE usename = " . $this->addQuotes($wgDBsuperuser); |
217 | 218 | $rows = $this->numRows($res = $this->doQuery($SQL)); |
218 | 219 | if (!$rows) { |
219 | | - print "<li>ERROR: Could not read permissions for user \"$wgDBsuperuser\"</li>\n"; |
| 220 | + print "<li>ERROR: Could not read permissions for user \"" . htmlspecialchars( $wgDBsuperuser ) . "\"</li>\n"; |
220 | 221 | dieout('</ul>'); |
221 | 222 | } |
222 | 223 | $perms = pg_fetch_result($res, 0, 0); |
— | — | @@ -223,15 +224,15 @@ |
224 | 225 | $SQL = "SELECT 1 FROM pg_catalog.pg_user WHERE usename = " . $this->addQuotes($wgDBuser); |
225 | 226 | $rows = $this->numRows($this->doQuery($SQL)); |
226 | 227 | if ($rows) { |
227 | | - print "<li>User \"$wgDBuser\" already exists, skipping account creation.</li>"; |
| 228 | + print "<li>User \"" . htmlspecialchars( $wgDBuser ) . "\" already exists, skipping account creation.</li>"; |
228 | 229 | } |
229 | 230 | else { |
230 | 231 | if ($perms != 1 and $perms != 3) { |
231 | | - print "<li>ERROR: the user \"$wgDBsuperuser\" cannot create other users. "; |
| 232 | + print "<li>ERROR: the user \"" . htmlspecialchars( $wgDBsuperuser ) . "\" cannot create other users. "; |
232 | 233 | print 'Please use a different Postgres user.</li>'; |
233 | 234 | dieout('</ul>'); |
234 | 235 | } |
235 | | - print "<li>Creating user <b>$wgDBuser</b>..."; |
| 236 | + print "<li>Creating user <b>" . htmlspecialchars( $wgDBuser ) . "</b>..."; |
236 | 237 | $safepass = $this->addQuotes($wgDBpassword); |
237 | 238 | $SQL = "CREATE USER $safeuser NOCREATEDB PASSWORD $safepass"; |
238 | 239 | $this->doQuery($SQL); |
— | — | @@ -242,15 +243,15 @@ |
243 | 244 | $SQL = "SELECT 1 FROM pg_catalog.pg_database WHERE datname = " . $this->addQuotes($wgDBname); |
244 | 245 | $rows = $this->numRows($this->doQuery($SQL)); |
245 | 246 | if ($rows) { |
246 | | - print "<li>Database \"$wgDBname\" already exists, skipping database creation.</li>"; |
| 247 | + print "<li>Database \"" . htmlspecialchars( $wgDBname ) . "\" already exists, skipping database creation.</li>"; |
247 | 248 | } |
248 | 249 | else { |
249 | 250 | if ($perms < 2) { |
250 | | - print "<li>ERROR: the user \"$wgDBsuperuser\" cannot create databases. "; |
| 251 | + print "<li>ERROR: the user \"" . htmlspecialchars( $wgDBsuperuser ) . "\" cannot create databases. "; |
251 | 252 | print 'Please use a different Postgres user.</li>'; |
252 | 253 | dieout('</ul>'); |
253 | 254 | } |
254 | | - print "<li>Creating database <b>$wgDBname</b>..."; |
| 255 | + print "<li>Creating database <b>" . htmlspecialchars( $wgDBname ) . "</b>..."; |
255 | 256 | $safename = $this->quote_ident($wgDBname); |
256 | 257 | $SQL = "CREATE DATABASE $safename OWNER $safeuser "; |
257 | 258 | $this->doQuery($SQL); |
— | — | @@ -259,17 +260,21 @@ |
260 | 261 | } |
261 | 262 | |
262 | 263 | // Reconnect to check out tsearch2 rights for this user |
263 | | - print "<li>Connecting to \"$wgDBname\" as superuser \"$wgDBsuperuser\" to check rights..."; |
| 264 | + print "<li>Connecting to \"" . htmlspecialchars( $wgDBname ) . "\" as superuser \"" . |
| 265 | + htmlspecialchars( $wgDBsuperuser ) . "\" to check rights..."; |
264 | 266 | |
265 | | - $hstring=""; |
| 267 | + $connectVars = array(); |
266 | 268 | if ($this->mServer!=false && $this->mServer!="") { |
267 | | - $hstring="host=$this->mServer "; |
| 269 | + $connectVars['host'] = $this->mServer; |
268 | 270 | } |
269 | 271 | if ($this->mPort!=false && $this->mPort!="") { |
270 | | - $hstring .= "port=$this->mPort "; |
| 272 | + $connectVars['port'] = $this->mPort; |
271 | 273 | } |
| 274 | + $connectVars['dbname'] = $wgDBname; |
| 275 | + $connectVars['user'] = $wgDBsuperuser; |
| 276 | + $connectVars['password'] = $password; |
272 | 277 | |
273 | | - @$this->mConn = pg_connect("$hstring dbname=$wgDBname user=$wgDBsuperuser password=$password"); |
| 278 | + @$this->mConn = pg_connect( $this->makeConnectionString( $connectVars ) ); |
274 | 279 | if ( $this->mConn == false ) { |
275 | 280 | print "<b>FAILED TO CONNECT!</b></li>"; |
276 | 281 | dieout("</ul>"); |
— | — | @@ -279,15 +284,18 @@ |
280 | 285 | |
281 | 286 | if ($this->numeric_version < 8.3) { |
282 | 287 | // Tsearch2 checks |
283 | | - print "<li>Checking that tsearch2 is installed in the database \"$wgDBname\"..."; |
| 288 | + print "<li>Checking that tsearch2 is installed in the database \"" . |
| 289 | + htmlspecialchars( $wgDBname ) . "\"..."; |
284 | 290 | if (! $this->tableExists("pg_ts_cfg", $wgDBts2schema)) { |
285 | | - print "<b>FAILED</b>. tsearch2 must be installed in the database \"$wgDBname\"."; |
| 291 | + print "<b>FAILED</b>. tsearch2 must be installed in the database \"" . |
| 292 | + htmlspecialchars( $wgDBname ) . "\"."; |
286 | 293 | print "Please see <a href='http://www.devx.com/opensource/Article/21674/0/page/2'>this article</a>"; |
287 | 294 | print " for instructions or ask on #postgresql on irc.freenode.net</li>\n"; |
288 | 295 | dieout("</ul>"); |
289 | 296 | } |
290 | 297 | print "OK</li>\n"; |
291 | | - print "<li>Ensuring that user \"$wgDBuser\" has select rights on the tsearch2 tables..."; |
| 298 | + print "<li>Ensuring that user \"" . htmlspecialchars( $wgDBuser ) . |
| 299 | + "\" has select rights on the tsearch2 tables..."; |
292 | 300 | foreach (array('cfg','cfgmap','dict','parser') as $table) { |
293 | 301 | $SQL = "GRANT SELECT ON pg_ts_$table TO $safeuser"; |
294 | 302 | $this->doQuery($SQL); |
— | — | @@ -299,7 +307,7 @@ |
300 | 308 | $result = $this->schemaExists($wgDBmwschema); |
301 | 309 | $safeschema = $this->quote_ident($wgDBmwschema); |
302 | 310 | if (!$result) { |
303 | | - print "<li>Creating schema <b>$wgDBmwschema</b> ..."; |
| 311 | + print "<li>Creating schema <b>" . htmlspecialchars( $wgDBmwschema ) . "</b> ..."; |
304 | 312 | $result = $this->doQuery("CREATE SCHEMA $safeschema AUTHORIZATION $safeuser"); |
305 | 313 | if (!$result) { |
306 | 314 | print "<b>FAILED</b>.</li>\n"; |
— | — | @@ -345,7 +353,7 @@ |
346 | 354 | |
347 | 355 | if ($this->numeric_version < 8.3) { |
348 | 356 | // Do we have the basic tsearch2 table? |
349 | | - print "<li>Checking for tsearch2 in the schema \"$wgDBts2schema\"..."; |
| 357 | + print "<li>Checking for tsearch2 in the schema \"" . htmlspecialchars( $wgDBts2schema ) . "\"..."; |
350 | 358 | if (! $this->tableExists("pg_ts_dict", $wgDBts2schema)) { |
351 | 359 | print "<b>FAILED</b>. Make sure tsearch2 is installed. See <a href="; |
352 | 360 | print "'http://www.devx.com/opensource/Article/21674/0/page/2'>this article</a>"; |
— | — | @@ -365,12 +373,13 @@ |
366 | 374 | $SQL = "SELECT count(*) FROM $safetsschema.pg_ts_$tname"; |
367 | 375 | $res = $this->doQuery($SQL); |
368 | 376 | if (!$res) { |
369 | | - print "<b>FAILED</b> to access pg_ts_$tname. Make sure that the user ". |
370 | | - "\"$wgDBuser\" has SELECT access to all four tsearch2 tables</li>\n"; |
| 377 | + print "<b>FAILED</b> to access " . htmlspecialchars( "pg_ts_$tname" ) . |
| 378 | + ". Make sure that the user \"". htmlspecialchars( $wgDBuser ) . |
| 379 | + "\" has SELECT access to all four tsearch2 tables</li>\n"; |
371 | 380 | dieout("</ul>"); |
372 | 381 | } |
373 | 382 | } |
374 | | - $SQL = "SELECT ts_name FROM $safetsschema.pg_ts_cfg WHERE locale = '$ctype'"; |
| 383 | + $SQL = "SELECT ts_name FROM $safetsschema.pg_ts_cfg WHERE locale = " . $this->addQuotes( $ctype ) ; |
375 | 384 | $SQL .= " ORDER BY CASE WHEN ts_name <> 'default' THEN 1 ELSE 0 END"; |
376 | 385 | $res = $this->doQuery($SQL); |
377 | 386 | error_reporting( E_ALL ); |
— | — | @@ -381,28 +390,30 @@ |
382 | 391 | print "OK</li>"; |
383 | 392 | |
384 | 393 | // Will the current locale work? Can we force it to? |
385 | | - print "<li>Verifying tsearch2 locale with $ctype..."; |
| 394 | + print "<li>Verifying tsearch2 locale with " . htmlspecialchars( $ctype ) . "..."; |
386 | 395 | $rows = $this->numRows($res); |
387 | 396 | $resetlocale = 0; |
388 | 397 | if (!$rows) { |
389 | 398 | print "<b>not found</b></li>\n"; |
390 | | - print "<li>Attempting to set default tsearch2 locale to \"$ctype\"..."; |
| 399 | + print "<li>Attempting to set default tsearch2 locale to \"" . htmlspecialchars( $ctype ) . "\"..."; |
391 | 400 | $resetlocale = 1; |
392 | 401 | } |
393 | 402 | else { |
394 | 403 | $tsname = pg_fetch_result($res, 0, 0); |
395 | 404 | if ($tsname != 'default') { |
396 | | - print "<b>not set to default ($tsname)</b>"; |
397 | | - print "<li>Attempting to change tsearch2 default locale to \"$ctype\"..."; |
| 405 | + print "<b>not set to default (" . htmlspecialchars( $tsname ) . ")</b>"; |
| 406 | + print "<li>Attempting to change tsearch2 default locale to \"" . |
| 407 | + htmlspecialchars( $ctype ) . "\"..."; |
398 | 408 | $resetlocale = 1; |
399 | 409 | } |
400 | 410 | } |
401 | 411 | if ($resetlocale) { |
402 | | - $SQL = "UPDATE $safetsschema.pg_ts_cfg SET locale = '$ctype' WHERE ts_name = 'default'"; |
| 412 | + $SQL = "UPDATE $safetsschema.pg_ts_cfg SET locale = " . $this->addQuotes( $ctype ) . " WHERE ts_name = 'default'"; |
403 | 413 | $res = $this->doQuery($SQL); |
404 | 414 | if (!$res) { |
405 | 415 | print "<b>FAILED</b>. "; |
406 | | - print "Please make sure that the locale in pg_ts_cfg for \"default\" is set to \"$ctype\"</li>\n"; |
| 416 | + print "Please make sure that the locale in pg_ts_cfg for \"default\" is set to \"" . |
| 417 | + htmlspecialchars( $ctype ) . "\"</li>\n"; |
407 | 418 | dieout("</ul>"); |
408 | 419 | } |
409 | 420 | print "OK</li>"; |
— | — | @@ -412,7 +423,7 @@ |
413 | 424 | $SQL = "SELECT $safetsschema.to_tsvector('default','MediaWiki tsearch2 testing')"; |
414 | 425 | $res = $this->doQuery($SQL); |
415 | 426 | if (!$res) { |
416 | | - print "<b>FAILED</b>. Specifically, \"$SQL\" did not work.</li>"; |
| 427 | + print "<b>FAILED</b>. Specifically, \"" . htmlspecialchars( $SQL ) . "\" did not work.</li>"; |
417 | 428 | dieout("</ul>"); |
418 | 429 | } |
419 | 430 | print "OK</li>"; |
— | — | @@ -424,28 +435,32 @@ |
425 | 436 | // Does the schema already exist? Who owns it? |
426 | 437 | $result = $this->schemaExists($wgDBmwschema); |
427 | 438 | if (!$result) { |
428 | | - print "<li>Creating schema <b>$wgDBmwschema</b> ..."; |
| 439 | + print "<li>Creating schema <b>" . htmlspecialchars( $wgDBmwschema ) . "</b> ..."; |
429 | 440 | error_reporting( 0 ); |
430 | 441 | $safeschema = $this->quote_ident($wgDBmwschema); |
431 | 442 | $result = $this->doQuery("CREATE SCHEMA $safeschema"); |
432 | 443 | error_reporting( E_ALL ); |
433 | 444 | if (!$result) { |
434 | | - print "<b>FAILED</b>. The user \"$wgDBuser\" must be able to access the schema. ". |
| 445 | + print "<b>FAILED</b>. The user \"" . htmlspecialchars( $wgDBuser ) . |
| 446 | + "\" must be able to access the schema. ". |
435 | 447 | "You can try making them the owner of the database, or try creating the schema with a ". |
436 | | - "different user, and then grant access to the \"$wgDBuser\" user.</li>\n"; |
| 448 | + "different user, and then grant access to the \"" . |
| 449 | + htmlspecialchars( $wgDBuser ) . "\" user.</li>\n"; |
437 | 450 | dieout("</ul>"); |
438 | 451 | } |
439 | 452 | print "OK</li>\n"; |
440 | 453 | } |
441 | 454 | else if ($result != $wgDBuser) { |
442 | | - print "<li>Schema \"$wgDBmwschema\" exists but is not owned by \"$wgDBuser\". Not ideal.</li>\n"; |
| 455 | + print "<li>Schema \"" . htmlspecialchars( $wgDBmwschema ) . "\" exists but is not owned by \"" . |
| 456 | + htmlspecialchars( $wgDBuser ) . "\". Not ideal.</li>\n"; |
443 | 457 | } |
444 | 458 | else { |
445 | | - print "<li>Schema \"$wgDBmwschema\" exists and is owned by \"$wgDBuser\". Excellent.</li>\n"; |
| 459 | + print "<li>Schema \"" . htmlspecialchars( $wgDBmwschema ) . "\" exists and is owned by \"" . |
| 460 | + htmlspecialchars( $wgDBuser ) . "\". Excellent.</li>\n"; |
446 | 461 | } |
447 | 462 | |
448 | 463 | // Always return GMT time to accomodate the existing integer-based timestamp assumption |
449 | | - print "<li>Setting the timezone to GMT for user \"$wgDBuser\" ..."; |
| 464 | + print "<li>Setting the timezone to GMT for user \"" . htmlspecialchars( $wgDBuser ) . "\" ..."; |
450 | 465 | $SQL = "ALTER USER $safeuser SET timezone = 'GMT'"; |
451 | 466 | $result = pg_query($this->mConn, $SQL); |
452 | 467 | if (!$result) { |
— | — | @@ -461,7 +476,7 @@ |
462 | 477 | dieout("</ul>"); |
463 | 478 | } |
464 | 479 | |
465 | | - print "<li>Setting the datestyle to ISO, YMD for user \"$wgDBuser\" ..."; |
| 480 | + print "<li>Setting the datestyle to ISO, YMD for user \"" . htmlspecialchars( $wgDBuser ) . "\" ..."; |
466 | 481 | $SQL = "ALTER USER $safeuser SET datestyle = 'ISO, YMD'"; |
467 | 482 | $result = pg_query($this->mConn, $SQL); |
468 | 483 | if (!$result) { |
— | — | @@ -478,7 +493,7 @@ |
479 | 494 | } |
480 | 495 | |
481 | 496 | // Fix up the search paths if needed |
482 | | - print "<li>Setting the search path for user \"$wgDBuser\" ..."; |
| 497 | + print "<li>Setting the search path for user \"" . htmlspecialchars( $wgDBuser ) . "\" ..."; |
483 | 498 | $path = $this->quote_ident($wgDBmwschema); |
484 | 499 | if ($wgDBts2schema !== $wgDBmwschema) |
485 | 500 | $path .= ", ". $this->quote_ident($wgDBts2schema); |
— | — | @@ -519,12 +534,14 @@ |
520 | 535 | $result = $this->doQuery("CREATE LANGUAGE plpgsql"); |
521 | 536 | error_reporting($olde); |
522 | 537 | if (!$result) { |
523 | | - print "<b>FAILED</b>. You need to install the language plpgsql in the database <tt>$wgDBname</tt></li>"; |
| 538 | + print "<b>FAILED</b>. You need to install the language plpgsql in the database <tt>" . |
| 539 | + htmlspecialchars( $wgDBname ) . "</tt></li>"; |
524 | 540 | dieout("</ul>"); |
525 | 541 | } |
526 | 542 | } |
527 | 543 | else { |
528 | | - print "<b>FAILED</b>. You need to install the language plpgsql in the database <tt>$wgDBname</tt></li>"; |
| 544 | + print "<b>FAILED</b>. You need to install the language plpgsql in the database <tt>" . |
| 545 | + htmlspecialchars( $wgDBname ) . "</tt></li>"; |
529 | 546 | dieout("</ul>"); |
530 | 547 | } |
531 | 548 | } |
— | — | @@ -1217,7 +1234,8 @@ |
1218 | 1235 | $res = $this->doQuery($SQL); |
1219 | 1236 | error_reporting( $olde ); |
1220 | 1237 | if (!$res) { |
1221 | | - print "<b>FAILED</b>. Make sure that the user \"$wgDBuser\" can write to the schema \"$wgDBmwschema\"</li>\n"; |
| 1238 | + print "<b>FAILED</b>. Make sure that the user \"" . htmlspecialchars( $wgDBuser ) . |
| 1239 | + "\" can write to the schema \"" . htmlspecialchars( $wgDBmwschema ) . "\"</li>\n"; |
1222 | 1240 | dieout("</ul>"); |
1223 | 1241 | } |
1224 | 1242 | $this->doQuery("DROP TABLE $safeschema.$ctest"); |
— | — | @@ -1232,11 +1250,11 @@ |
1233 | 1251 | $tss = $this->addQuotes($wgDBts2schema); |
1234 | 1252 | $pgp = $this->addQuotes($wgDBport); |
1235 | 1253 | $dbn = $this->addQuotes($this->mDBname); |
1236 | | - $ctype = pg_fetch_result($this->doQuery("SHOW lc_ctype"),0,0); |
| 1254 | + $ctype = $this->addQuotes( pg_fetch_result($this->doQuery("SHOW lc_ctype"),0,0) ); |
1237 | 1255 | |
1238 | 1256 | $SQL = "UPDATE mediawiki_version SET mw_version=$mwv, pg_version=$pgv, pg_user=$pgu, ". |
1239 | 1257 | "mw_schema = $mws, ts2_schema = $tss, pg_port=$pgp, pg_dbname=$dbn, ". |
1240 | | - "ctype = '$ctype' ". |
| 1258 | + "ctype = $ctype ". |
1241 | 1259 | "WHERE type = 'Creation'"; |
1242 | 1260 | $this->query($SQL); |
1243 | 1261 | |
Index: branches/REL1_13/phase3/config/index.php |
— | — | @@ -84,7 +84,8 @@ |
85 | 85 | <html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en" lang="en" dir="ltr"> |
86 | 86 | <head> |
87 | 87 | <meta http-equiv="Content-type" content="text/html; charset=utf-8" /> |
88 | | - <title>MediaWiki <?php echo( $wgVersion ); ?> Installation</title> |
| 88 | + <meta name="robots" content="noindex,nofollow"/> |
| 89 | + <title>MediaWiki <?php echo htmlspecialchars( $wgVersion ); ?> Installation</title> |
89 | 90 | <style type="text/css"> |
90 | 91 | |
91 | 92 | @import "../skins/monobook/main.css"; |
— | — | @@ -202,7 +203,7 @@ |
203 | 204 | <div id="content"> |
204 | 205 | <div id="bodyContent"> |
205 | 206 | |
206 | | -<h1>MediaWiki <?php print $wgVersion ?> Installation</h1> |
| 207 | +<h1>MediaWiki <?php print htmlspecialchars( $wgVersion ) ?> Installation</h1> |
207 | 208 | |
208 | 209 | <?php |
209 | 210 | $mainListOpened = false; # Is the main list (environement checking) opend ? Used by dieout |
— | — | @@ -302,7 +303,7 @@ |
303 | 304 | install_version_checks(); |
304 | 305 | $self = 'Installer'; # Maintenance script name, to please Setup.php |
305 | 306 | |
306 | | -print "<li>PHP " . phpversion() . " installed</li>\n"; |
| 307 | +print "<li>PHP " . htmlspecialchars( phpversion() ) . " installed</li>\n"; |
307 | 308 | |
308 | 309 | error_reporting( 0 ); |
309 | 310 | $phpdatabases = array(); |
— | — | @@ -402,7 +403,7 @@ |
403 | 404 | $conf->safeMode = false; |
404 | 405 | } |
405 | 406 | |
406 | | -$sapi = php_sapi_name(); |
| 407 | +$sapi = htmlspecialchars( php_sapi_name() ); |
407 | 408 | print "<li>PHP server API is $sapi; "; |
408 | 409 | $script = defined('MW_INSTALL_PHP5_EXT') ? 'index.php5' : 'index.php'; |
409 | 410 | if( $wgUsePathInfo ) { |
— | — | @@ -585,6 +586,9 @@ |
586 | 587 | : $_SERVER["SERVER_ADMIN"]; |
587 | 588 | $conf->EmergencyContact = importPost( "EmergencyContact", $defaultEmail ); |
588 | 589 | $conf->DBtype = importPost( "DBtype", $DefaultDBtype ); |
| 590 | + if ( !isset( $ourdb[$conf->DBtype] ) ) { |
| 591 | + $conf->DBtype = $DefaultDBtype; |
| 592 | + } |
589 | 593 | |
590 | 594 | $conf->DBserver = importPost( "DBserver", "localhost" ); |
591 | 595 | $conf->DBname = importPost( "DBname", "wikidb" ); |
— | — | @@ -757,7 +761,7 @@ |
758 | 762 | $errs["DBtype"] = "Unknown database type '$conf->DBtype'"; |
759 | 763 | continue; |
760 | 764 | } |
761 | | - print "<li>Database type: {$conf->DBtypename}</li>\n"; |
| 765 | + print "<li>Database type: " . htmlspecialchars( $conf->DBtypename ) . "</li>\n"; |
762 | 766 | $dbclass = 'Database'.ucfirst($conf->DBtype); |
763 | 767 | $wgDBtype = $conf->DBtype; |
764 | 768 | $wgDBadminuser = "root"; |
— | — | @@ -785,7 +789,7 @@ |
786 | 790 | |
787 | 791 | $wgTitle = Title::newFromText( "Installation script" ); |
788 | 792 | error_reporting( E_ALL ); |
789 | | - print "<li>Loading class: $dbclass</li>\n"; |
| 793 | + print "<li>Loading class: " . htmlspecialchars( $dbclass ) . "</li>\n"; |
790 | 794 | $dbc = new $dbclass; |
791 | 795 | |
792 | 796 | if( $conf->DBtype == 'mysql' ) { |
— | — | @@ -809,7 +813,7 @@ |
810 | 814 | } |
811 | 815 | |
812 | 816 | # Attempt to connect |
813 | | - echo( "<li>Attempting to connect to database server as $db_user..." ); |
| 817 | + echo( "<li>Attempting to connect to database server as " . htmlspecialchars( $db_user ) . "..." ); |
814 | 818 | $wgDatabase = Database::newFromParams( $wgDBserver, $db_user, $db_pass, '', 1 ); |
815 | 819 | |
816 | 820 | # Check the connection and respond to errors |
— | — | @@ -844,7 +848,7 @@ |
845 | 849 | case 2003: |
846 | 850 | default: |
847 | 851 | # General connection problem |
848 | | - echo( "failed with error [$errno] $errtx.</li>\n" ); |
| 852 | + echo( htmlspecialchars( "failed with error [$errno] $errtx." ) . "</li>\n" ); |
849 | 853 | $errs["DBserver"] = "Connection failed"; |
850 | 854 | break; |
851 | 855 | } # switch |
— | — | @@ -858,10 +862,11 @@ |
859 | 863 | ## Possible connect as a superuser |
860 | 864 | if( $useRoot && $conf->DBtype != 'sqlite' ) { |
861 | 865 | $wgDBsuperuser = $conf->RootUser; |
862 | | - echo( "<li>Attempting to connect to database \"postgres\" as superuser \"$wgDBsuperuser\"..." ); |
| 866 | + echo( "<li>Attempting to connect to database \"postgres\" as superuser \"" . |
| 867 | + htmlspecialchars( $wgDBsuperuser ) . "\"..." ); |
863 | 868 | $wgDatabase = $dbc->newFromParams($wgDBserver, $wgDBsuperuser, $conf->RootPW, "postgres", 1); |
864 | 869 | if (!$wgDatabase->isOpen()) { |
865 | | - print " error: " . $wgDatabase->lastError() . "</li>\n"; |
| 870 | + print " error: " . htmlspecialchars( $wgDatabase->lastError() ) . "</li>\n"; |
866 | 871 | $errs["DBserver"] = "Could not connect to database as superuser"; |
867 | 872 | $errs["RootUser"] = "Check username"; |
868 | 873 | $errs["RootPW"] = "and password"; |
— | — | @@ -869,10 +874,11 @@ |
870 | 875 | } |
871 | 876 | $wgDatabase->initial_setup($conf->RootPW, 'postgres'); |
872 | 877 | } |
873 | | - echo( "<li>Attempting to connect to database \"$wgDBname\" as \"$wgDBuser\"..." ); |
| 878 | + echo( "<li>Attempting to connect to database \"" . htmlspecialchars( $wgDBname ) . |
| 879 | + "\" as \"" . htmlspecialchars( $wgDBuser ) . "\"..." ); |
874 | 880 | $wgDatabase = $dbc->newFromParams($wgDBserver, $wgDBuser, $wgDBpassword, $wgDBname, 1); |
875 | 881 | if (!$wgDatabase->isOpen()) { |
876 | | - print " error: " . $wgDatabase->lastError() . "</li>\n"; |
| 882 | + print " error: " . htmlspecialchars( $wgDatabase->lastError() ) . "</li>\n"; |
877 | 883 | } else { |
878 | 884 | $myver = $wgDatabase->getServerVersion(); |
879 | 885 | } |
— | — | @@ -884,7 +890,7 @@ |
885 | 891 | continue; |
886 | 892 | } |
887 | 893 | |
888 | | - print "<li>Connected to $myver"; |
| 894 | + print "<li>Connected to " . htmlspecialchars( $myver ); |
889 | 895 | if ($conf->DBtype == 'mysql') { |
890 | 896 | if( version_compare( $myver, "4.0.14" ) < 0 ) { |
891 | 897 | print "</li>\n"; |
— | — | @@ -971,15 +977,19 @@ |
972 | 978 | } |
973 | 979 | } |
974 | 980 | if ( $existingSchema && $existingSchema != $conf->DBschema ) { |
975 | | - print "<li><strong>Warning:</strong> you requested the {$conf->DBschema} schema, " . |
976 | | - "but the existing database has the $existingSchema schema. This upgrade script ". |
977 | | - "can't convert it, so it will remain $existingSchema.</li>\n"; |
| 981 | + $encExisting = htmlspecialchars( $existingSchema ); |
| 982 | + $encRequested = htmlspecialchars( $conf->DBschema ); |
| 983 | + print "<li><strong>Warning:</strong> you requested the $encRequested schema, " . |
| 984 | + "but the existing database has the $encExisting schema. This upgrade script ". |
| 985 | + "can't convert it, so it will remain $encExisting.</li>\n"; |
978 | 986 | $conf->setSchema( $existingSchema, $conf->DBengine ); |
979 | 987 | } |
980 | 988 | if ( $existingEngine && $existingEngine != $conf->DBengine ) { |
981 | | - print "<li><strong>Warning:</strong> you requested the {$conf->DBengine} storage " . |
982 | | - "engine, but the existing database uses the $existingEngine engine. This upgrade " . |
983 | | - "script can't convert it, so it will remain $existingEngine.</li>\n"; |
| 989 | + $encExisting = htmlspecialchars( $existingEngine ); |
| 990 | + $encRequested = htmlspecialchars( $conf->DBengine ); |
| 991 | + print "<li><strong>Warning:</strong> you requested the $encRequested storage " . |
| 992 | + "engine, but the existing database uses the $encExisting engine. This upgrade " . |
| 993 | + "script can't convert it, so it will remain $encExisting.</li>\n"; |
984 | 994 | $conf->setSchema( $conf->DBschema, $existingEngine ); |
985 | 995 | } |
986 | 996 | } |
— | — | @@ -1020,7 +1030,8 @@ |
1021 | 1031 | } |
1022 | 1032 | $wgDatabase->freeResult( $res ); |
1023 | 1033 | if ( !$found && $conf->DBengine != 'MyISAM' ) { |
1024 | | - echo "<li><strong>Warning:</strong> {$conf->DBengine} storage engine not available, " . |
| 1034 | + echo "<li><strong>Warning:</strong> " . htmlspecialchars( $conf->DBengine ) . |
| 1035 | + " storage engine not available, " . |
1025 | 1036 | "using MyISAM instead</li>\n"; |
1026 | 1037 | $conf->setSchema( $conf->DBschema, 'MyISAM' ); |
1027 | 1038 | } |
— | — | @@ -1059,10 +1070,10 @@ |
1060 | 1071 | if( $wgDatabase2->isOpen() ) { |
1061 | 1072 | # Nope, just close the test connection and continue |
1062 | 1073 | $wgDatabase2->close(); |
1063 | | - echo( "<li>User $wgDBuser exists. Skipping grants.</li>\n" ); |
| 1074 | + echo( "<li>User " . htmlspecialchars( $wgDBuser ) . " exists. Skipping grants.</li>\n" ); |
1064 | 1075 | } else { |
1065 | 1076 | # Yes, so run the grants |
1066 | | - echo( "<li>Granting user permissions to $wgDBuser on $wgDBname..." ); |
| 1077 | + echo( "<li>" . htmlspecialchars( "Granting user permissions to $wgDBuser on $wgDBname..." ) ); |
1067 | 1078 | dbsource( "../maintenance/users.sql", $wgDatabase ); |
1068 | 1079 | echo( "success.</li>\n" ); |
1069 | 1080 | } |
— | — | @@ -1165,7 +1176,9 @@ |
1166 | 1177 | $list = getLanguageList(); |
1167 | 1178 | foreach( $list as $code => $name ) { |
1168 | 1179 | $sel = ($code == $conf->LanguageCode) ? 'selected="selected"' : ''; |
1169 | | - echo "\n\t\t<option value=\"$code\" $sel>$name</option>"; |
| 1180 | + $encCode = htmlspecialchars( $code ); |
| 1181 | + $encName = htmlspecialchars( $name ); |
| 1182 | + echo "\n\t\t<option value=\"$encCode\" $sel>$encName</option>"; |
1170 | 1183 | } |
1171 | 1184 | echo "\n"; |
1172 | 1185 | ?> |
— | — | @@ -1330,7 +1343,11 @@ |
1331 | 1344 | <div class="config-section"> |
1332 | 1345 | <div class="config-input"> |
1333 | 1346 | <label class='column'>Database type:</label> |
1334 | | -<?php if (isset($errs['DBpicktype'])) print "\t<span class='error'>$errs[DBpicktype]</span>\n"; ?> |
| 1347 | +<?php |
| 1348 | + if (isset($errs['DBpicktype'])) { |
| 1349 | + print "\t<span class='error'>" . htmlspecialchars( $errs[DBpicktype] ) . "</span>\n"; |
| 1350 | + } |
| 1351 | +?> |
1335 | 1352 | <ul class='plain'><?php |
1336 | 1353 | database_picker($conf); |
1337 | 1354 | ?></ul> |
— | — | @@ -1455,7 +1472,7 @@ |
1456 | 1473 | </div> |
1457 | 1474 | </form> |
1458 | 1475 | <script type="text/javascript"> |
1459 | | -window.onload = toggleDBarea('<?php echo $conf->DBtype; ?>', |
| 1476 | +window.onload = toggleDBarea('<?php echo Xml::encodeJsVar( $conf->DBtype ); ?>', |
1460 | 1477 | <?php |
1461 | 1478 | ## If they passed in a root user name, don't populate it on page load |
1462 | 1479 | echo strlen(importPost('RootUser', '')) ? 0 : 1; |
— | — | @@ -1781,10 +1798,8 @@ |
1782 | 1799 | return importVar( $_REQUEST, $name, $default ); |
1783 | 1800 | } |
1784 | 1801 | |
1785 | | -$radioCount = 0; |
1786 | | - |
1787 | 1802 | function aField( &$conf, $field, $text, $type = "text", $value = "", $onclick = '' ) { |
1788 | | - global $radioCount; |
| 1803 | + static $radioCount = 0; |
1789 | 1804 | if( $type != "" ) { |
1790 | 1805 | $xtype = "type=\"$type\""; |
1791 | 1806 | } else { |
— | — | @@ -1824,7 +1839,9 @@ |
1825 | 1840 | } |
1826 | 1841 | |
1827 | 1842 | global $errs; |
1828 | | - if(isset($errs[$field])) echo "<span class='error'>" . $errs[$field] . "</span>\n"; |
| 1843 | + if(isset($errs[$field])) { |
| 1844 | + echo "<span class='error'>" . htmlspecialchars( $errs[$field] ) . "</span>\n"; |
| 1845 | + } |
1829 | 1846 | } |
1830 | 1847 | |
1831 | 1848 | function getLanguageList() { |
— | — | @@ -1917,7 +1934,7 @@ |
1918 | 1935 | fclose( $fp ); |
1919 | 1936 | } |
1920 | 1937 | if ( !$errstr ) { |
1921 | | - echo "<li>Connected to memcached on $host:$port successfully"; |
| 1938 | + echo "<li>Connected to memcached on " . htmlspecialchars( "$host:$port" ) ." successfully</li>"; |
1922 | 1939 | } |
1923 | 1940 | return $errstr; |
1924 | 1941 | } |