Don't put \n on the end of every error() call, just do it in error() itself. Still...
authorChad Horohoe <demon@users.mediawiki.org>
Sun, 2 Aug 2009 21:55:10 +0000 (21:55 +0000)
committerChad Horohoe <demon@users.mediawiki.org>
Sun, 2 Aug 2009 21:55:10 +0000 (21:55 +0000)
25 files changed:
maintenance/Maintenance.php
maintenance/addwiki.php
maintenance/benchmarkPurge.php
maintenance/changePassword.php
maintenance/cleanupSpam.php
maintenance/createAndPromote.php
maintenance/deleteBatch.php
maintenance/deleteOldRevisions.php
maintenance/edit.php
maintenance/fixTimestamps.php
maintenance/getLagTimes.php
maintenance/moveBatch.php
maintenance/populateLogSearch.php
maintenance/populateParentId.php
maintenance/protect.php
maintenance/reassignEdits.php
maintenance/rebuildFileCache.php
maintenance/rebuildtextindex.php
maintenance/removeUnusedAccounts.php
maintenance/renameDbPrefix.php
maintenance/runJobs.php
maintenance/sql.php
maintenance/stats.php
maintenance/updateRestrictions.php
maintenance/updateSpecialPages.php

index b1f0a8d..3482d55 100644 (file)
@@ -218,7 +218,7 @@ abstract class Maintenance {
         */
        protected function error( $err, $die = false ) {
                $f = fopen( 'php://stderr', 'w' ); 
-               fwrite( $f, $err );
+               fwrite( $f, $err . "\n" );
                fclose( $f );
                if( $die ) die();
        }
@@ -278,7 +278,7 @@ abstract class Maintenance {
                                require_once( $classFile );
                        }
                        if( !class_exists( $maintClass ) ) {
-                               $this->error( "Cannot spawn child: $maintClass\n" );
+                               $this->error( "Cannot spawn child: $maintClass" );
                        }
                }
                
