From 30468dbcf754c38a8f4e534951015159748776bc Mon Sep 17 00:00:00 2001 From: Chad Horohoe Date: Sun, 2 Aug 2009 21:55:10 +0000 Subject: [PATCH] Don't put \n on the end of every error() call, just do it in error() itself. Still have to use on output(), because people like "Something...done" stuff. --- maintenance/Maintenance.php | 18 +++++++++--------- maintenance/addwiki.php | 2 +- maintenance/benchmarkPurge.php | 2 +- maintenance/changePassword.php | 2 +- maintenance/cleanupSpam.php | 4 ++-- maintenance/createAndPromote.php | 4 ++-- maintenance/deleteBatch.php | 2 +- maintenance/deleteOldRevisions.php | 2 +- maintenance/edit.php | 4 ++-- maintenance/fixTimestamps.php | 5 ++--- maintenance/getLagTimes.php | 2 +- maintenance/moveBatch.php | 6 +++--- maintenance/populateLogSearch.php | 2 +- maintenance/populateParentId.php | 2 +- maintenance/protect.php | 4 ++-- maintenance/reassignEdits.php | 2 +- maintenance/rebuildFileCache.php | 4 ++-- maintenance/rebuildtextindex.php | 2 +- maintenance/removeUnusedAccounts.php | 2 +- maintenance/renameDbPrefix.php | 2 +- maintenance/runJobs.php | 2 +- maintenance/sql.php | 2 +- maintenance/stats.php | 4 ++-- maintenance/updateRestrictions.php | 4 ++-- maintenance/updateSpecialPages.php | 4 ++-- 25 files changed, 44 insertions(+), 45 deletions(-) diff --git a/maintenance/Maintenance.php b/maintenance/Maintenance.php index b1f0a8d7d9..3482d55f6c 100644 --- a/maintenance/Maintenance.php +++ b/maintenance/Maintenance.php @@ -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; diff --git a/maintenance/addwiki.php b/maintenance/addwiki.php index e7210143b3..57513dc636 100644 --- a/maintenance/addwiki.php +++ b/maintenance/addwiki.php @@ -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]; diff --git a/maintenance/benchmarkPurge.php b/maintenance/benchmarkPurge.php index c0c635f3c6..ee5af780bc 100644 --- a/maintenance/benchmarkPurge.php +++ b/maintenance/benchmarkPurge.php @@ -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' ) ) { diff --git a/maintenance/changePassword.php b/maintenance/changePassword.php index 5f840f06fb..10ed826929 100644 --- a/maintenance/changePassword.php +++ b/maintenance/changePassword.php @@ -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') ); diff --git a/maintenance/cleanupSpam.php b/maintenance/cleanupSpam.php index b6d8582fd0..78f117c2ba 100644 --- a/maintenance/cleanupSpam.php +++ b/maintenance/cleanupSpam.php @@ -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; } diff --git a/maintenance/createAndPromote.php b/maintenance/createAndPromote.php index 566885c283..0a18596e77 100644 --- a/maintenance/createAndPromote.php +++ b/maintenance/createAndPromote.php @@ -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 diff --git a/maintenance/deleteBatch.php b/maintenance/deleteBatch.php index 5fc74359b4..0d6dac939b 100644 --- a/maintenance/deleteBatch.php +++ b/maintenance/deleteBatch.php @@ -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 ); diff --git a/maintenance/deleteOldRevisions.php b/maintenance/deleteOldRevisions.php index 6b140faa9f..7084751859 100644 --- a/maintenance/deleteOldRevisions.php +++ b/maintenance/deleteOldRevisions.php @@ -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 ); } diff --git a/maintenance/edit.php b/maintenance/edit.php index 704909adf7..8a7cd46ec2 100644 --- a/maintenance/edit.php +++ b/maintenance/edit.php @@ -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 ); diff --git a/maintenance/fixTimestamps.php b/maintenance/fixTimestamps.php index 61bec789c2..c9589f5999 100644 --- a/maintenance/fixTimestamps.php +++ b/maintenance/fixTimestamps.php @@ -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); diff --git a/maintenance/getLagTimes.php b/maintenance/getLagTimes.php index cdf73e8ede..9c9f6b18a1 100644 --- a/maintenance/getLagTimes.php +++ b/maintenance/getLagTimes.php @@ -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 ) { diff --git a/maintenance/moveBatch.php b/maintenance/moveBatch.php index 0e07c32679..5f0e3d663a 100644 --- a/maintenance/moveBatch.php +++ b/maintenance/moveBatch.php @@ -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; } diff --git a/maintenance/populateLogSearch.php b/maintenance/populateLogSearch.php index b8f28df244..4d247542ac 100644 --- a/maintenance/populateLogSearch.php +++ b/maintenance/populateLogSearch.php @@ -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 ) { diff --git a/maintenance/populateParentId.php b/maintenance/populateParentId.php index 854f2e6e9b..8114b9d636 100644 --- a/maintenance/populateParentId.php +++ b/maintenance/populateParentId.php @@ -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__ ); diff --git a/maintenance/protect.php b/maintenance/protect.php index d929211d12..6606746f45 100644 --- a/maintenance/protect.php +++ b/maintenance/protect.php @@ -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 ); diff --git a/maintenance/reassignEdits.php b/maintenance/reassignEdits.php index 15fef13504..714d24335e 100644 --- a/maintenance/reassignEdits.php +++ b/maintenance/reassignEdits.php @@ -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." ); } } } diff --git a/maintenance/rebuildFileCache.php b/maintenance/rebuildFileCache.php index 0b48f9a791..7cfd3fa513 100644 --- a/maintenance/rebuildFileCache.php +++ b/maintenance/rebuildFileCache.php @@ -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 diff --git a/maintenance/rebuildtextindex.php b/maintenance/rebuildtextindex.php index a4d735654e..17b261f98d 100644 --- a/maintenance/rebuildtextindex.php +++ b/maintenance/rebuildtextindex.php @@ -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" ); diff --git a/maintenance/removeUnusedAccounts.php b/maintenance/removeUnusedAccounts.php index 6a36b68212..baa76d7d1d 100644 --- a/maintenance/removeUnusedAccounts.php +++ b/maintenance/removeUnusedAccounts.php @@ -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 ) ) { diff --git a/maintenance/renameDbPrefix.php b/maintenance/renameDbPrefix.php index 68e66ed4cc..b7edc6eed5 100644 --- a/maintenance/renameDbPrefix.php +++ b/maintenance/renameDbPrefix.php @@ -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 ); diff --git a/maintenance/runJobs.php b/maintenance/runJobs.php index 956af836ad..0816c64883 100644 --- a/maintenance/runJobs.php +++ b/maintenance/runJobs.php @@ -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' ) { diff --git a/maintenance/sql.php b/maintenance/sql.php index 16175bdfaa..64ddc7af50 100644 --- a/maintenance/sql.php +++ b/maintenance/sql.php @@ -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' ) ); diff --git a/maintenance/stats.php b/maintenance/stats.php index b496f0cf73..53e15a1328 100644 --- a/maintenance/stats.php +++ b/maintenance/stats.php @@ -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 ) ); diff --git a/maintenance/updateRestrictions.php b/maintenance/updateRestrictions.php index 52af600083..5ae0684582 100644 --- a/maintenance/updateRestrictions.php +++ b/maintenance/updateRestrictions.php @@ -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__ ); diff --git a/maintenance/updateSpecialPages.php b/maintenance/updateSpecialPages.php index c6c464147c..298cc273a2 100644 --- a/maintenance/updateSpecialPages.php +++ b/maintenance/updateSpecialPages.php @@ -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" ); -- 2.20.1