r5952 MediaWiki - Code Review archive

Repository:MediaWiki
Revision:r5951‎ | r5952 | r5953 >
Date:21:38, 17 October 2004
Author:vibber
Status:old
Tags:
Comment:
Interactive scripts are a pain in the butt, and have bad interactions
with output buffering. If no option is given on the command line, just
print a help message instead of the ill-fated prompt.

Also now accepts --update and --rebuild in standard GNU long option style.
Modified paths:
  • /trunk/phase3/maintenance/rebuildMessages.php (modified) (history)

Diff [purge]

Index: trunk/phase3/maintenance/rebuildMessages.php
@@ -6,12 +6,14 @@
77 */
88
99 /** */
 10+$options = array( 'update' => null, 'rebuild' => null );
1011 require_once( "commandLine.inc" );
1112 include_once( "InitialiseMessages.inc" );
1213
1314 $wgTitle = Title::newFromText( "Rebuild messages script" );
1415
1516 if ( isset( $args[0] ) ) {
 17+ # Retain script compatibility
1618 $response = array_shift( $args );
1719 if ( $response == "update" ) {
1820 $response = 1;
@@ -26,27 +28,28 @@
2729 } else {
2830 $messages = false;
2931 }
 32+if( isset( $options['update'] ) ) $response = 1;
 33+if( isset( $options['rebuild'] ) ) $response = 2;
3034
3135 if ( $response == 0 ) {
3236 $dbr =& wfGetDB( DB_SLAVE );
3337 $row = $dbr->selectRow( "cur", array("count(*) as c"), array("cur_namespace" => NS_MEDIAWIKI) );
3438 print "Current namespace size: {$row->c}\n";
3539
36 - print "1. Update messages to include latest additions to Language.php\n" .
37 - "2. Delete all messages and reinitialise namespace\n" .
38 - "3. Quit\n\n".
39 -
40 - "Please enter a number: ";
 40+ print <<<END
 41+Usage: php rebuildMessages.php <action> [filename]
4142
42 - do {
43 - $response = IntVal(readconsole());
44 - if ( $response >= 1 && $response <= 3 ) {
45 - $good = true;
46 - } else {
47 - $good = false;
48 - print "Please type a number between 1 and 3: ";
49 - }
50 - } while ( !$good );
 43+Action must be one of:
 44+ --update Update messages to include latest additions to Language.php
 45+ --rebuild Delete all messages and reinitialise namespace
 46+
 47+If a message dump file is given, messages will be read from it to supplement
 48+the defaults in MediaWiki's Language*.php. The file should contain a serialized
 49+PHP associative array, as produced by dumpMessages.php.
 50+
 51+
 52+END;
 53+ exit(0);
5154 }
5255
5356 switch ( $response ) {

Status & tagging log