From 5217f44a24d45ebff21ee5a395b7e35d8188b98a Mon Sep 17 00:00:00 2001 From: Brion Vibber Date: Sun, 17 Oct 2004 21:38:47 +0000 Subject: [PATCH] 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. --- maintenance/rebuildMessages.php | 33 ++++++++++++++++++--------------- 1 file changed, 18 insertions(+), 15 deletions(-) diff --git a/maintenance/rebuildMessages.php b/maintenance/rebuildMessages.php index e195a72418..c2bbb1bed8 100755 --- a/maintenance/rebuildMessages.php +++ b/maintenance/rebuildMessages.php @@ -6,12 +6,14 @@ */ /** */ +$options = array( 'update' => null, 'rebuild' => null ); require_once( "commandLine.inc" ); include_once( "InitialiseMessages.inc" ); $wgTitle = Title::newFromText( "Rebuild messages script" ); if ( isset( $args[0] ) ) { + # Retain script compatibility $response = array_shift( $args ); if ( $response == "update" ) { $response = 1; @@ -26,27 +28,28 @@ if ( isset( $args[0] ) ) { } else { $messages = false; } +if( isset( $options['update'] ) ) $response = 1; +if( isset( $options['rebuild'] ) ) $response = 2; if ( $response == 0 ) { $dbr =& wfGetDB( DB_SLAVE ); $row = $dbr->selectRow( "cur", array("count(*) as c"), array("cur_namespace" => NS_MEDIAWIKI) ); print "Current namespace size: {$row->c}\n"; - print "1. Update messages to include latest additions to Language.php\n" . - "2. Delete all messages and reinitialise namespace\n" . - "3. Quit\n\n". - - "Please enter a number: "; - - do { - $response = IntVal(readconsole()); - if ( $response >= 1 && $response <= 3 ) { - $good = true; - } else { - $good = false; - print "Please type a number between 1 and 3: "; - } - } while ( !$good ); + print << [filename] + +Action must be one of: + --update Update messages to include latest additions to Language.php + --rebuild Delete all messages and reinitialise namespace + +If a message dump file is given, messages will be read from it to supplement +the defaults in MediaWiki's Language*.php. The file should contain a serialized +PHP associative array, as produced by dumpMessages.php. + + +END; + exit(0); } switch ( $response ) { -- 2.20.1