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.
This commit is contained in:
parent
5ff7ffe312
commit
30468dbcf7
25 changed files with 44 additions and 45 deletions
|
|
@ -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;
|
||||
|
|
|
|||
|
|
@ -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];
|
||||
|
||||
|
|
|
|||
|
|
@ -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' ) ) {
|
||||
|
|
|
|||
|
|
@ -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') );
|
||||
|
|
|
|||
|
|
@ -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;
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -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
|
||||
|
|
|
|||
|
|
@ -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 );
|
||||
|
|
|
|||
|
|
@ -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 );
|
||||
}
|
||||
|
|
|
|||
|
|
@ -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 );
|
||||
|
|
|
|||
|
|
@ -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);
|
||||
|
|
|
|||
|
|
@ -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 ) {
|
||||
|
|
|
|||
|
|
@ -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;
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -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 ) {
|
||||
|
|
|
|||
|
|
@ -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__ );
|
||||
|
|
|
|||
|
|
@ -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 );
|
||||
|
|
|
|||
|
|
@ -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." );
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -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
|
||||
|
|
|
|||
|
|
@ -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" );
|
||||
|
|
|
|||
|
|
@ -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 ) ) {
|
||||
|
|
|
|||
|
|
@ -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 );
|
||||
|
|
|
|||
|
|
@ -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' ) {
|
||||
|
|
|
|||
|
|
@ -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' ) );
|
||||
|
|
|
|||
|
|
@ -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 ) );
|
||||
|
|
|
|||
|
|
@ -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__ );
|
||||
|
||||
|
|
|
|||
|
|
@ -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" );
|
||||
|
|
|
|||
Loading…
Reference in a new issue