Index: trunk/phase3/maintenance/counter.php |
— | — | @@ -1,12 +0,0 @@ |
2 | | -<?php |
3 | | -/** |
4 | | - * Helper file for update.php |
5 | | - * |
6 | | - * @file |
7 | | - * @ingroup Maintenance |
8 | | - */ |
9 | | - |
10 | | -function print_c($last, $current) { |
11 | | - echo str_repeat( chr(8), strlen( $last ) ) . $current; |
12 | | -} |
13 | | - |
Index: trunk/phase3/maintenance/update.php |
— | — | @@ -1,5 +1,4 @@ |
2 | 2 | <?php |
3 | | -require_once 'counter.php'; |
4 | 3 | /** |
5 | 4 | * Run all updaters. |
6 | 5 | * |
— | — | @@ -12,48 +11,24 @@ |
13 | 12 | |
14 | 13 | /** */ |
15 | 14 | $wgUseMasterForMaintenance = true; |
16 | | -$options = array( 'quick', 'nopurge' ); |
17 | | -require_once( "commandLine.inc" ); |
18 | | -require_once( "updaters.inc" ); |
| 15 | +require( "commandLine.inc" ); |
| 16 | +require( "updaters.inc" ); |
19 | 17 | $wgTitle = Title::newFromText( "MediaWiki database updater" ); |
20 | | -$dbclass = 'Database' . ucfirst( $wgDBtype ) ; |
21 | 18 | |
22 | 19 | echo( "MediaWiki {$wgVersion} Updater\n\n" ); |
23 | 20 | |
24 | 21 | install_version_checks(); |
25 | 22 | |
26 | | -# Do a pre-emptive check to ensure we've got credentials supplied |
27 | | -# We can't, at this stage, check them, but we can detect their absence, |
28 | | -# which seems to cause most of the problems people whinge about |
29 | | -if( !isset( $wgDBadminuser ) || !isset( $wgDBadminpassword ) ) { |
30 | | - echo( "No superuser credentials could be found. Please provide the details\n" ); |
31 | | - echo( "of a user with appropriate permissions to update the database. See\n" ); |
32 | | - echo( "AdminSettings.sample for more details.\n\n" ); |
33 | | - exit(1); |
34 | | -} |
35 | | - |
36 | 23 | # Attempt to connect to the database as a privileged user |
37 | 24 | # This will vomit up an error if there are permissions problems |
38 | | -$wgDatabase = new $dbclass( $wgDBserver, $wgDBadminuser, $wgDBadminpassword, $wgDBname, 1 ); |
| 25 | +$wgDatabase = wfGetDB( DB_MASTER ); |
39 | 26 | |
40 | | -if( !$wgDatabase->isOpen() ) { |
41 | | - # Appears to have failed |
42 | | - echo( "A connection to the database could not be established. Check the\n" ); |
43 | | - echo( "values of \$wgDBadminuser and \$wgDBadminpassword.\n" ); |
44 | | - exit(1); |
45 | | -} |
46 | | - |
47 | 27 | print "Going to run database updates for ".wfWikiID()."\n"; |
48 | 28 | print "Depending on the size of your database this may take a while!\n"; |
49 | 29 | |
50 | 30 | if( !isset( $options['quick'] ) ) { |
51 | 31 | print "Abort with control-c in the next five seconds... "; |
52 | | - |
53 | | - for ($i = 6; $i >= 1;) { |
54 | | - print_c($i, --$i); |
55 | | - sleep(1); |
56 | | - } |
57 | | - echo "\n"; |
| 32 | + wfCountDown( 5 ); |
58 | 33 | } |
59 | 34 | |
60 | 35 | $shared = isset( $options['doshared'] ); |
Index: trunk/phase3/maintenance/userOptions.inc |
— | — | @@ -246,13 +246,7 @@ |
247 | 247 | |
248 | 248 | Abort with control-c in the next five seconds.... |
249 | 249 | WARN; |
250 | | - require('counter.php'); |
251 | | - for ($i=6;$i>=1;) { |
252 | | - print_c($i, --$i); |
253 | | - sleep(1); |
254 | | - } |
255 | | - print "\n"; |
256 | | - |
| 250 | + wfCountDown( 5 ); |
257 | 251 | return true; |
258 | 252 | } |
259 | 253 | |
Index: trunk/phase3/includes/GlobalFunctions.php |
— | — | @@ -3084,6 +3084,24 @@ |
3085 | 3085 | flush(); |
3086 | 3086 | } |
3087 | 3087 | |
| 3088 | +/** |
| 3089 | + * Count down from $n to zero on the terminal, with a one-second pause |
| 3090 | + * between showing each number. For use in command-line scripts. |
| 3091 | + */ |
| 3092 | +function wfCountDown( $n ) { |
| 3093 | + for ( $i = $n; $i >= 0; $i-- ) { |
| 3094 | + if ( $i != $n ) { |
| 3095 | + echo str_repeat( "\x08", strlen( $i + 1 ) ); |
| 3096 | + } |
| 3097 | + echo $i; |
| 3098 | + flush(); |
| 3099 | + if ( $i ) { |
| 3100 | + sleep( 1 ); |
| 3101 | + } |
| 3102 | + } |
| 3103 | + echo "\n"; |
| 3104 | +} |
| 3105 | + |
3088 | 3106 | /** Generate a random 32-character hexadecimal token. |
3089 | 3107 | * @param mixed $salt Some sort of salt, if necessary, to add to random characters before hashing. |
3090 | 3108 | */ |