From ebbf031774f786abaac5351fce2ae898f1524a07 Mon Sep 17 00:00:00 2001 From: Siebrand Mazeland Date: Wed, 23 Apr 2014 11:40:50 +0200 Subject: [PATCH] Pass phpcs-strict on maintenance/ (7/8) Change-Id: Ibb03a775055c687a4c5bc6864172e043d3a7e3d8 --- maintenance/cdb.php | 3 ++- maintenance/checkImages.php | 3 ++- maintenance/checkLess.php | 3 ++- maintenance/checkSyntax.php | 24 +++++++++++++++++++----- maintenance/cleanupAncientTables.php | 5 +++-- maintenance/cleanupImages.php | 7 ++++++- maintenance/cleanupRemovedModules.php | 8 +++++++- maintenance/cleanupSpam.php | 22 +++++++++++++++++----- maintenance/cleanupWatchlist.php | 3 ++- maintenance/commandLine.inc | 6 ++++++ 10 files changed, 66 insertions(+), 18 deletions(-) diff --git a/maintenance/cdb.php b/maintenance/cdb.php index 4590611896..86c686b412 100644 --- a/maintenance/cdb.php +++ b/maintenance/cdb.php @@ -77,7 +77,8 @@ do { print "Loading cdb file $file..."; try { $fileHandle = CdbReader::open( $file ); - } catch ( CdbException $e ) {} + } catch ( CdbException $e ) { + } if ( !$fileHandle ) { print "not a cdb file or unable to read it\n"; diff --git a/maintenance/checkImages.php b/maintenance/checkImages.php index e6aea53764..e91464521c 100644 --- a/maintenance/checkImages.php +++ b/maintenance/checkImages.php @@ -73,7 +73,8 @@ class CheckImages extends Maintenance { } if ( $stat['size'] != $row->img_size ) { - $this->output( "{$row->img_name}: size mismatch DB={$row->img_size}, actual={$stat['size']}\n" ); + $this->output( "{$row->img_name}: size mismatch DB={$row->img_size}, " + . "actual={$stat['size']}\n" ); continue; } diff --git a/maintenance/checkLess.php b/maintenance/checkLess.php index f81285f061..b97e1b0b23 100644 --- a/maintenance/checkLess.php +++ b/maintenance/checkLess.php @@ -31,7 +31,8 @@ class CheckLess extends Maintenance { public function __construct() { parent::__construct(); - $this->mDescription = 'Checks LESS files for errors by running the LessTestSuite PHPUnit test suite'; + $this->mDescription = + 'Checks LESS files for errors by running the LessTestSuite PHPUnit test suite'; } public function execute() { diff --git a/maintenance/checkSyntax.php b/maintenance/checkSyntax.php index ef8854558e..e01767e9e1 100644 --- a/maintenance/checkSyntax.php +++ b/maintenance/checkSyntax.php @@ -38,10 +38,23 @@ class CheckSyntax extends Maintenance { parent::__construct(); $this->mDescription = "Check syntax for all PHP files in MediaWiki"; $this->addOption( 'with-extensions', 'Also recurse the extensions folder' ); - $this->addOption( 'path', 'Specific path (file or directory) to check, either with absolute path or relative to the root of this MediaWiki installation', - false, true ); - $this->addOption( 'list-file', 'Text file containing list of files or directories to check', false, true ); - $this->addOption( 'modified', 'Check only files that were modified (requires Git command-line client)' ); + $this->addOption( + 'path', + 'Specific path (file or directory) to check, either with absolute path or ' + . 'relative to the root of this MediaWiki installation', + false, + true + ); + $this->addOption( + 'list-file', + 'Text file containing list of files or directories to check', + false, + true + ); + $this->addOption( + 'modified', + 'Check only files that were modified (requires Git command-line client)' + ); $this->addOption( 'syntax-only', 'Check for syntax validity only, skip code style warnings' ); } @@ -53,7 +66,8 @@ class CheckSyntax extends Maintenance { $this->buildFileList(); // ParseKit is broken on PHP 5.3+, disabled until this is fixed - $useParseKit = function_exists( 'parsekit_compile_file' ) && version_compare( PHP_VERSION, '5.3', '<' ); + $useParseKit = function_exists( 'parsekit_compile_file' ) + && version_compare( PHP_VERSION, '5.3', '<' ); $str = 'Checking syntax (using ' . ( $useParseKit ? 'parsekit' : ' php -l, this can take a long time' ) . ")\n"; diff --git a/maintenance/cleanupAncientTables.php b/maintenance/cleanupAncientTables.php index 694efaa64d..428484b376 100644 --- a/maintenance/cleanupAncientTables.php +++ b/maintenance/cleanupAncientTables.php @@ -40,8 +40,9 @@ class CleanupAncientTables extends Maintenance { public function execute() { if ( !$this->hasOption( 'force' ) ) { $this->error( "This maintenance script will remove old columns and indexes.\n" - . "It is recommended to backup your database first, and ensure all your data has been migrated to newer tables\n" - . "If you want to continue, run this script again with the --force \n" + . "It is recommended to backup your database first, and ensure all your data has\n" + . "been migrated to newer tables. If you want to continue, run this script again\n" + . "with --force.\n" ); } diff --git a/maintenance/cleanupImages.php b/maintenance/cleanupImages.php index 01ed9caf9c..1b46ab87a4 100644 --- a/maintenance/cleanupImages.php +++ b/maintenance/cleanupImages.php @@ -122,7 +122,12 @@ class ImageCleanup extends TableCleanup { } private function pageExists( $name, $db ) { - return $db->selectField( 'page', '1', array( 'page_namespace' => NS_FILE, 'page_title' => $name ), __METHOD__ ); + return $db->selectField( + 'page', + '1', + array( 'page_namespace' => NS_FILE, 'page_title' => $name ), + __METHOD__ + ); } private function pokeFile( $orig, $new ) { diff --git a/maintenance/cleanupRemovedModules.php b/maintenance/cleanupRemovedModules.php index 84eec28969..cc8b02488f 100644 --- a/maintenance/cleanupRemovedModules.php +++ b/maintenance/cleanupRemovedModules.php @@ -36,7 +36,13 @@ class CleanupRemovedModules extends Maintenance { parent::__construct(); $this->mDescription = 'Remove cache entries for removed ResourceLoader modules from the database'; $this->addOption( 'batchsize', 'Delete rows in batches of this size. Default: 500', false, true ); - $this->addOption( 'max-slave-lag', 'If the slave lag exceeds this many seconds, wait until it drops below this value. Default: 5', false, true ); + $this->addOption( + 'max-slave-lag', + 'If the slave lag exceeds this many seconds, wait until it drops below this value. ' + . 'Default: 5', + false, + true + ); } public function execute() { diff --git a/maintenance/cleanupSpam.php b/maintenance/cleanupSpam.php index 12b12416fd..8551f8f625 100644 --- a/maintenance/cleanupSpam.php +++ b/maintenance/cleanupSpam.php @@ -35,7 +35,10 @@ class CleanupSpam extends Maintenance { $this->mDescription = "Cleanup all spam from a given hostname"; $this->addOption( 'all', 'Check all wikis in $wgLocalDatabases' ); $this->addOption( 'delete', 'Delete pages containing only spam instead of blanking them' ); - $this->addArg( 'hostname', 'Hostname that was spamming, single * wildcard in the beginning allowed' ); + $this->addArg( + 'hostname', + 'Hostname that was spamming, single * wildcard in the beginning allowed' + ); } public function execute() { @@ -123,19 +126,28 @@ class CleanupSpam extends Maintenance { $content = $rev->getContent( Revision::RAW ); $this->output( "reverting\n" ); - $page->doEditContent( $content, wfMessage( 'spam_reverting', $domain )->inContentLanguage()->text(), - EDIT_UPDATE, $rev->getId() ); + $page->doEditContent( + $content, + wfMessage( 'spam_reverting', $domain )->inContentLanguage()->text(), + EDIT_UPDATE, + $rev->getId() + ); } elseif ( $this->hasOption( 'delete' ) ) { // Didn't find a non-spammy revision, blank the page $this->output( "deleting\n" ); - $page->doDeleteArticle( wfMessage( 'spam_deleting', $domain )->inContentLanguage()->text() ); + $page->doDeleteArticle( + wfMessage( 'spam_deleting', $domain )->inContentLanguage()->text() + ); } else { // Didn't find a non-spammy revision, blank the page $handler = ContentHandler::getForTitle( $title ); $content = $handler->makeEmptyContent(); $this->output( "blanking\n" ); - $page->doEditContent( $content, wfMessage( 'spam_blanking', $domain )->inContentLanguage()->text() ); + $page->doEditContent( + $content, + wfMessage( 'spam_blanking', $domain )->inContentLanguage()->text() + ); } $dbw->commit( __METHOD__ ); } diff --git a/maintenance/cleanupWatchlist.php b/maintenance/cleanupWatchlist.php index 94e90db67a..22fd05fc4d 100644 --- a/maintenance/cleanupWatchlist.php +++ b/maintenance/cleanupWatchlist.php @@ -65,7 +65,8 @@ class WatchlistCleanup extends TableCleanup { $title = Title::newFromText( $verified ); if ( $row->wl_user == 0 || is_null( $title ) || !$title->equals( $current ) ) { - $this->output( "invalid watch by {$row->wl_user} for ({$row->wl_namespace}, \"{$row->wl_title}\")\n" ); + $this->output( "invalid watch by {$row->wl_user} for " + . "({$row->wl_namespace}, \"{$row->wl_title}\")\n" ); $updated = $this->removeWatch( $row ); $this->progress( $updated ); return; diff --git a/maintenance/commandLine.inc b/maintenance/commandLine.inc index be07142208..0d3e643234 100644 --- a/maintenance/commandLine.inc +++ b/maintenance/commandLine.inc @@ -23,14 +23,18 @@ require_once __DIR__ . '/Maintenance.php'; +// @codingStandardsIgnoreStart MediaWiki.NamingConventions.ValidGlobalName.wgPrefix global $optionsWithArgs; +// @codingStandardsIgnoreEnd if ( !isset( $optionsWithArgs ) ) { $optionsWithArgs = array(); } class CommandLineInc extends Maintenance { public function __construct() { + // @codingStandardsIgnoreStart MediaWiki.NamingConventions.ValidGlobalName.wgPrefix global $optionsWithArgs; + // @codingStandardsIgnoreEnd parent::__construct(); foreach ( $optionsWithArgs as $name ) { $this->addOption( $name, '', false, true ); @@ -48,7 +52,9 @@ class CommandLineInc extends Maintenance { } public function execute() { + // @codingStandardsIgnoreStart MediaWiki.NamingConventions.ValidGlobalName.wgPrefix global $args, $options; + // @codingStandardsIgnoreEnd $args = $this->mArgs; $options = $this->mOptions; } -- 2.20.1