-<?
-$wgCommandLineMode = true;
+<?php
+/**
+ * @todo document
+ * @package MediaWiki
+ * @subpackage Maintenance
+ */
-if ( ! is_readable( "../LocalSettings.php" ) ) {
- print "A copy of your installation's LocalSettings.php\n" .
- "must exist in the source directory.\n";
- exit();
+/** */
+$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;
+ } elseif ( $response == "rebuild" ) {
+ $response = 2;
+ }
+} else {
+ $response = 0;
}
+if ( isset( $args[0] ) ) {
+ $messages = loadLanguageFile( array_shift( $args ) );
+} else {
+ $messages = false;
+}
+if( isset( $options['update'] ) ) $response = 1;
+if( isset( $options['rebuild'] ) ) $response = 2;
-$DP = "../includes";
-include_once( "../LocalSettings.php" );
-include_once( "../AdminSettings.php" );
+if ( $response == 0 ) {
+ $dbr =& wfGetDB( DB_SLAVE );
+ $row = $dbr->selectRow( "page", array("count(*) as c"), array("page_namespace" => NS_MEDIAWIKI) );
+ print "Current namespace size: {$row->c}\n";
-include_once( "{$IP}/Setup.php" );
-include_once( "./InitialiseMessages.inc" );
-$wgTitle = Title::newFromText( "Rebuild messages script" );
-$wgCommandLineMode = true;
-set_time_limit(0);
+ print <<<END
+Usage: php rebuildMessages.php <action> [filename]
+
+Action must be one of:
+ --update Update messages to include latest additions to MessagesXX.php
+ --rebuild Delete all messages and reinitialise namespace
-initialiseMessages( true );
+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 ) {
+ case 1:
+ initialiseMessages( false, $messages );
+ break;
+ case 2:
+ initialiseMessages( true, $messages );
+ break;
+}
exit();