@@ -295,12 +295,12 @@ abstract class Maintenance {
 
                # Abort if called from a web server
                if ( isset( $_SERVER ) && array_key_exists( 'REQUEST_METHOD', $_SERVER ) ) {
-                       $this->error( "This script must be run from the command line\n", true );
+                       $this->error( "This script must be run from the command line", true );
                }
 
                # Make sure we can handle script parameters
                if( !ini_get( 'register_argc_argv' ) ) {
-                       $this->error( "Cannot get command line arguments, register_argc_argv is set to false\n", true );
+                       $this->error( "Cannot get command line arguments, register_argc_argv is set to false", true );
                }
 
                if( version_compare( phpversion(), '5.2.4' ) >= 0 ) {
@@ -407,7 +407,7 @@ abstract class Maintenance {
                                if ( isset( $this->mParams[$option] ) && $this->mParams[$option]['withArg'] ) {
                                        $param = next( $argv );
                                        if ( $param === false ) {
-                                               $this->error( "$arg needs a value after it\n", true );
+                                               $this->error( "$arg needs a value after it", true );
                                        }
                                        $options[$option] = $param;
                                } else {
@@ -427,7 +427,7 @@ abstract class Maintenance {
                                        if ( $this->mParams[$option]['withArg'] ) {
                                                $param = next( $argv );
                                                if ( $param === false ) {
-                                                       $this->error( "$arg needs a value after it\n", true );
+                                                       $this->error( "$arg needs a value after it", true );
                                                }
                                                $options[$option] = $param;
                                        } else {
@@ -452,13 +452,13 @@ abstract class Maintenance {
                # Check to make sure we've got all the required ones
                foreach( $this->mParams as $opt => $info ) {
                        if( $info['require'] && !$this->hasOption($opt) ) {
-                               $this->error( "Param $opt required.\n", true );
+                               $this->error( "Param $opt required.", true );
                        }
                }
 
                # Also make sure we've got enough arguments
                if ( count( $this->mArgs ) < count( $this->mArgList ) ) {
-                       $this->error( "Not enough arguments passed\n", true );
+                       $this->error( "Not enough arguments passed", true );
                }
        }
        
@@ -633,7 +633,7 @@ abstract class Maintenance {
        
                if ( ! is_readable( $settingsFile ) ) {
                        $this->error( "A copy of your installation's LocalSettings.php\n" .
-                                               "must exist and be readable in the source directory.\n", true );
+                                               "must exist and be readable in the source directory.", true );
                }
                $wgCommandLineMode = true;
                $DP = $IP;
index e721014..57513dc 100644 (file)
@@ -39,7 +39,7 @@ class AddWiki extends Maintenance {
                $dbName = $this->getArg(2);
 
                if ( !isset( $wgLanguageNames[$lang] ) ) {
-                       $this->error( "Language $lang not found in \$wgLanguageNames\n", true );
+                       $this->error( "Language $lang not found in \$wgLanguageNames", true );
                }
                $name = $wgLanguageNames[$lang];
 
index c0c635f..ee5af78 100644 (file)
@@ -33,7 +33,7 @@ class BenchmarkPurge extends Maintenance {
        public function execute() {
                global $wgUseSquid;
                if( !$wgUseSquid ) {
-                       $this->error( "Squid purge benchmark doesn't do much without squid support on.\n". true );
+                       $this->error( "Squid purge benchmark doesn't do much without squid support on.". true );
                } else {
                        $this->output( "There are " . count( $wgSquidServers ) . " defined squid servers:\n" );
                        if( $this->hasOption( 'count' ) ) {
index 5f840f0..10ed826 100644 (file)
@@ -36,7 +36,7 @@ class ChangePassword extends Maintenance {
        public function execute() {
                $user = User::newFromName( $this->getOption('user') );
                if( !$user->getId() ) {
-                       $this->error( "No such user: " . $this->getOption('user') . "\n", true );
+                       $this->error( "No such user: " . $this->getOption('user'), true );
                }
                try {
                        $user->setPassword( $this->getOption('password') );
index b6d8582..78f117c 100644 (file)
@@ -42,7 +42,7 @@ class CleanupSpam extends Maintenance {
                $spec = $this->getArg();
                $like = LinkFilter::makeLike( $spec );
                if ( !$like ) {
-                       $this->error( "Not a valid hostname specification: $spec\n", true );
+                       $this->error( "Not a valid hostname specification: $spec", true );
                }
 
                $dbr = wfGetDB( DB_SLAVE );
@@ -83,7 +83,7 @@ class CleanupSpam extends Maintenance {
        private function cleanupArticle( $id, $domain ) {
                $title = Title::newFromID( $id );
                if ( !$title ) {
-                       $this->error( "Internal error: no page for ID $id\n" );
+                       $this->error( "Internal error: no page for ID $id" );
                        return;
                }
        
index 566885c..0a18596 100644 (file)
@@ -41,9 +41,9 @@ class CreateAndPromote extends Maintenance {
                
                $user = User::newFromName( $username );
                if( !is_object( $user ) ) {
-                       $this->error( "invalid username.\n", true );
+                       $this->error( "invalid username.", true );
                } elseif( 0 != $user->idForName() ) {
-                       $this->error( "account exists.\n", true );
+                       $this->error( "account exists.", true );
                }
 
                # Try to set the password
index 5fc7435..0d6dac9 100644 (file)
@@ -59,7 +59,7 @@ class DeleteBatch extends Maintenance {
 
                # Setup
                if( !$file ) {
-                       $this->error( "Unable to read file, exiting\n", true );
+                       $this->error( "Unable to read file, exiting", true );
                }
                $wgUser = User::newFromName( $user );
                $dbw = wfGetDB( DB_MASTER );
index 6b140fa..7084751 100644 (file)
@@ -34,7 +34,7 @@ class DeleteOldRevisions extends Maintenance {
        public function execute() {
                $this->output( "Delete old revisions\n\n" );
                if( count( $this->mArgs ) < 1 ) {
-                       $this->error( "Must pass at least 1 page_id\n", true );
+                       $this->error( "Must pass at least 1 page_id", true );
                }
                $this->doDelete( $this->hasOption( 'delete' ), $this->mArgs );
        }
index 704909a..8a7cd46 100644 (file)
@@ -47,7 +47,7 @@ class EditCLI extends Maintenance {
                
                $wgUser = User::newFromName( $userName );
                if ( !$wgUser ) {
-                       $this->error( "Invalid username\n", true );
+                       $this->error( "Invalid username", true );
                }
                if ( $wgUser->isAnon() ) {
                        $wgUser->addToDatabase();
@@ -55,7 +55,7 @@ class EditCLI extends Maintenance {
        
                $wgTitle = Title::newFromText( $this->getArg() );
                if ( !$wgTitle ) {
-                       $this->error( "Invalid title\n", true );
+                       $this->error( "Invalid title", true );
                }
        
                $wgArticle = new Article( $wgTitle );
index 61bec78..c9589f5 100644 (file)
@@ -47,7 +47,7 @@ class FixTimestamps extends Maintenance {
                $row = $dbw->fetchObject( $res );
        
                if ( is_null( $row->minrev ) ) {
-                       $this->error( "No revisions in search period.\n", true );
+                       $this->error( "No revisions in search period.", true );
                }
        
                $minRev = $row->minrev;
@@ -98,8 +98,7 @@ class FixTimestamps extends Maintenance {
                was incorrectly set forward, negative means the clock was incorrectly set back.
 
                If the offset is right, then increase the search interval until there are enough 
-               good revisions to provide a majority reference.
-               ", true );
+               good revisions to provide a majority reference.", true );
                } elseif ( $numBadRevs == 0 ) {
                        $this->output( "No bad revisions found.\n" );
                        exit(0);
index cdf73e8..9c9f6b1 100644 (file)
@@ -31,7 +31,7 @@ class GetLagTimes extends Maintenance {
 
                if( $lb->getServerCount() == 1 ) {
                        $this->error( "This script dumps replication lag times, but you don't seem to have\n"
-                                                 . "a multi-host db server configuration.\n" );
+                                                 . "a multi-host db server configuration." );
                } else {
                        $lags = $lb->getLagTimes();
                        foreach( $lags as $n => $lag ) {
index 0e07c32..5f0e3d6 100644 (file)
@@ -64,7 +64,7 @@ class MoveBatch extends Maintenance {
 
                # Setup
                if( !$file ) {
-                       $this->error( "Unable to read file, exiting\n", true );
+                       $this->error( "Unable to read file, exiting", true );
                }
                $wgUser = User::newFromName( $user );
                
@@ -77,13 +77,13 @@ class MoveBatch extends Maintenance {
                        }
                        $parts = array_map( 'trim', explode( '|', $line ) );
                        if ( count( $parts ) != 2 ) {
-                               $this->error( "Error on line $linenum, no pipe character\n" );
+                               $this->error( "Error on line $linenum, no pipe character" );
                                continue;
                        }
                        $source = Title::newFromText( $parts[0] );
                        $dest = Title::newFromText( $parts[1] );
                        if ( is_null( $source ) || is_null( $dest ) ) {
-                               $this->error( "Invalid title on line $linenum\n" );
+                               $this->error( "Invalid title on line $linenum" );
                                continue;
                        }
        
index b8f28df..4d24754 100644 (file)
@@ -35,7 +35,7 @@ class PopulateLogSearch extends Maintenance {
        public function execute() {
                $db = wfGetDB( DB_MASTER );
                if ( !$db->tableExists( 'log_search' ) ) {
-                       $this->error( "log_search does not exist\n", true );
+                       $this->error( "log_search does not exist", true );
                }
                $start = $db->selectField( 'logging', 'MIN(log_id)', false, __FUNCTION__ );
                if( !$start ) {
index 854f2e6..8114b9d 100644 (file)
@@ -34,7 +34,7 @@ class PopulateParentId extends Maintenance {
        public function execute() {
                $db = wfGetDB( DB_MASTER );
                if ( !$db->tableExists( 'revision' ) ) {
-                       $this->error( "revision table does not exist\n", true );
+                       $this->error( "revision table does not exist", true );
                }
                $this->output( "Populating rev_parent_id column\n" );
                $start = $db->selectField( 'revision', 'MIN(rev_id)', false, __FUNCTION__ );
index d929211..6606746 100644 (file)
@@ -46,9 +46,9 @@ class Protect extends Maintenance {
                $wgUser = User::newFromName( $userName );
                $restrictions = array( 'edit' => $protection, 'move' => $protection );
 
-               $wgTitle = Title::newFromText( $args[0] );
+               $wgTitle = Title::newFromText( $this->getArg() );
                if ( !$wgTitle ) {
-                       $this->error( "Invalid title\n", true );
+                       $this->error( "Invalid title", true );
                }
 
                $wgArticle = new Article( $wgTitle );
index 15fef13..714d243 100644 (file)
@@ -50,7 +50,7 @@ class ReassignEdits extends Maintenance {
                                        $this->output( "Run the script again without --report to update.\n" );
                        } else {
                                $ton = $to->getName();
-                               $this->error( "User '{$ton}' not found.\n" );
+                               $this->error( "User '{$ton}' not found." );
                        }
                }
        }
index 0b48f9a..7cfd3fa 100644 (file)
@@ -33,7 +33,7 @@ class RebuildFileCache extends Maintenance {
        public function execute() {
                global $wgUseFileCache, $wgDisableCounters, $wgTitle, $wgArticle, $wgOut;
                if( !$wgUseFileCache ) {
-                       $this->error( "Nothing to do -- \$wgUseFileCache is disabled.\n", true );
+                       $this->error( "Nothing to do -- \$wgUseFileCache is disabled.", true );
                }
                $wgDisableCounters = false;
                $start = intval( $this->getArg( 0, 0 ) );
@@ -44,7 +44,7 @@ class RebuildFileCache extends Maintenance {
                $start = $start > 0 ? $start : $dbr->selectField( 'page', 'MIN(page_id)', false, __FUNCTION__ );
                $end = $dbr->selectField( 'page', 'MAX(page_id)', false, __FUNCTION__ );
                if( !$start ) {
-                       $this->error( "Nothing to do.\n", true );
+                       $this->error( "Nothing to do.", true );
                }
 
                $_SERVER['HTTP_ACCEPT_ENCODING'] = 'bgzip'; // hack, no real client
index a4d7356..17b261f 100644 (file)
@@ -42,7 +42,7 @@ class RebuildTextIndex extends Maintenance {
                // Only do this for MySQL
                $database = wfGetDB( DB_MASTER );
                if( !$database instanceof DatabaseMysql ) {
-                       $this->error( "This script is only for MySQL.\n", true );
+                       $this->error( "This script is only for MySQL.", true );
                }
 
                $wgTitle = Title::newFromText( "Rebuild text index script" );
index 6a36b68..baa76d7 100644 (file)
@@ -48,7 +48,7 @@ class RemoveUnusedAccounts extends Maintenance {
                }
                $touched = $this->getOption( 'ignore-touched', "1" );
                if( !ctype_digit( $touched ) ) {
-                       $this->error( "Please put a valid positive integer on the --ignore-touched parameter.\n", true );
+                       $this->error( "Please put a valid positive integer on the --ignore-touched parameter.", true );
                }
                $touchedSeconds = 86400 * $touched;
                while( $row = $dbr->fetchObject( $res ) ) {
index 68e66ed..b7edc6e 100644 (file)
@@ -49,7 +49,7 @@ class RenameDbPrefix extends Maintenance {
                }
        
                if( $old === false || $new === false ) {
-                       $this->error( "Invalid prefix!\n", true );
+                       $this->error( "Invalid prefix!", true );
                }
                if( $old === $new ) {
                        $this->output( "Same prefix. Nothing to rename!\n", true );
index 956af83..0816c64 100644 (file)
@@ -42,7 +42,7 @@ class RunJobs extends Maintenance {
                if ( $this->hasOption( 'procs' ) ) {
                        $procs = intval( $this->getOption('procs') );
                        if ( $procs < 1 || $procs > 1000 ) {
-                               $this->error( "Invalid argument to --procs\n", true );
+                               $this->error( "Invalid argument to --procs", true );
                        }
                        $fc = new ForkController( $procs );
                        if ( $fc->start( $procs ) != 'child' ) {
index 16175bd..64ddc7a 100644 (file)
@@ -41,7 +41,7 @@ class MwSql extends Maintenance {
                }
        
                if ( !$file )
-                       $this->error( "Unable to open input file\n", true );
+                       $this->error( "Unable to open input file", true );
 
                $dbw = wfGetDB( DB_MASTER );
                $error = $dbw->sourceStream( $file, $promptCallback, array( $this, 'sqlPrintResult' ) );
index b496f0c..53e15a1 100644 (file)
@@ -33,13 +33,13 @@ class CacheStats extends Maintenance {
                
                // Can't do stats if 
                if( get_class( $wgMemc ) == 'FakeMemCachedClient' ) {
-                       $this->error( "You are running FakeMemCachedClient, I can not provide any statistics.\n", true );
+                       $this->error( "You are running FakeMemCachedClient, I can not provide any statistics.", true );
                }
                $session = intval($wgMemc->get(wfMemcKey('stats','request_with_session')));
                $noSession = intval($wgMemc->get(wfMemcKey('stats','request_without_session')));
                $total = $session + $noSession;
                if ( $total == 0 ) {
-                       $this->error( "You either have no stats or the cache isn't running. Aborting.\n", true );
+                       $this->error( "You either have no stats or the cache isn't running. Aborting.", true );
                }
                $this->output( "Requests\n" );
                $this->output( sprintf( "with session:      %-10d %6.2f%%\n", $session, $session/$total*100 ) );
index 52af600..5ae0684 100644 (file)
@@ -35,12 +35,12 @@ class UpdateRestrictions extends Maintenance {
        public function execute() {
                $db = wfGetDB( DB_MASTER );
                if( !$db->tableExists( 'page_restrictions' ) ) {
-                       $this->error( "page_restrictions table does not exist\n", true );
+                       $this->error( "page_restrictions table does not exist", true );
                }
 
                $start = $db->selectField( 'page', 'MIN(page_id)', false, __METHOD__ );
                if( !$start ) {
-                       $this->error( "Nothing to do.\n", true );
+                       $this->error( "Nothing to do.", true );
                }
                $end = $db->selectField( 'page', 'MAX(page_id)', false, __METHOD__ );
        
index c6c4641..298cc27 100644 (file)
@@ -38,7 +38,7 @@ class UpdateSpecialPages extends Maintenance {
 
                foreach( $wgSpecialPageCacheUpdates as $special => $call ) {
                        if( !is_callable($call) ) {
-                               $this->error( "Uncallable function $call!\n" );
+                               $this->error( "Uncallable function $call!" );
                                continue;
                        }
                        $t1 = explode( ' ', microtime() );
@@ -113,7 +113,7 @@ class UpdateSpecialPages extends Maintenance {
                                if ( !wfGetLB()->pingAll())  {
                                        $this->output( "\n" );
                                        do {
-                                               $this->error( "Connection failed, reconnecting in 10 seconds...\n" );
+                                               $this->error( "Connection failed, reconnecting in 10 seconds..." );
                                                sleep(10);
                                        } while ( !wfGetLB()->pingAll() );
                                        $this->output( "Reconnected\n\n" );