fixing up commandLine.inc so it will work anywhere
authorTim Starling <tstarling@users.mediawiki.org>
Sun, 13 Jun 2004 04:24:44 +0000 (04:24 +0000)
committerTim Starling <tstarling@users.mediawiki.org>
Sun, 13 Jun 2004 04:24:44 +0000 (04:24 +0000)
maintenance/InitialiseMessages.inc
maintenance/commandLine.inc
maintenance/liveCmdLine.inc
maintenance/rebuildMessages.php

index 5d42cff..699ec66 100755 (executable)
@@ -45,7 +45,7 @@ function initialiseMessages( $overwrite = false, $messageArray = false ) {
        # Get keys from $wgAllMessagesEn, which is more complete than the local language
        $first = true;
        if ( $messageArray ) {
-               $sortedArray = $wgAllMessagesEn;
+               $sortedArray = $messageArray;
        } else {
                $sortedArray = $wgAllMessagesEn;
        }
@@ -175,9 +175,13 @@ $message
        }
 }
 
-function loadArrayFromFile( $filename )
+function loadLanguageFile( $filename )
 {
        $contents = file_get_contents( $filename );
+       # Remove header line
+       $p = strpos( $contents, "\n" ) + 1;
+       $contents = substr( $contents, $p );
+       # Unserialize
        return unserialize( $contents );
 }
 
index 102057f..b29c43f 100644 (file)
@@ -1,7 +1,10 @@
 <?php
-if ( strpos( "wikimedia.org", `hostname -a` ) !== false ) {
+if ( strpos( `hostname -a`, "wikimedia.org" ) !== false ) {
        require_once( "liveCmdLine.inc" );
 } else {
+       # Turn off output buffering if it's on
+       @ob_end_flush();
+       
        if ( isset( $_SERVER ) && array_key_exists( 'REQUEST_METHOD', $_SERVER ) ) {
                print "This script must be run from the command line\n";
                exit();
@@ -11,7 +14,8 @@ if ( strpos( "wikimedia.org", `hostname -a` ) !== false ) {
 
        $sep = strchr( $include_path = ini_get( "include_path" ), ";" ) ? ";" : ":";
        if ( @$argv[1] && @$argv[1] != "-" ) {
-               $lang = $argv[1];
+               $self = array_shift( $argv );
+               $lang = array_shift( $argv );
                putenv( "wikilang=$lang");
                $settingsFile = "/apache/htdocs/{$argv[1]}/w/LocalSettings.php";
                $newpath = "/apache/common/php$sep";
@@ -35,9 +39,8 @@ if ( strpos( "wikimedia.org", `hostname -a` ) !== false ) {
        $wgUsePHPTal = false;
        define("MEDIAWIKI",true);
        include_once( "Setup.php" );
-       include_once( "./InitialiseMessages.inc" );
        include_once( "../install-utils.inc" );
-       $wgTitle = Title::newFromText( "Rebuild messages script" );
+       $wgTitle = Title::newFromText( "Command line script" );
        $wgCommandLineMode = true;
        set_time_limit(0);
 }
index 5d51a6a..67d09d1 100644 (file)
@@ -11,14 +11,17 @@ if ( isset( $_SERVER ) && array_key_exists( 'REQUEST_METHOD', $_SERVER ) ) {
 }
 
 $wgCommandLineMode = true;
+$self = array_shift( $argv );
+# Turn off output buffering if it's on
+@ob_end_flush();
 
-if ( isset( $argv[1] ) ) {
-       $lang = $argv[1];
+if ( isset( $argv[0] ) ) {
+       $lang = array_shift( $argv );
 } else {
        $lang = "aa";
 }
-if ( isset( $argv[2] ) ) {
-       $site = $argv[2];
+if ( isset( $argv[0] ) ) {
+       $site = array_shift( $argv );
 } else {
        $site = "wikipedia";
 }
@@ -42,7 +45,8 @@ require_once( "/home/wikipedia/common/php-new/CommonSettings.php" );
 $wgUsePHPTal = false;
 
 define("MEDIAWIKI",true);
-include_once( "Setup.php" );
+require_once( "Setup.php" );
+require_once( "../install-utils.inc" );
 $wgTitle = Title::newFromText( "Command line script" );
 $wgCommandLineMode = true;
 set_time_limit(0);
index d97d16f..068ac1f 100755 (executable)
@@ -1,48 +1,21 @@
 <?php
-$wgCommandLineMode = true;
-# Turn off output buffering if it's on
-@ob_end_flush();
-       
-$sep = strchr( $include_path = ini_get( "include_path" ), ";" ) ? ";" : ":";
-if ( isset($argv[1]) && $argv[1] ) {
-       $lang = $argv[1];
-       putenv( "wikilang=$lang");
-       $settingsFile = "/apache/htdocs/{$argv[1]}/w/LocalSettings.php";
-       $newpath = "/apache/common/php$sep";
-} else {
-       $settingsFile = "../LocalSettings.php";
-       $newpath = "";
-}
+require_once( "commandLine.inc" );
+include_once( "./InitialiseMessages.inc" );
+
+$wgTitle = Title::newFromText( "Rebuild messages script" );
 
-if ( isset($argv[2]) && $argv[2] == "update" ) {
-       $response = 1;
-} elseif ( isset($argv[2]) && $argv[2] == "reinitialise" ) {
-       $response = 2;
+if ( isset( $argv[0] ) ) {
+       $response = array_shift( $argv );
+       if ( $response == "update" ) {
+               $response = 1;
+       } elseif ( $response == "rebuild" ) {
+               $response = 2;
+       }
 } else {
        $response = 0;
 }
-
-if ( ! is_readable( $settingsFile ) ) {
-       print "A copy of your installation's LocalSettings.php\n" .
-         "must exist in the source directory.\n";
-       exit();
-}
-
-ini_set( "include_path", "../includes$sep../languages$sep$newpath$IP$sep$include_path" );
-
-$wgCommandLineMode = true;
-$DP = "../includes";
-require_once( $settingsFile );
-
-require_once( "Setup.php" );
-require_once( "./InitialiseMessages.inc" );
-require_once( "../install-utils.inc" );
-$wgTitle = Title::newFromText( "Rebuild messages script" );
-$wgCommandLineMode = true;
-set_time_limit(0);
-
-if ( isset($argv) && count( $argv ) >= 3 ) {
-       $messages = loadArrayFromFile( $argv[3] );
+if ( isset( $argv[0] ) ) {
+       $messages = loadLanguageFile( array_shift( $argv ) );
 } else {
        $messages = false;
 }