Update formatting in maintenance/ (4/4)
Change-Id: I6b58d014a4bfd6600e4e6f80188fdcfce18482ca
This commit is contained in:
parent
5a77286a1e
commit
606c680b21
30 changed files with 152 additions and 100 deletions
|
|
@ -74,5 +74,4 @@ function PurgeRedundantText( $delete = false ) {
|
|||
|
||||
# Done
|
||||
$dbw->commit( __METHOD__ );
|
||||
|
||||
}
|
||||
|
|
|
|||
|
|
@ -37,7 +37,8 @@ class PurgeParserCache extends Maintenance {
|
|||
$this->addDescription( "Remove old objects from the parser cache. " .
|
||||
"This only works when the parser cache is in an SQL database." );
|
||||
$this->addOption( 'expiredate', 'Delete objects expiring before this date.', false, true );
|
||||
$this->addOption( 'age',
|
||||
$this->addOption(
|
||||
'age',
|
||||
'Delete objects created more than this many seconds ago, assuming $wgParserCacheExpireTime ' .
|
||||
'has been consistent.',
|
||||
false, true );
|
||||
|
|
@ -77,8 +78,8 @@ class PurgeParserCache extends Maintenance {
|
|||
$stars = floor( $percent / 2 );
|
||||
$this->output( '[' . str_repeat( '*', $stars ) . str_repeat( '.', 50 - $stars ) . '] ' .
|
||||
"$percentString%\r" );
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
$maintClass = 'PurgeParserCache';
|
||||
require_once RUN_MAINTENANCE_IF_MAIN;
|
||||
|
|
|
|||
|
|
@ -140,6 +140,7 @@ class ReassignEdits extends Maintenance {
|
|||
}
|
||||
|
||||
$dbw->commit( __METHOD__ );
|
||||
|
||||
return (int)$total;
|
||||
}
|
||||
|
||||
|
|
@ -189,6 +190,7 @@ class ReassignEdits extends Maintenance {
|
|||
}
|
||||
}
|
||||
$user->load();
|
||||
|
||||
return $user;
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -79,6 +79,7 @@ class ImageBuilder extends Maintenance {
|
|||
if ( !isset( $this->repo ) ) {
|
||||
$this->repo = RepoGroup::singleton()->getLocalRepo();
|
||||
}
|
||||
|
||||
return $this->repo;
|
||||
}
|
||||
|
||||
|
|
@ -149,6 +150,7 @@ class ImageBuilder extends Maintenance {
|
|||
// Create a File object from the row
|
||||
// This will also upgrade it
|
||||
$file = $this->getRepo()->newFileFromRow( $row );
|
||||
|
||||
return $file->getUpgraded();
|
||||
}
|
||||
|
||||
|
|
@ -161,9 +163,11 @@ class ImageBuilder extends Maintenance {
|
|||
// This will also upgrade it
|
||||
if ( $row->oi_archive_name == '' ) {
|
||||
$this->output( "Empty oi_archive_name for oi_name={$row->oi_name}\n" );
|
||||
|
||||
return false;
|
||||
}
|
||||
$file = $this->getRepo()->newFileFromRow( $row );
|
||||
|
||||
return $file->getUpgraded();
|
||||
}
|
||||
|
||||
|
|
@ -201,21 +205,22 @@ class ImageBuilder extends Maintenance {
|
|||
|
||||
if ( $filename == '' ) {
|
||||
$this->output( "Empty filename for $fullpath\n" );
|
||||
|
||||
return;
|
||||
}
|
||||
if ( !$this->dryrun ) {
|
||||
$file = wfLocalFile( $filename );
|
||||
if ( !$file->recordUpload(
|
||||
'',
|
||||
'(recovered file, missing upload log entry)',
|
||||
'',
|
||||
'',
|
||||
'',
|
||||
false,
|
||||
$timestamp
|
||||
)
|
||||
) {
|
||||
'',
|
||||
'(recovered file, missing upload log entry)',
|
||||
'',
|
||||
'',
|
||||
'',
|
||||
false,
|
||||
$timestamp
|
||||
) ) {
|
||||
$this->output( "Error uploading file $fullpath\n" );
|
||||
|
||||
return;
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -52,6 +52,7 @@ class RebuildLocalisationCache extends Maintenance {
|
|||
if ( $this->hasOption( 'memory-limit' ) ) {
|
||||
return parent::memoryLimit();
|
||||
}
|
||||
|
||||
return '1000M';
|
||||
}
|
||||
|
||||
|
|
@ -148,7 +149,7 @@ class RebuildLocalisationCache extends Maintenance {
|
|||
/**
|
||||
* Helper function to rebuild list of languages codes. Prints the code
|
||||
* for each language which is rebuilt.
|
||||
* @param array $codes List of language codes to rebuild.
|
||||
* @param array $codes List of language codes to rebuild.
|
||||
* @param LocalisationCache $lc Instance of LocalisationCacheBulkLoad (?)
|
||||
* @param bool $force Rebuild up-to-date languages
|
||||
* @return int Number of rebuilt languages
|
||||
|
|
@ -162,6 +163,7 @@ class RebuildLocalisationCache extends Maintenance {
|
|||
$numRebuilt++;
|
||||
}
|
||||
}
|
||||
|
||||
return $numRebuilt;
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -69,29 +69,31 @@ class RebuildRecentchanges extends Maintenance {
|
|||
$cutoff = time() - $wgRCMaxAge;
|
||||
$dbw->insertSelect( 'recentchanges', array( 'page', 'revision' ),
|
||||
array(
|
||||
'rc_timestamp' => 'rev_timestamp',
|
||||
'rc_user' => 'rev_user',
|
||||
'rc_user_text' => 'rev_user_text',
|
||||
'rc_namespace' => 'page_namespace',
|
||||
'rc_title' => 'page_title',
|
||||
'rc_comment' => 'rev_comment',
|
||||
'rc_minor' => 'rev_minor_edit',
|
||||
'rc_bot' => 0,
|
||||
'rc_new' => 'page_is_new',
|
||||
'rc_cur_id' => 'page_id',
|
||||
'rc_timestamp' => 'rev_timestamp',
|
||||
'rc_user' => 'rev_user',
|
||||
'rc_user_text' => 'rev_user_text',
|
||||
'rc_namespace' => 'page_namespace',
|
||||
'rc_title' => 'page_title',
|
||||
'rc_comment' => 'rev_comment',
|
||||
'rc_minor' => 'rev_minor_edit',
|
||||
'rc_bot' => 0,
|
||||
'rc_new' => 'page_is_new',
|
||||
'rc_cur_id' => 'page_id',
|
||||
'rc_this_oldid' => 'rev_id',
|
||||
'rc_last_oldid' => 0, // is this ok?
|
||||
'rc_type' => $dbw->conditional( 'page_is_new != 0', RC_NEW, RC_EDIT ),
|
||||
'rc_source' => $dbw->conditional(
|
||||
'page_is_new != 0',
|
||||
$dbw->addQuotes( RecentChange::SRC_NEW ),
|
||||
$dbw->addQuotes( RecentChange::SRC_EDIT )
|
||||
'rc_type' => $dbw->conditional( 'page_is_new != 0', RC_NEW, RC_EDIT ),
|
||||
'rc_source' => $dbw->conditional(
|
||||
'page_is_new != 0',
|
||||
$dbw->addQuotes( RecentChange::SRC_NEW ),
|
||||
$dbw->addQuotes( RecentChange::SRC_EDIT )
|
||||
),
|
||||
'rc_deleted' => 'rev_deleted'
|
||||
), array(
|
||||
'rc_deleted' => 'rev_deleted'
|
||||
),
|
||||
array(
|
||||
'rev_timestamp > ' . $dbw->addQuotes( $dbw->timestamp( $cutoff ) ),
|
||||
'rev_page=page_id'
|
||||
), __METHOD__,
|
||||
),
|
||||
__METHOD__,
|
||||
array(), // INSERT options
|
||||
array( 'ORDER BY' => 'rev_timestamp DESC', 'LIMIT' => 5000 ) // SELECT options
|
||||
);
|
||||
|
|
@ -193,31 +195,33 @@ class RebuildRecentchanges extends Maintenance {
|
|||
"$logging LEFT JOIN $page ON (log_namespace=page_namespace AND log_title=page_title)"
|
||||
),
|
||||
array(
|
||||
'rc_timestamp' => 'log_timestamp',
|
||||
'rc_user' => 'log_user',
|
||||
'rc_user_text' => 'user_name',
|
||||
'rc_namespace' => 'log_namespace',
|
||||
'rc_title' => 'log_title',
|
||||
'rc_comment' => 'log_comment',
|
||||
'rc_minor' => 0,
|
||||
'rc_bot' => 0,
|
||||
'rc_patrolled' => 1,
|
||||
'rc_new' => 0,
|
||||
'rc_timestamp' => 'log_timestamp',
|
||||
'rc_user' => 'log_user',
|
||||
'rc_user_text' => 'user_name',
|
||||
'rc_namespace' => 'log_namespace',
|
||||
'rc_title' => 'log_title',
|
||||
'rc_comment' => 'log_comment',
|
||||
'rc_minor' => 0,
|
||||
'rc_bot' => 0,
|
||||
'rc_patrolled' => 1,
|
||||
'rc_new' => 0,
|
||||
'rc_this_oldid' => 0,
|
||||
'rc_last_oldid' => 0,
|
||||
'rc_type' => RC_LOG,
|
||||
'rc_source' => $dbw->addQuotes( RecentChange::SRC_LOG ),
|
||||
'rc_cur_id' => $dbw->cascadingDeletes() ? 'page_id' : 'COALESCE(page_id, 0)',
|
||||
'rc_log_type' => 'log_type',
|
||||
'rc_type' => RC_LOG,
|
||||
'rc_source' => $dbw->addQuotes( RecentChange::SRC_LOG ),
|
||||
'rc_cur_id' => $dbw->cascadingDeletes() ? 'page_id' : 'COALESCE(page_id, 0)',
|
||||
'rc_log_type' => 'log_type',
|
||||
'rc_log_action' => 'log_action',
|
||||
'rc_logid' => 'log_id',
|
||||
'rc_params' => 'log_params',
|
||||
'rc_deleted' => 'log_deleted'
|
||||
), array(
|
||||
'rc_logid' => 'log_id',
|
||||
'rc_params' => 'log_params',
|
||||
'rc_deleted' => 'log_deleted'
|
||||
),
|
||||
array(
|
||||
'log_timestamp > ' . $dbw->addQuotes( $dbw->timestamp( $cutoff ) ),
|
||||
'log_user=user_id',
|
||||
'log_type IN(' . implode( ',', $selectLogs ) . ')'
|
||||
), __METHOD__,
|
||||
),
|
||||
__METHOD__,
|
||||
array(), // INSERT options
|
||||
array( 'ORDER BY' => 'log_timestamp DESC', 'LIMIT' => 5000 ) // SELECT options
|
||||
);
|
||||
|
|
@ -299,7 +303,6 @@ class RebuildRecentchanges extends Maintenance {
|
|||
$messageMemc->delete( wfMemcKey( 'rcfeed', $feed, 'timestamp' ) ); # Good enough for now.
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
$maintClass = "RebuildRecentchanges";
|
||||
|
|
|
|||
|
|
@ -82,7 +82,6 @@ class RefreshImageMetadata extends Maintenance {
|
|||
false,
|
||||
true
|
||||
);
|
||||
|
||||
}
|
||||
|
||||
public function execute() {
|
||||
|
|
@ -148,7 +147,7 @@ class RefreshImageMetadata extends Maintenance {
|
|||
// to weed out any inconsequential changes.
|
||||
$error++;
|
||||
$this->output( "Warning: File:{$row->img_name} used to have " .
|
||||
"$oldLength bytes of metadata but now has $newLength bytes.\n" );
|
||||
"$oldLength bytes of metadata but now has $newLength bytes.\n" );
|
||||
} elseif ( $verbose ) {
|
||||
$this->output( "Refreshed File:{$row->img_name}.\n" );
|
||||
}
|
||||
|
|
@ -161,20 +160,17 @@ class RefreshImageMetadata extends Maintenance {
|
|||
if ( $newLength < $oldLength - 5 ) {
|
||||
$error++;
|
||||
$this->output( "Warning: File:{$row->img_name} used to have " .
|
||||
"$oldLength bytes of metadata but now has $newLength bytes. (forced)\n" );
|
||||
|
||||
"$oldLength bytes of metadata but now has $newLength bytes. (forced)\n" );
|
||||
}
|
||||
if ( $verbose ) {
|
||||
$this->output( "Forcibly refreshed File:{$row->img_name}.\n" );
|
||||
}
|
||||
}
|
||||
else {
|
||||
} else {
|
||||
if ( $verbose ) {
|
||||
$this->output( "Skipping File:{$row->img_name}.\n" );
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
$conds2 = array( 'img_name > ' . $dbw->addQuotes( $row->img_name ) );
|
||||
wfWaitForSlaves();
|
||||
|
|
@ -216,6 +212,7 @@ class RefreshImageMetadata extends Maintenance {
|
|||
if ( $like ) {
|
||||
$conds[] = 'img_metadata ' . $dbw->buildLike( $dbw->anyString(), $like, $dbw->anyString() );
|
||||
}
|
||||
|
||||
return $conds;
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -65,7 +65,8 @@ class RefreshLinks extends Maintenance {
|
|||
* @param bool $oldRedirectsOnly Only fix redirects without redirect entries
|
||||
*/
|
||||
private function doRefreshLinks( $start, $newOnly = false, $maxLag = false,
|
||||
$end = 0, $redirectsOnly = false, $oldRedirectsOnly = false ) {
|
||||
$end = 0, $redirectsOnly = false, $oldRedirectsOnly = false
|
||||
) {
|
||||
global $wgParser, $wgUseTidy;
|
||||
|
||||
$reportingInterval = 100;
|
||||
|
|
@ -196,6 +197,7 @@ class RefreshLinks extends Maintenance {
|
|||
// Delete any redirect table entry for it
|
||||
$dbw->delete( 'redirect', array( 'rd_from' => $id ),
|
||||
__METHOD__ );
|
||||
|
||||
return;
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -64,7 +64,7 @@ class RemoveUnusedAccounts extends Maintenance {
|
|||
if ( count( array_intersect( $instance->getEffectiveGroups(), $excludedGroups ) ) == 0
|
||||
&& $this->isInactiveAccount( $row->user_id, true )
|
||||
&& wfTimestamp( TS_UNIX, $row->user_touched ) < wfTimestamp( TS_UNIX, time() - $touchedSeconds )
|
||||
) {
|
||||
) {
|
||||
# Inactive; print out the name and flag it
|
||||
$del[] = $row->user_id;
|
||||
$this->output( $row->user_name . "\n" );
|
||||
|
|
|
|||
|
|
@ -84,6 +84,7 @@ class DumpRenderer extends Maintenance {
|
|||
$title = $rev->getTitle();
|
||||
if ( !$title ) {
|
||||
$this->error( "Got bogus revision with null title!" );
|
||||
|
||||
return;
|
||||
}
|
||||
$display = $title->getPrefixedText();
|
||||
|
|
|
|||
|
|
@ -70,7 +70,7 @@ class ResetUserTokens extends Maintenance {
|
|||
$where = array();
|
||||
if ( $this->nullsOnly ) {
|
||||
// Have to build this by hand, because \ is escaped in helper functions
|
||||
$where = array( 'user_token = \'' . str_repeat( '\0', 32) . '\'' );
|
||||
$where = array( 'user_token = \'' . str_repeat( '\0', 32 ) . '\'' );
|
||||
}
|
||||
|
||||
$maxid = $dbr->selectField( 'user', 'MAX(user_id)', array(), __METHOD__ );
|
||||
|
|
@ -98,9 +98,7 @@ class ResetUserTokens extends Maintenance {
|
|||
$max = $min + $this->mBatchSize;
|
||||
|
||||
wfWaitForSlaves();
|
||||
|
||||
} while ( $min <= $maxid );
|
||||
|
||||
}
|
||||
|
||||
private function updateUser( $userid ) {
|
||||
|
|
|
|||
|
|
@ -72,6 +72,7 @@ class RollbackEdits extends Maintenance {
|
|||
|
||||
if ( !$titles ) {
|
||||
$this->output( 'No suitable titles to be rolled back' );
|
||||
|
||||
return;
|
||||
}
|
||||
|
||||
|
|
@ -105,6 +106,7 @@ class RollbackEdits extends Maintenance {
|
|||
foreach ( $results as $row ) {
|
||||
$titles[] = Title::makeTitle( $row->page_namespace, $row->page_title );
|
||||
}
|
||||
|
||||
return $titles;
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -43,6 +43,7 @@ class RunJobs extends Maintenance {
|
|||
if ( $this->hasOption( 'memory-limit' ) ) {
|
||||
return parent::memoryLimit();
|
||||
}
|
||||
|
||||
// Don't eat all memory on the machine if we get a bad job.
|
||||
return "150M";
|
||||
}
|
||||
|
|
@ -101,7 +102,7 @@ class RunJobs extends Maintenance {
|
|||
$this->runJobsLog( $job->toString() . " STARTING" );
|
||||
|
||||
// Set timer to stop the job if too much CPU time is used
|
||||
set_time_limit( $maxTime ?: 0 );
|
||||
set_time_limit( $maxTime ? : 0 );
|
||||
// Run the job...
|
||||
wfProfileIn( __METHOD__ . '-' . get_class( $job ) );
|
||||
$t = microtime( true );
|
||||
|
|
@ -209,7 +210,7 @@ class RunJobs extends Maintenance {
|
|||
$content = stream_get_contents( $handle );
|
||||
flock( $handle, LOCK_UN );
|
||||
fclose( $handle );
|
||||
$backoffs = json_decode( $content, true ) ?: array();
|
||||
$backoffs = json_decode( $content, true ) ? : array();
|
||||
}
|
||||
|
||||
return $backoffs;
|
||||
|
|
@ -227,7 +228,7 @@ class RunJobs extends Maintenance {
|
|||
$handle = fopen( $file, 'wb+' );
|
||||
flock( $handle, LOCK_EX );
|
||||
$content = stream_get_contents( $handle );
|
||||
$cBackoffs = json_decode( $content, true ) ?: array();
|
||||
$cBackoffs = json_decode( $content, true ) ? : array();
|
||||
foreach ( $backoffs as $type => $timestamp ) {
|
||||
$cBackoffs[$type] = isset( $cBackoffs[$type] ) ? $cBackoffs[$type] : 0;
|
||||
$cBackoffs[$type] = max( $cBackoffs[$type], $backoffs[$type] );
|
||||
|
|
|
|||
|
|
@ -41,6 +41,7 @@ class ShowSiteStats extends Maintenance {
|
|||
parent::__construct();
|
||||
$this->mDescription = "Show the cached statistics";
|
||||
}
|
||||
|
||||
public function execute() {
|
||||
$fields = array(
|
||||
'ss_total_views' => 'Total views',
|
||||
|
|
|
|||
|
|
@ -39,7 +39,7 @@ class MwSql extends Maintenance {
|
|||
}
|
||||
|
||||
public function execute() {
|
||||
$wiki = $this->getOption( 'wikidb' ) ?: false;
|
||||
$wiki = $this->getOption( 'wikidb' ) ? : false;
|
||||
// Get the appropriate load balancer (for this wiki)
|
||||
if ( $this->hasOption( 'cluster' ) ) {
|
||||
$lb = wfGetLBFactory()->getExternalLB( $this->getOption( 'cluster' ), $wiki );
|
||||
|
|
@ -88,12 +88,12 @@ class MwSql extends Maintenance {
|
|||
}
|
||||
|
||||
$useReadline = function_exists( 'readline_add_history' )
|
||||
&& Maintenance::posix_isatty( 0 /*STDIN*/ );
|
||||
&& Maintenance::posix_isatty( 0 /*STDIN*/ );
|
||||
|
||||
if ( $useReadline ) {
|
||||
global $IP;
|
||||
$historyFile = isset( $_ENV['HOME'] ) ?
|
||||
"{$_ENV['HOME']}/.mwsql_history" : "$IP/maintenance/.mwsql_history";
|
||||
"{$_ENV['HOME']}/.mwsql_history" : "$IP/maintenance/.mwsql_history";
|
||||
readline_read_history( $historyFile );
|
||||
}
|
||||
|
||||
|
|
@ -126,7 +126,7 @@ class MwSql extends Maintenance {
|
|||
$prompt = $newPrompt;
|
||||
$wholeLine = '';
|
||||
} catch ( DBQueryError $e ) {
|
||||
$doDie = ! Maintenance::posix_isatty( 0 );
|
||||
$doDie = !Maintenance::posix_isatty( 0 );
|
||||
$this->error( $e, $doDie );
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -78,6 +78,7 @@ class Sqlite {
|
|||
foreach ( $columns as $col ) {
|
||||
if ( !isset( $allowedTypes[strtolower( $col->type )] ) ) {
|
||||
$db->close();
|
||||
|
||||
return "Table {$table->name} has column {$col->name} with non-native type '{$col->type}'";
|
||||
}
|
||||
}
|
||||
|
|
@ -86,6 +87,7 @@ class Sqlite {
|
|||
return $e->getMessage();
|
||||
}
|
||||
$db->close();
|
||||
|
||||
return true;
|
||||
}
|
||||
};
|
||||
}
|
||||
|
|
|
|||
|
|
@ -55,6 +55,7 @@ class SqliteMaintenance extends Maintenance {
|
|||
// Should work even if we use a non-SQLite database
|
||||
if ( $this->hasOption( 'check-syntax' ) ) {
|
||||
$this->checkSyntax();
|
||||
|
||||
return;
|
||||
}
|
||||
|
||||
|
|
@ -62,6 +63,7 @@ class SqliteMaintenance extends Maintenance {
|
|||
|
||||
if ( $this->db->getType() != 'sqlite' ) {
|
||||
$this->error( "This maintenance script requires a SQLite database.\n" );
|
||||
|
||||
return;
|
||||
}
|
||||
|
||||
|
|
@ -101,6 +103,7 @@ class SqliteMaintenance extends Maintenance {
|
|||
|
||||
if ( !$res || $res->numRows() == 0 ) {
|
||||
$this->error( "Error: integrity check query returned nothing.\n" );
|
||||
|
||||
return;
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -322,7 +322,6 @@ class CheckStorage {
|
|||
|
||||
// Check targets of unresolved stubs
|
||||
$this->checkExternalConcatBlobs( $externalConcatBlobs );
|
||||
|
||||
// next chunk
|
||||
}
|
||||
|
||||
|
|
@ -403,7 +402,6 @@ class CheckStorage {
|
|||
);
|
||||
}
|
||||
unset( $oldIds[$row->blob_id] );
|
||||
|
||||
}
|
||||
$extDb->freeResult( $res );
|
||||
|
||||
|
|
@ -434,6 +432,7 @@ class CheckStorage {
|
|||
// Write revision list
|
||||
if ( !file_put_contents( $revFileName, implode( "\n", $revIds ) ) ) {
|
||||
echo "Error writing revision list, can't restore text\n";
|
||||
|
||||
return;
|
||||
}
|
||||
|
||||
|
|
@ -450,12 +449,14 @@ class CheckStorage {
|
|||
|
||||
if ( $exitStatus ) {
|
||||
echo "mwdumper died with exit status $exitStatus\n";
|
||||
|
||||
return;
|
||||
}
|
||||
|
||||
$file = fopen( $filteredXmlFileName, 'r' );
|
||||
if ( !$file ) {
|
||||
echo "Unable to open filtered XML file\n";
|
||||
|
||||
return;
|
||||
}
|
||||
|
||||
|
|
@ -477,6 +478,7 @@ class CheckStorage {
|
|||
|
||||
if ( $content === null ) {
|
||||
echo "Revision $id is broken, we have no content available\n";
|
||||
|
||||
return;
|
||||
}
|
||||
|
||||
|
|
@ -488,12 +490,14 @@ class CheckStorage {
|
|||
// be safe, we'll skip it and leave it broken
|
||||
|
||||
echo "Revision $id is blank in the dump, may have been broken before export\n";
|
||||
|
||||
return;
|
||||
}
|
||||
|
||||
if ( !$id ) {
|
||||
// No ID, can't import
|
||||
echo "No id tag in revision, can't import\n";
|
||||
|
||||
return;
|
||||
}
|
||||
|
||||
|
|
@ -502,6 +506,7 @@ class CheckStorage {
|
|||
$oldId = $dbr->selectField( 'revision', 'rev_text_id', array( 'rev_id' => $id ), __METHOD__ );
|
||||
if ( !$oldId ) {
|
||||
echo "Missing revision row for rev_id $id\n";
|
||||
|
||||
return;
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -296,6 +296,7 @@ class FixBug20757 extends Maintenance {
|
|||
$this->mapCache[$pageId] = $map;
|
||||
$this->mapCacheSize += count( $map );
|
||||
}
|
||||
|
||||
return $this->mapCache[$pageId];
|
||||
}
|
||||
|
||||
|
|
@ -312,7 +313,7 @@ class FixBug20757 extends Maintenance {
|
|||
if ( in_array( 'external', $flags ) ) {
|
||||
$url = $text;
|
||||
wfSuppressWarnings();
|
||||
list( /* $proto */ , $path ) = explode( '://', $url, 2 );
|
||||
list( /* $proto */, $path ) = explode( '://', $url, 2 );
|
||||
wfRestoreWarnings();
|
||||
|
||||
if ( $path == "" ) {
|
||||
|
|
@ -341,6 +342,7 @@ class FixBug20757 extends Maintenance {
|
|||
|
||||
$obj->uncompress();
|
||||
$text = $obj->getItem( $stub['hash'] );
|
||||
|
||||
return $text !== false;
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -38,6 +38,7 @@ class OrphanStats extends Maintenance {
|
|||
|
||||
protected function &getDB( $cluster, $groups = array(), $wiki = false ) {
|
||||
$lb = wfGetLBFactory()->getExternalLB( $cluster );
|
||||
|
||||
return $lb->getConnection( DB_SLAVE );
|
||||
}
|
||||
|
||||
|
|
@ -65,7 +66,7 @@ class OrphanStats extends Maintenance {
|
|||
$num++;
|
||||
$size = strlen( $blobRow->blob_text );
|
||||
$totalSize += $size;
|
||||
$hashes[ sha1( $blobRow->blob_text ) ] = true;
|
||||
$hashes[sha1( $blobRow->blob_text )] = true;
|
||||
$maxSize = max( $size, $maxSize );
|
||||
}
|
||||
unset( $res );
|
||||
|
|
@ -73,8 +74,8 @@ class OrphanStats extends Maintenance {
|
|||
$this->output( "Number of orphans: $num\n" );
|
||||
if ( $num > 0 ) {
|
||||
$this->output( "Average size: " . round( $totalSize / $num, 0 ) . " bytes\n" .
|
||||
"Max size: $maxSize\n" .
|
||||
"Number of unique texts: " . count( $hashes ) . "\n" );
|
||||
"Max size: $maxSize\n" .
|
||||
"Number of unique texts: " . count( $hashes ) . "\n" );
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -95,6 +95,7 @@ class RecompressTracked {
|
|||
$jobOptions[$classOption] = $options[$cmdOption];
|
||||
}
|
||||
}
|
||||
|
||||
return new self( $jobOptions );
|
||||
}
|
||||
|
||||
|
|
@ -118,7 +119,6 @@ class RecompressTracked {
|
|||
if ( $this->debugLog ) {
|
||||
$this->logToFile( $msg, $this->debugLog );
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
function info( $msg ) {
|
||||
|
|
@ -190,13 +190,16 @@ class RecompressTracked {
|
|||
$dbr = wfGetDB( DB_SLAVE );
|
||||
if ( !$dbr->tableExists( 'blob_tracking' ) ) {
|
||||
$this->critical( "Error: blob_tracking table does not exist" );
|
||||
|
||||
return false;
|
||||
}
|
||||
$row = $dbr->selectRow( 'blob_tracking', '*', false, __METHOD__ );
|
||||
if ( !$row ) {
|
||||
$this->info( "Warning: blob_tracking table contains no rows, skipping this wiki." );
|
||||
|
||||
return false;
|
||||
}
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
|
|
@ -276,6 +279,7 @@ class RecompressTracked {
|
|||
if ( isset( $pipes[$slaveId] ) ) {
|
||||
$this->prevSlaveId = $slaveId;
|
||||
$this->dispatchToSlave( $slaveId, $args );
|
||||
|
||||
return;
|
||||
}
|
||||
}
|
||||
|
|
@ -443,14 +447,14 @@ class RecompressTracked {
|
|||
$args = explode( ' ', $line );
|
||||
$cmd = array_shift( $args );
|
||||
switch ( $cmd ) {
|
||||
case 'doPage':
|
||||
$this->doPage( intval( $args[0] ) );
|
||||
break;
|
||||
case 'doOrphanList':
|
||||
$this->doOrphanList( array_map( 'intval', $args ) );
|
||||
break;
|
||||
case 'quit':
|
||||
return;
|
||||
case 'doPage':
|
||||
$this->doPage( intval( $args[0] ) );
|
||||
break;
|
||||
case 'doOrphanList':
|
||||
$this->doOrphanList( array_map( 'intval', $args ) );
|
||||
break;
|
||||
case 'quit':
|
||||
return;
|
||||
}
|
||||
$this->waitForSlaves();
|
||||
}
|
||||
|
|
@ -618,6 +622,7 @@ class RecompressTracked {
|
|||
if ( $cluster === false ) {
|
||||
$cluster = reset( $this->destClusters );
|
||||
}
|
||||
|
||||
return $cluster;
|
||||
}
|
||||
|
||||
|
|
@ -628,6 +633,7 @@ class RecompressTracked {
|
|||
*/
|
||||
function getExtDB( $cluster ) {
|
||||
$lb = wfGetLBFactory()->getExternalLB( $cluster );
|
||||
|
||||
return $lb->getConnection( DB_MASTER );
|
||||
}
|
||||
|
||||
|
|
@ -724,6 +730,7 @@ class CgzCopyTransaction {
|
|||
$hash = $this->cgz->addItem( $text );
|
||||
$this->referrers[$textId] = $hash;
|
||||
$this->texts[$textId] = $text;
|
||||
|
||||
return $this->cgz->isHappy();
|
||||
}
|
||||
|
||||
|
|
@ -787,6 +794,7 @@ class CgzCopyTransaction {
|
|||
$this->critical( "Warning: concurrent operation detected, are there two conflicting " .
|
||||
"processes running, doing the same job?" );
|
||||
}
|
||||
|
||||
return;
|
||||
}
|
||||
$this->recompress();
|
||||
|
|
|
|||
|
|
@ -77,6 +77,7 @@ function resolveStub( $id, $stubText, $flags ) {
|
|||
|
||||
if ( strtolower( get_class( $stub ) ) !== 'historyblobstub' ) {
|
||||
print "Error found object of class " . get_class( $stub ) . ", expecting historyblobstub\n";
|
||||
|
||||
return;
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -126,6 +126,7 @@ class TrackBlobs {
|
|||
$this->textClause .= 'old_text' . $dbr->buildLike( "DB://$cluster/", $dbr->anyString() );
|
||||
}
|
||||
}
|
||||
|
||||
return $this->textClause;
|
||||
}
|
||||
|
||||
|
|
@ -133,6 +134,7 @@ class TrackBlobs {
|
|||
if ( !preg_match( '!^DB://(\w+)/(\d+)(?:/([0-9a-fA-F]+)|)$!', $text, $m ) ) {
|
||||
return false;
|
||||
}
|
||||
|
||||
return array(
|
||||
'cluster' => $m[1],
|
||||
'id' => intval( $m[2] ),
|
||||
|
|
@ -305,6 +307,7 @@ class TrackBlobs {
|
|||
function findOrphanBlobs() {
|
||||
if ( !extension_loaded( 'gmp' ) ) {
|
||||
echo "Can't find orphan blobs, need bitfield support provided by GMP.\n";
|
||||
|
||||
return;
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -71,6 +71,7 @@ class SyncFileBackend extends Maintenance {
|
|||
if ( $this->isQuiet() ) {
|
||||
print $id; // give a single machine-readable number
|
||||
}
|
||||
|
||||
return;
|
||||
}
|
||||
|
||||
|
|
@ -104,7 +105,7 @@ class SyncFileBackend extends Maintenance {
|
|||
}
|
||||
|
||||
// Periodically update the position file
|
||||
$callback = function( $pos ) use ( $startFromPosFile, $posFile, $start ) {
|
||||
$callback = function ( $pos ) use ( $startFromPosFile, $posFile, $start ) {
|
||||
if ( $startFromPosFile && $pos >= $start ) { // successfully advanced
|
||||
file_put_contents( $posFile, $pos, LOCK_EX );
|
||||
}
|
||||
|
|
@ -238,6 +239,7 @@ class SyncFileBackend extends Maintenance {
|
|||
if ( !$fsFile ) {
|
||||
$this->error( "Unable to sync '$dPath': could not get local copy." );
|
||||
$status->fatal( 'backend-fail-internal', $src->getName() );
|
||||
|
||||
return $status;
|
||||
}
|
||||
$fsFiles[] = $fsFile; // keep TempFSFile objects alive as needed
|
||||
|
|
@ -254,6 +256,7 @@ class SyncFileBackend extends Maintenance {
|
|||
} else { // error
|
||||
$this->error( "Unable to sync '$dPath': could not stat file." );
|
||||
$status->fatal( 'backend-fail-internal', $src->getName() );
|
||||
|
||||
return $status;
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -120,6 +120,7 @@ TEXT;
|
|||
}
|
||||
if ( $count == 0 ) {
|
||||
$this->output( "Collations up-to-date.\n" );
|
||||
|
||||
return;
|
||||
}
|
||||
$this->output( "Fixing collation for $count rows.\n" );
|
||||
|
|
@ -150,7 +151,8 @@ TEXT;
|
|||
# This is an old-style row, so the sortkey needs to be
|
||||
# converted.
|
||||
if ( $row->cl_sortkey == $title->getText()
|
||||
|| $row->cl_sortkey == $title->getPrefixedText() ) {
|
||||
|| $row->cl_sortkey == $title->getPrefixedText()
|
||||
) {
|
||||
$prefix = '';
|
||||
} else {
|
||||
# Custom sortkey, use it as a prefix
|
||||
|
|
@ -236,6 +238,7 @@ TEXT;
|
|||
$prefix .= " AND $equality";
|
||||
}
|
||||
}
|
||||
|
||||
return $cond;
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -72,6 +72,7 @@ class UpdateDoubleWidthSearch extends Maintenance {
|
|||
$sql = "SELECT si_page FROM $searchindex
|
||||
WHERE ( si_text RLIKE '$regexp' )
|
||||
OR ( si_title RLIKE '$regexp' )";
|
||||
|
||||
return $dbw->query( $sql, __METHOD__ );
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -57,8 +57,8 @@ class UpdateSpecialPages extends Maintenance {
|
|||
}
|
||||
|
||||
if ( !$this->hasOption( 'override' )
|
||||
&& $wgDisableQueryPageUpdate && in_array( $special, $wgDisableQueryPageUpdate ) )
|
||||
{
|
||||
&& $wgDisableQueryPageUpdate && in_array( $special, $wgDisableQueryPageUpdate )
|
||||
) {
|
||||
$this->output( sprintf( "%-30s [QueryPage] disabled\n", $special ) );
|
||||
continue;
|
||||
}
|
||||
|
|
|
|||
|
|
@ -61,6 +61,7 @@ class UserDupes {
|
|||
$info = $this->db->indexInfo( 'user', 'user_name', __METHOD__ );
|
||||
if ( !$info ) {
|
||||
$this->out( "WARNING: doesn't seem to have user_name index at all!\n" );
|
||||
|
||||
return false;
|
||||
}
|
||||
|
||||
|
|
@ -102,6 +103,7 @@ class UserDupes {
|
|||
function checkDupes( $doDelete = false ) {
|
||||
if ( $this->hasUniqueIndex() ) {
|
||||
echo wfWikiID() . " already has a unique index on its user table.\n";
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
|
|
@ -144,14 +146,17 @@ class UserDupes {
|
|||
|
||||
if ( $this->failed > 0 ) {
|
||||
$this->out( "Something terribly awry; $this->failed duplicate accounts were not removed.\n" );
|
||||
|
||||
return false;
|
||||
}
|
||||
|
||||
if ( $this->trimmed == 0 || $doDelete ) {
|
||||
$this->out( "It is now safe to apply the unique index on user_name.\n" );
|
||||
|
||||
return true;
|
||||
} else {
|
||||
$this->out( "Run this script again with the --fix option to automatically delete them.\n" );
|
||||
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
|
@ -196,6 +201,7 @@ class UserDupes {
|
|||
foreach ( $result as $row ) {
|
||||
$list[] = $row->user_name;
|
||||
}
|
||||
|
||||
return $list;
|
||||
}
|
||||
|
||||
|
|
@ -288,5 +294,4 @@ class UserDupes {
|
|||
$this->db->delete( 'user', array( 'user_id' => $userid ), __METHOD__ );
|
||||
$this->out( " ok" );
|
||||
}
|
||||
|
||||
}
|
||||
|
|
|
|||
|
|
@ -107,7 +107,8 @@ class UserOptions {
|
|||
return false;
|
||||
}
|
||||
|
||||
$this->{ $this->mMode } ();
|
||||
$this->{$this->mMode}();
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
|
|
@ -139,7 +140,7 @@ class UserOptions {
|
|||
array( 'user_id' ),
|
||||
array(),
|
||||
__METHOD__
|
||||
);
|
||||
);
|
||||
|
||||
foreach ( $result as $id ) {
|
||||
|
||||
|
|
@ -159,7 +160,6 @@ class UserOptions {
|
|||
@$ret[$this->mAnOption][$userValue]++;
|
||||
// @codingStandardsIgnoreEnd
|
||||
}
|
||||
|
||||
} else {
|
||||
|
||||
foreach ( $defaultOptions as $name => $defaultValue ) {
|
||||
|
|
@ -192,7 +192,7 @@ class UserOptions {
|
|||
array( 'user_id' ),
|
||||
array(),
|
||||
__METHOD__
|
||||
);
|
||||
);
|
||||
|
||||
foreach ( $result as $id ) {
|
||||
|
||||
|
|
@ -218,7 +218,6 @@ class UserOptions {
|
|||
if ( !$this->mQuiet ) {
|
||||
print " OK\n";
|
||||
}
|
||||
|
||||
} elseif ( !$this->mQuiet ) {
|
||||
print "Not changing '$username' using <{$this->mAnOption}> = '$curValue'\n";
|
||||
}
|
||||
|
|
@ -235,6 +234,7 @@ class UserOptions {
|
|||
foreach ( $def as $optname => $defaultValue ) {
|
||||
array_push( $ret, $optname );
|
||||
}
|
||||
|
||||
return $ret;
|
||||
}
|
||||
|
||||
|
|
@ -243,7 +243,7 @@ class UserOptions {
|
|||
#
|
||||
|
||||
public static function showUsageAndExit() {
|
||||
print <<<USAGE
|
||||
print <<<USAGE
|
||||
|
||||
This script pass through all users and change one of their options.
|
||||
The new option is NOT validated.
|
||||
|
|
@ -267,7 +267,7 @@ Options:
|
|||
--dry : do not save user settings back to database
|
||||
|
||||
USAGE;
|
||||
exit( 0 );
|
||||
exit( 0 );
|
||||
}
|
||||
|
||||
/**
|
||||
|
|
@ -280,14 +280,14 @@ USAGE;
|
|||
return true;
|
||||
}
|
||||
|
||||
print <<<WARN
|
||||
print <<<WARN
|
||||
The script is about to change the skin for ALL USERS in the database.
|
||||
Users with option <$this->mAnOption> = '$this->mOldValue' will be made to use '$this->mNewValue'.
|
||||
|
||||
Abort with control-c in the next five seconds....
|
||||
WARN;
|
||||
wfCountDown( 5 );
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
}
|
||||
|
|
|
|||
|
|
@ -34,6 +34,7 @@ class WaitForSlave extends Maintenance {
|
|||
parent::__construct();
|
||||
$this->addArg( 'maxlag', 'How long to wait for the slaves, default 10 seconds', false );
|
||||
}
|
||||
|
||||
public function execute() {
|
||||
wfWaitForSlaves( $this->getArg( 0, 10 ) );
|
||||
}
|
||||
|
|
|
|||
Loading…
Reference in a new issue