Fix various MediaWiki.WhiteSpace.SpaceBeforeSingleLineComment.NewLineComment

Change-Id: I50c7c93f1534e966224f98a835ca01f93eb9416d
This commit is contained in:
Reedy 2020-05-19 23:10:27 +01:00 committed by Krinkle
parent 3f2937810e
commit c7eb28aac9
37 changed files with 81 additions and 48 deletions

View file

@ -37,10 +37,9 @@ wfEntryPointCheck( 'text' );
// Define this so scripts can easily find doMaintenance.php
define( 'RUN_MAINTENANCE_IF_MAIN', __DIR__ . '/doMaintenance.php' );
/**
* @deprecated since 1.31
*/
define( 'DO_MAINTENANCE', RUN_MAINTENANCE_IF_MAIN ); // original name, harmless
// Original name for compat, harmless
// Support: MediaWiki < 1.31
define( 'DO_MAINTENANCE', RUN_MAINTENANCE_IF_MAIN );
/**
* @var string|false

View file

@ -40,7 +40,8 @@ class BenchUtf8TitleCheck extends Benchmarker {
// phpcs:disable Generic.Files.LineLength
$this->data = [
"",
"United States of America", // 7bit ASCII
// 7bit ASCII
"United States of America",
"S%C3%A9rie%20t%C3%A9l%C3%A9vis%C3%A9e",
"Acteur%7CAlbert%20Robbins%7CAnglais%7CAnn%20Donahue%7CAnthony%20E.%20Zuiker%7CCarol%20Mendelsohn",
// This comes from T38839

View file

@ -139,7 +139,7 @@ TEXT
$dbr = $this->getDB( DB_REPLICA, 'vslow' );
// Find all TitleValue-invalid titles.
$percent = $dbr->anyString(); // DBMS-agnostic equivalent of '%' LIKE wildcard
$percent = $dbr->anyString();
$res = $dbr->select(
$table,
[

View file

@ -54,7 +54,8 @@ class TitleCleanup extends TableCleanup {
&& $title->getNamespace() == $row->page_namespace
&& $title->getDBkey() === $row->page_title
) {
$this->progress( 0 ); // all is fine
// all is fine
$this->progress( 0 );
return;
}

View file

@ -106,7 +106,7 @@ class CleanupUploadStash extends Maintenance {
}
$this->output( "Deleting old thumbnails...\n" );
$i = 0;
$batch = []; // operation batch
$batch = [];
foreach ( $iterator as $file ) {
if ( wfTimestamp( TS_UNIX, $tempRepo->getFileTimestamp( "$dir/$file" ) ) < $cutoff ) {
$batch[] = [ 'op' => 'delete', 'src' => "$dir/$file" ];
@ -131,11 +131,13 @@ class CleanupUploadStash extends Maintenance {
$this->fatalError( "Could not get file listing." );
}
$this->output( "Deleting orphaned temp files...\n" );
if ( strpos( $dir, '/local-temp' ) === false ) { // sanity check
if ( strpos( $dir, '/local-temp' ) === false ) {
// sanity check
$this->fatalError( "Temp repo is not using the temp container." );
}
$i = 0;
$batch = []; // operation batch
$batch = [];
foreach ( $iterator as $file ) {
if ( wfTimestamp( TS_UNIX, $tempRepo->getFileTimestamp( "$dir/$file" ) ) < $cutoff ) {
$batch[] = [ 'op' => 'delete', 'src' => "$dir/$file" ];

View file

@ -107,7 +107,9 @@ class DeleteArchivedFiles extends Maintenance {
} elseif ( !$repo->quickPurge( $path ) ) {
$this->output( "Unable to remove file $path, skipping\n" );
$file->unlock();
continue; // don't delete even with --force
// don't delete even with --force
continue;
} else {
$needForce = false;
}

View file

@ -50,12 +50,14 @@ class EraseArchivedFile extends Maintenance {
$filekey = $this->getOption( 'filekey' );
$filename = $this->getOption( 'filename' );
if ( $filekey === '*' ) { // all versions by name
if ( $filekey === '*' ) {
// all versions by name
if ( !strlen( $filename ) ) {
$this->fatalError( "Missing --filename parameter." );
}
$afile = false;
} else { // specified version
} else {
// specified version
$dbw = $this->getDB( DB_MASTER );
$fileQuery = ArchivedFile::getQueryInfo();
$row = $dbw->selectRow( $fileQuery['tables'], $fileQuery['fields'],

View file

@ -84,7 +84,7 @@ class FileOpPerfTest extends Maintenance {
$ops5[] = [ 'op' => 'delete', 'src' => "$dst-2" ];
}
if ( count( $ops1 ) >= $this->getOption( 'maxfiles', 20 ) ) {
break; // enough
break;
}
}
closedir( $dir );

View file

@ -440,7 +440,8 @@ class FindBadBlobs extends Maintenance {
try {
$this->blobStore->getBlob( $address );
return 0; // nothing to do
// nothing to do
return 0;
} catch ( BlobAccessException $ex ) {
$error = $ex->getMessage();
} catch ( ExternalStoreException $ex ) {

View file

@ -98,7 +98,8 @@ class FindMissingFiles extends Maintenance {
$checkPaths = [];
foreach ( $ores as $row ) {
if ( !strlen( $row->oi_archive_name ) ) {
continue; // broken row
// broken row
continue;
}
$file = $repo->newFromArchiveName( $row->oi_name, $row->oi_archive_name );
$checkPaths[] = $file->getPath();

View file

@ -72,7 +72,8 @@ class FixDoubleRedirects extends Maintenance {
'rd_from = pa.page_id',
'rd_namespace = pb.page_namespace',
'rd_title = pb.page_title',
'rd_interwiki IS NULL OR rd_interwiki = ' . $dbr->addQuotes( '' ), // T42352
// T42352
'rd_interwiki IS NULL OR rd_interwiki = ' . $dbr->addQuotes( '' ),
'pb.page_is_redirect' => 1,
];

View file

@ -46,7 +46,8 @@ class FixTimestamps extends Maintenance {
$offset = $this->getArg( 0 ) * 3600;
$start = $this->getArg( 1 );
$end = $this->getArg( 2 );
$grace = 60; // maximum normal clock offset
// maximum normal clock offset
$grace = 60;
# Find bounding revision IDs
$dbw = $this->getDB( DB_MASTER );

View file

@ -91,7 +91,8 @@ class GetConfiguration extends Maintenance {
if ( $this->regex ) {
$this->regex = '/' . $this->regex . '/';
if ( $this->hasOption( 'iregex' ) ) {
$this->regex .= 'i'; # case insensitive regex
# case insensitive regex
$this->regex .= 'i';
}
}
@ -165,7 +166,8 @@ class GetConfiguration extends Maintenance {
protected function formatVarDump( $res ) {
$ret = '';
foreach ( $res as $key => $value ) {
ob_start(); # intercept var_dump() output
# intercept var_dump() output
ob_start();
print "\${$key} = ";
var_dump( $value );
# grab var_dump() output and discard it from the output buffer

View file

@ -112,11 +112,13 @@ TEXT
$this->reportingInterval = intval( $this->getOption( 'report', 100 ) );
if ( !$this->reportingInterval ) {
$this->reportingInterval = 100; // avoid division by zero
// avoid division by zero
$this->reportingInterval = 100;
}
$this->dryRun = $this->hasOption( 'dry-run' );
$this->uploads = $this->hasOption( 'uploads' ); // experimental!
$this->uploads = $this->hasOption( 'uploads' );
if ( $this->hasOption( 'image-base-path' ) ) {
$this->imageBasePath = $this->getOption( 'image-base-path' );
}

View file

@ -177,7 +177,8 @@ class ImportTextFiles extends Maintenance {
$oldContent ? $oldContent->getSize() : 0,
$rev->getContent()->getSize(),
$newId,
1 /* the pages don't need to be patrolled */
// the pages don't need to be patrolled
1
);
}
} else {

View file

@ -415,7 +415,6 @@ class MigrateActors extends LoggedUpdateMaintenance {
// Update rows
if ( $rows ) {
$inserts = [];
$updates = [];
foreach ( $rows as $row ) {
if ( !$row->actor_id ) {
list( , $display ) = $this->makeNextCond( $dbw, [ $primaryKey ], $row );
@ -431,10 +430,10 @@ class MigrateActors extends LoggedUpdateMaintenance {
$actorField => $row->actor_id,
];
foreach ( $extra as $to => $from ) {
$ins[$to] = $row->$to; // It's aliased
// It's aliased
$ins[$to] = $row->$to;
}
$inserts[] = $ins;
$updates[] = $row->$primaryKey;
}
$this->beginTransaction( $dbw, __METHOD__ );
$dbw->insert( $newTable, $inserts, __METHOD__ );

View file

@ -56,7 +56,8 @@ class SevenZipStream {
// Suppress the stupid messages on stderr
$command .= ' 2>/dev/null';
}
$this->stream = popen( $command, $mode[0] ); // popen() doesn't like two-letter modes
// popen() doesn't like two-letter modes
$this->stream = popen( $command, $mode[0] );
return ( $this->stream !== false );
}

View file

@ -81,5 +81,5 @@ class InitUserPreference extends Maintenance {
}
}
$maintClass = InitUserPreference::class; // Tells it to run the class
$maintClass = InitUserPreference::class;
require_once RUN_MAINTENANCE_IF_MAIN;

View file

@ -41,8 +41,10 @@ class JSParseHelper extends Maintenance {
if ( $this->hasArg( 0 ) ) {
$files = $this->mArgs;
} else {
$this->maybeHelp( true ); // @todo fixme this is a lame API :)
exit( 1 ); // it should exit from the above first...
// @todo fixme this is a lame API :)
$this->maybeHelp( true );
// it should exit from the above first...
exit( 1 );
}
$parser = new JSParser();

View file

@ -71,7 +71,8 @@ class WikiStatsOutput extends StatsOutput {
'system message translations, usually because they redirect to other ' .
'language codes: ' . implode( ', ', $dummyCodes );
}
echo ".\n\n"; # dot to end sentence
# dot to end sentence
echo ".\n\n";
echo '{| class="sortable wikitable" border="2" style="background-color: #F9F9F9; ' .
'border: 1px #AAAAAA solid; border-collapse: collapse; clear:both; width:100%;"' . "\n";
}

View file

@ -213,7 +213,7 @@ do {
default:
$bad = true;
} // switch() end
}
if ( $bad ) {
if ( $command ) {

View file

@ -57,7 +57,8 @@ class MigrateFileRepoLayout extends Maintenance {
$be = $repo->getBackend();
if ( $be instanceof FileBackendDBRepoWrapper ) {
$be = $be->getInternalBackend(); // avoid path translations for this script
// avoid path translations for this script
$be = $be->getInternalBackend();
}
$dbw = $repo->getMasterDB();

View file

@ -89,7 +89,8 @@ class NukePage extends Maintenance {
# Update stats as appropriate
if ( $delete ) {
$this->output( "Updating site stats..." );
$ga = $isGoodArticle ? -1 : 0; // if it was good, decrement that too
// if it was good, decrement that too
$ga = $isGoodArticle ? -1 : 0;
$stats = SiteStatsUpdate::factory( [
'edits' => -$count,
'articles' => $ga,

View file

@ -139,7 +139,8 @@ class PopulateArchiveRevId extends LoggedUpdateMaintenance {
} );
$ok = true;
} catch ( DBQueryError $e ) {
if ( $e->errno != 1062 ) { // 1062 is "duplicate entry", ignore it and retry
if ( $e->errno != 1062 ) {
// 1062 is "duplicate entry", ignore it and retry
throw $e;
}
}

View file

@ -103,7 +103,8 @@ class PopulateFilearchiveSha1 extends LoggedUpdateMaintenance {
$processingTime = microtime( true ) - $startTime;
$this->output( sprintf( "\nDone %d files in %.1f seconds\n", $done, $processingTime ) );
return true; // we only updated *some* files, don't log
// we only updated *some* files, don't log
return true;
}
}

View file

@ -116,7 +116,8 @@ class PopulateRevisionLength extends LoggedUpdateMaintenance {
"{$prefix}_len IS NULL",
$dbr->makeList( [
"{$prefix}_len = 0",
"{$prefix}_sha1 != " . $dbr->addQuotes( 'phoiac9h4m842xq45sp7s6u21eteeq1' ), // sha1( "" )
// sha1( "" )
"{$prefix}_sha1 != " . $dbr->addQuotes( 'phoiac9h4m842xq45sp7s6u21eteeq1' ),
], IDatabase::LIST_AND )
], IDatabase::LIST_OR )
],

View file

@ -84,7 +84,8 @@ class PruneFileCache extends Maintenance {
while ( ( $file = readdir( $dirHandle ) ) !== false ) {
// Skip ".", "..", and also any dirs or files like ".svn" or ".htaccess"
if ( $file[0] != "." ) {
$path = $dir . '/' . $file; // absolute
// absolute
$path = $dir . '/' . $file;
if ( is_dir( $path ) ) {
if ( $report === 'report' ) {
$this->output( "Scanning `$path`...\n" );

View file

@ -77,7 +77,7 @@ class PurgeChangedPages extends Maintenance {
$this->maybeHelp( true );
}
$stuckCount = 0; // loop breaker
$stuckCount = 0;
while ( true ) {
// Adjust bach size if we are stuck in a second that had many changes
$bSize = ( $stuckCount + 1 ) * $this->getBatchSize();

View file

@ -79,7 +79,8 @@ class PurgeParserCache extends Maintenance {
}
public function showProgressAndWait( $percent ) {
usleep( $this->usleep ); // avoid lag; T150124
// avoid lag; T150124
usleep( $this->usleep );
$percentString = sprintf( "%.2f", $percent );
if ( $percentString === $this->lastProgress ) {

View file

@ -212,7 +212,8 @@ class ImageBuilder extends Maintenance {
[ 'img_name' => $filename ],
__METHOD__ );
if ( !$row ) { // file not registered
if ( !$row ) {
// file not registered
$this->addMissingImage( $filename, $fullpath );
}
}

View file

@ -86,7 +86,8 @@ class RebuildLocalisationCache extends Maintenance {
}
$conf = $wgLocalisationCacheConf;
$conf['manualRecache'] = false; // Allow fallbacks to create CDB files
// Allow fallbacks to create CDB files
$conf['manualRecache'] = false;
$conf['forceRecache'] = $force || !empty( $conf['forceRecache'] );
if ( $this->hasOption( 'outdir' ) ) {
$conf['storeDirectory'] = $this->getOption( 'outdir' );

View file

@ -340,7 +340,8 @@ class RefreshLinks extends Maintenance {
$dbw = $this->getDB( DB_MASTER );
$dbr = $this->getDB( DB_REPLICA, [ 'vslow' ] );
$linksTables = [ // table name => page_id field
$linksTables = [
// table name => page_id field
'pagelinks' => 'pl_from',
'imagelinks' => 'il_from',
'categorylinks' => 'cl_from',

View file

@ -59,7 +59,8 @@ class Sqlite {
'integer',
'real',
'text',
'blob', // NULL type is omitted intentionally
'blob',
// NULL type is omitted intentionally
] );
$db = DatabaseSqlite::newStandaloneInstance( ':memory:' );

View file

@ -347,7 +347,7 @@ class CheckStorage {
"Error: Incorrect object header for concat bulk row {$row->old_id}",
$concatBlobs[$row->old_id]
);
} # else good
}
unset( $concatBlobs[$row->old_id] );
}

View file

@ -25,7 +25,8 @@ class TidyUpT39714 extends Maintenance {
$lbFactory = MediaWikiServices::getInstance()->getDBLoadBalancerFactory();
foreach ( $result as $row ) {
$ids = explode( ',', explode( "\n", $row->log_params )[0] );
$result = $this->getDB( DB_REPLICA )->select( // Work out what log entries were changed here.
// Work out what log entries were changed here.
$result = $this->getDB( DB_REPLICA )->select(
'logging',
'log_type',
[ 'log_id' => $ids ],

View file

@ -109,7 +109,9 @@ class UpdateMediaWiki extends Maintenance {
$lang = MediaWikiServices::getInstance()->getLanguageFactory()->getLanguage( 'en' );
// Set global language to ensure localised errors are in English (T22633)
RequestContext::getMain()->setLanguage( $lang );
$wgLang = $lang; // BackCompat
// BackCompat
$wgLang = $lang;
define( 'MW_UPDATER', true );

View file

@ -60,7 +60,7 @@ The new option is NOT validated.' );
) {
$this->updateOptions();
} else {
$this->maybeHelp( /* force = */ true );
$this->maybeHelp( true );
}
}