$this->addOption( 'parser1', 'The first parser to compare.', true, true );
$this->addOption( 'parser2', 'The second parser to compare.', true, true );
$this->addOption( 'tidy', 'Run tidy on the articles.', false, false );
- $this->addOption( 'save-failed', 'Folder in which articles which differ will be stored.', false, true );
+ $this->addOption(
+ 'save-failed',
+ 'Folder in which articles which differ will be stored.',
+ false,
+ true
+ );
$this->addOption( 'show-diff', 'Show a diff of the two renderings.', false, false );
- $this->addOption( 'diff-bin', 'Binary to use for diffing (can also be provided by DIFF env var).', false, false );
- $this->addOption( 'strip-parameters', 'Remove parameters of html tags to increase readability.', false, false );
- $this->addOption( 'show-parsed-output', 'Show the parsed html if both Parsers give the same output.', false, false );
+ $this->addOption(
+ 'diff-bin',
+ 'Binary to use for diffing (can also be provided by DIFF env var).',
+ false,
+ false
+ );
+ $this->addOption(
+ 'strip-parameters',
+ 'Remove parameters of html tags to increase readability.',
+ false,
+ false
+ );
+ $this->addOption(
+ 'show-parsed-output',
+ 'Show the parsed html if both Parsers give the same output.',
+ false,
+ false
+ );
}
public function checkOptions() {
$content = $rev->getContent();
if ( $content->getModel() !== CONTENT_MODEL_WIKITEXT ) {
- $this->error( "Page {$title->getPrefixedText()} does not contain wikitext but {$content->getModel()}\n" );
+ $this->error( "Page {$title->getPrefixedText()} does not contain wikitext "
+ . "but {$content->getModel()}\n" );
+
return;
}
$this->error( "Parsing for {$title->getPrefixedText()} differs\n" );
if ( $this->saveFailed ) {
- file_put_contents( $this->saveFailed . '/' . rawurlencode( $title->getPrefixedText() ) . ".txt", $text );
+ file_put_contents(
+ $this->saveFailed . '/' . rawurlencode( $title->getPrefixedText() ) . ".txt",
+ $text
+ );
}
if ( $this->showDiff ) {
- $this->output( wfDiff( $this->stripParameters( $output1->getText() ), $this->stripParameters( $output2->getText() ), '' ) );
+ $this->output( wfDiff(
+ $this->stripParameters( $output1->getText() ),
+ $this->stripParameters( $output2->getText() ),
+ ''
+ ) );
}
} else {
$this->output( $title->getPrefixedText() . "\tOK\n" );
+
if ( $this->showParsedOutput ) {
$this->output( $this->stripParameters( $output1->getText() ) );
}
public function __construct() {
parent::__construct();
- $this->mDescription = "Convert from the old links schema (string->ID) to the new schema (ID->ID).
-The wiki should be put into read-only mode while this script executes";
+ $this->mDescription =
+ "Convert from the old links schema (string->ID) to the new schema (ID->ID)."
+ . "The wiki should be put into read-only mode while this script executes";
$this->addArg( 'logperformance', "Log performance to perfLogFilename.", false );
- $this->addArg( 'perfLogFilename', "Filename where performance is logged if --logperformance was set (defaults to 'convLinksPerf.txt').", false );
- $this->addArg( 'keep-links-table', "Don't overwrite the old links table with the new one, leave the new table at links_temp.", false );
- $this->addArg( 'nokeys', "Don't create keys, and so allow duplicates in the new links table.\n
-This gives a huge speed improvement for very large links tables which are MyISAM." /* (What about InnoDB?) */, false );
+ $this->addArg(
+ 'perfLogFilename',
+ "Filename where performance is logged if --logperformance was set "
+ . "(defaults to 'convLinksPerf.txt').",
+ false
+ );
+ $this->addArg(
+ 'keep-links-table',
+ "Don't overwrite the old links table with the new one, leave the new table at links_temp.",
+ false
+ );
+ $this->addArg(
+ 'nokeys',
+ /* (What about InnoDB?) */
+ "Don't create keys, and so allow duplicates in the new links table.\n"
+ . "This gives a huge speed improvement for very large links tables which are MyISAM.",
+ false
+ );
}
public function getDbType() {
global $wgContLang;
- $numBadLinks = $curRowsRead = 0; # counters etc
- $totalTuplesInserted = 0; # total tuples INSERTed into links_temp
+ # counters etc
+ $numBadLinks = $curRowsRead = 0;
- $reportCurReadProgress = true; # whether or not to give progress reports while reading IDs from cur table
- $curReadReportInterval = 1000; # number of rows between progress reports
+ # total tuples INSERTed into links_temp
+ $totalTuplesInserted = 0;
- $reportLinksConvProgress = true; # whether or not to give progress reports during conversion
- $linksConvInsertInterval = 1000; # number of rows per INSERT
+ # whether or not to give progress reports while reading IDs from cur table
+ $reportCurReadProgress = true;
+
+ # number of rows between progress reports
+ $curReadReportInterval = 1000;
+
+ # whether or not to give progress reports during conversion
+ $reportLinksConvProgress = true;
+
+ # number of rows per INSERT
+ $linksConvInsertInterval = 1000;
$initialRowOffset = 0;
- # $finalRowOffset = 0; # not used yet; highest row number from links table to process
+
+ # not used yet; highest row number from links table to process
+ # $finalRowOffset = 0;
$overwriteLinksTable = !$this->hasOption( 'keep-links-table' );
$noKeys = $this->hasOption( 'noKeys' );
# --------------------------------------------------------------------
- list( $cur, $links, $links_temp, $links_backup ) = $dbw->tableNamesN( 'cur', 'links', 'links_temp', 'links_backup' );
+ list( $cur, $links, $links_temp, $links_backup ) =
+ $dbw->tableNamesN( 'cur', 'links', 'links_temp', 'links_backup' );
if ( $dbw->tableExists( 'pagelinks' ) ) {
$this->output( "...have pagelinks; skipping old links table updates\n" );
$curRowsRead++;
if ( $reportCurReadProgress ) {
if ( ( $curRowsRead % $curReadReportInterval ) == 0 ) {
- $this->performanceLog( $fh, $curRowsRead . " " . ( $this->getMicroTime() - $baseTime ) . "\n" );
+ $this->performanceLog(
+ $fh,
+ $curRowsRead . " " . ( $this->getMicroTime() - $baseTime ) . "\n"
+ );
$this->output( "\t$curRowsRead rows of $cur table read.\n" );
}
}
$dbw->freeResult( $res );
$dbw->bufferResults( true );
$this->output( "Finished loading IDs.\n\n" );
- $this->performanceLog( $fh, "Took " . ( $this->getMicroTime() - $baseTime ) . " seconds to load IDs.\n\n" );
+ $this->performanceLog(
+ $fh,
+ "Took " . ( $this->getMicroTime() - $baseTime ) . " seconds to load IDs.\n\n"
+ );
# --------------------------------------------------------------------
$this->performanceLog( $fh, "Processing $numRows rows from $links table...\n" );
$this->performanceLog( $fh, "rows inserted vs seconds elapsed:\n" );
- for ( $rowOffset = $initialRowOffset; $rowOffset < $numRows; $rowOffset += $linksConvInsertInterval ) {
+ for ( $rowOffset = $initialRowOffset; $rowOffset < $numRows;
+ $rowOffset += $linksConvInsertInterval
+ ) {
$sqlRead = "SELECT * FROM $links ";
$sqlRead = $dbw->limitResult( $sqlRead, $linksConvInsertInterval, $rowOffset );
$res = $dbw->query( $sqlRead );
}
}
$dbw->freeResult( $res );
- # $this->output( "rowOffset: $rowOffset\ttuplesAdded: $tuplesAdded\tnumBadLinks: $numBadLinks\n" );
+ # $this->output( "rowOffset: $rowOffset\ttuplesAdded: "
+ # . "$tuplesAdded\tnumBadLinks: $numBadLinks\n" );
if ( $tuplesAdded != 0 ) {
if ( $reportLinksConvProgress ) {
$this->output( "Inserting $tuplesAdded tuples into $links_temp..." );
$totalTuplesInserted += $tuplesAdded;
if ( $reportLinksConvProgress ) {
$this->output( " done. Total $totalTuplesInserted tuples inserted.\n" );
- $this->performanceLog( $fh, $totalTuplesInserted . " " . ( $this->getMicroTime() - $baseTime ) . "\n" );
+ $this->performanceLog(
+ $fh,
+ $totalTuplesInserted . " " . ( $this->getMicroTime() - $baseTime ) . "\n"
+ );
}
}
}
- $this->output( "$totalTuplesInserted valid titles and $numBadLinks invalid titles were processed.\n\n" );
- $this->performanceLog( $fh, "$totalTuplesInserted valid titles and $numBadLinks invalid titles were processed.\n" );
- $this->performanceLog( $fh, "Total execution time: " . ( $this->getMicroTime() - $startTime ) . " seconds.\n" );
+ $this->output( "$totalTuplesInserted valid titles and "
+ . "$numBadLinks invalid titles were processed.\n\n" );
+ $this->performanceLog(
+ $fh,
+ "$totalTuplesInserted valid titles and $numBadLinks invalid titles were processed.\n"
+ );
+ $this->performanceLog(
+ $fh,
+ "Total execution time: " . ( $this->getMicroTime() - $startTime ) . " seconds.\n"
+ );
if ( $this->logPerformance ) {
fclose ( $fh );
}
* @ingroup Maintenance
*/
class CreateAndPromote extends Maintenance {
-
- static $permitRoles = array( 'sysop', 'bureaucrat', 'bot' );
+ private static $permitRoles = array( 'sysop', 'bureaucrat', 'bot' );
public function __construct() {
parent::__construct();
$this->mDescription = "Create a new user account and/or grant it additional rights";
- $this->addOption( "force", "If acccount exists already, just grant it rights or change password." );
+ $this->addOption(
+ 'force',
+ 'If acccount exists already, just grant it rights or change password.'
+ );
foreach ( self::$permitRoles as $role ) {
$this->addOption( $role, "Add the account to the {$role} group" );
}
$inGroups = $user->getGroups();
}
- $promotions = array_diff( array_filter( self::$permitRoles, array( $this, 'hasOption' ) ), $inGroups );
+ $promotions = array_diff(
+ array_filter( self::$permitRoles, array( $this, 'hasOption' ) ),
+ $inGroups
+ );
if ( $exists && !$password && count( $promotions ) === 0 ) {
$this->output( "Account exists and nothing to do.\n" );
class DeleteArchivedRevisions extends Maintenance {
public function __construct() {
parent::__construct();
- $this->mDescription = "Deletes all archived revisions\nThese revisions will no longer be restorable";
+ $this->mDescription =
+ "Deletes all archived revisions\nThese revisions will no longer be restorable";
$this->addOption( 'delete', 'Performs the deletion' );
}
$dbw = wfGetDB( DB_MASTER );
$res = $dbw->selectRow( 'archive', 'COUNT(*) as count', array(), __FUNCTION__ );
$this->output( "Found {$res->count} revisions to delete.\n" );
- $this->output( "Please run the script again with the --delete option to really delete the revisions.\n" );
+ $this->output( "Please run the script again with the --delete option "
+ . "to really delete the revisions.\n" );
}
}
}
$dbw = wfGetDB( DB_MASTER );
# Handle each entry
+ // @codingStandardsIgnoreStart Ignore Generic.CodeAnalysis.ForLoopWithTestFunctionCall.NotAllowed
for ( $linenum = 1; !feof( $file ); $linenum++ ) {
+ // @codingStandardsIgnoreEnd
$line = trim( fgets( $file ) );
if ( $line == '' ) {
continue;
foreach ( $res as $row ) {
if ( $i % $this->report == 0 ) {
- $this->output( sprintf( "%s: %13s done (%s)\n", wfWikiID(), "$i/$total", wfPercent( $i / $total * 100 ) ) );
+ $this->output( sprintf(
+ "%s: %13s done (%s)\n",
+ wfWikiID(),
+ "$i/$total",
+ wfPercent( $i / $total * 100 )
+ ) );
}
$md5 = md5( $row->img_name );
$wgMemc->delete( wfMemcKey( 'Image', $md5 ) );
# Find all the orphaned revisions
$this->output( "Checking for orphaned revisions..." );
- $sql = "SELECT rev_id FROM {$revision} LEFT JOIN {$page} ON rev_page = page_id WHERE page_namespace IS NULL";
+ $sql = "SELECT rev_id FROM {$revision} LEFT JOIN {$page} ON rev_page = page_id "
+ . "WHERE page_namespace IS NULL";
$res = $dbw->query( $sql, 'deleteOrphanedRevisions' );
# Stash 'em all up for deletion (if needed)
$this->output( "Revision $revID not found\n" );
} else {
$affected += $dbw->affectedRows();
- $pageID = $dbw->selectField( 'revision', 'rev_page', array( 'rev_id' => $revID ), __METHOD__ );
- $pageLatest = $dbw->selectField( 'page', 'page_latest', array( 'page_id' => $pageID ), __METHOD__ );
+ $pageID = $dbw->selectField(
+ 'revision',
+ 'rev_page',
+ array( 'rev_id' => $revID ),
+ __METHOD__
+ );
+ $pageLatest = $dbw->selectField(
+ 'page',
+ 'page_latest',
+ array( 'page_id' => $pageID ),
+ __METHOD__
+ );
$dbw->delete( 'revision', array( 'rev_id' => $revID ) );
if ( $pageLatest == $revID ) {
// Database integrity
- $newLatest = $dbw->selectField( 'revision', 'rev_id', array( 'rev_page' => $pageID ), __METHOD__, array( 'ORDER BY' => 'rev_timestamp DESC' ) );
- $dbw->update( 'page', array( 'page_latest' => $newLatest ), array( 'page_id' => $pageID ), __METHOD__ );
+ $newLatest = $dbw->selectField(
+ 'revision',
+ 'rev_id',
+ array( 'rev_page' => $pageID ),
+ __METHOD__,
+ array( 'ORDER BY' => 'rev_timestamp DESC' )
+ );
+ $dbw->update(
+ 'page',
+ array( 'page_latest' => $newLatest ),
+ array( 'page_id' => $pageID ),
+ __METHOD__
+ );
}
}
}
// @todo FIXME: Replace this hack with general farm-friendly code
# @todo FIXME: Wikimedia-specific stuff needs to go away to an ext
# Maybe a hook?
+ // @codingStandardsIgnoreStart MediaWiki.NamingConventions.ValidGlobalName.wgPrefix
global $cluster;
$cluster = 'pmtpa';
+ // @codingStandardsIgnoreEnd
require "$IP/../wmf-config/wgConf.php";
}
// Require the configuration (probably LocalSettings.php)
}
if ( $maintenance->getDbType() === Maintenance::DB_NONE ) {
- if ( $wgLocalisationCacheConf['storeClass'] === false && ( $wgLocalisationCacheConf['store'] == 'db' || ( $wgLocalisationCacheConf['store'] == 'detect' && !$wgCacheDirectory ) ) ) {
+ if ( $wgLocalisationCacheConf['storeClass'] === false
+ && ( $wgLocalisationCacheConf['store'] == 'db'
+ || ( $wgLocalisationCacheConf['store'] == 'detect' && !$wgCacheDirectory ) )
+ ) {
$wgLocalisationCacheConf['storeClass'] = 'LCStoreNull';
}
}
$revision = new WikiRevision;
$revision->setText( file_get_contents( $this->getOption( 'file' ) ) );
- $revision->setTitle( Title::newFromText( rawurldecode( basename( $this->getOption( 'file' ), '.txt' ) ) ) );
+ $revision->setTitle( Title::newFromText(
+ rawurldecode( basename( $this->getOption( 'file' ), '.txt' ) )
+ ) );
$this->handleRevision( $revision );
+
return;
}
if ( $this->getOption( 'dump' ) == '-' ) {
$source = new ImportStreamSource( $this->getStdin() );
} else {
- $this->error( "Sorry, I don't support dump filenames yet. Use - and provide it on stdin on the meantime.", true );
+ $this->error( "Sorry, I don't support dump filenames yet. "
+ . "Use - and provide it on stdin on the meantime.", true );
}
$importer = new WikiImporter( $source );
$this->error( round( $this->count / $delta, 2 ) . " pages/sec" );
}
- # Perform the memory_get_peak_usage() when all the other data has been output so there's no damage if it dies.
- # It is only available since 5.2.0 (since 5.2.1 if you haven't compiled with --enable-memory-limit)
+ # Perform the memory_get_peak_usage() when all the other data has been
+ # output so there's no damage if it dies. It is only available since
+ # 5.2.0 (since 5.2.1 if you haven't compiled with --enable-memory-limit)
$this->error( "Memory peak usage of " . memory_get_peak_usage() . " bytes\n" );
}