From a50a5d9da7a0a8c4030e8ad65cbb2a112024f8e9 Mon Sep 17 00:00:00 2001 From: Siebrand Mazeland Date: Tue, 22 Apr 2014 22:55:25 +0200 Subject: [PATCH] Pass phpcs-strict on maintenance/ (1/8) Change-Id: Ib68a7cf4251e8f4c71233df869673f4c5d3cf84c --- maintenance/showSiteStats.php | 6 +++++- maintenance/sql.php | 3 ++- maintenance/sqlite.php | 5 ++++- maintenance/update.php | 19 +++++++++++++++---- maintenance/updateArticleCount.php | 10 ++++++++-- maintenance/updateDoubleWidthSearch.php | 7 ++++++- maintenance/updateRestrictions.php | 15 +++++++++++++-- maintenance/updateSearchIndex.php | 14 ++++++++++++-- maintenance/userDupes.inc | 9 ++++++--- maintenance/userOptions.inc | 7 ++++++- 10 files changed, 77 insertions(+), 18 deletions(-) diff --git a/maintenance/showSiteStats.php b/maintenance/showSiteStats.php index 49148b3390..6bf4daae94 100644 --- a/maintenance/showSiteStats.php +++ b/maintenance/showSiteStats.php @@ -65,7 +65,11 @@ class ShowSiteStats extends Maintenance { // Show them foreach ( $fields as $field => $desc ) { - $this->output( sprintf( "%-{$max_length_desc}s: %{$max_length_value}d\n", $desc, $stats->$field ) ); + $this->output( sprintf( + "%-{$max_length_desc}s: %{$max_length_value}d\n", + $desc, + $stats->$field + ) ); } } } diff --git a/maintenance/sql.php b/maintenance/sql.php index d43c8dc040..b20b0cf9f0 100644 --- a/maintenance/sql.php +++ b/maintenance/sql.php @@ -53,7 +53,8 @@ class MwSql extends Maintenance { $index = DB_SLAVE; } else { $index = null; - for ( $i = 0; $i < $lb->getServerCount(); ++$i ) { + $serverCount = $lb->getServerCount(); + for ( $i = 0; $i < $serverCount; ++$i ) { if ( $lb->getServerName( $i ) === $server ) { $index = $i; break; diff --git a/maintenance/sqlite.php b/maintenance/sqlite.php index 8a785245ac..dbd8ed1f81 100644 --- a/maintenance/sqlite.php +++ b/maintenance/sqlite.php @@ -32,7 +32,10 @@ class SqliteMaintenance extends Maintenance { public function __construct() { parent::__construct(); $this->mDescription = "Performs some operations specific to SQLite database backend"; - $this->addOption( 'vacuum', 'Clean up database by removing deleted pages. Decreases database file size' ); + $this->addOption( + 'vacuum', + 'Clean up database by removing deleted pages. Decreases database file size' + ); $this->addOption( 'integrity', 'Check database for integrity' ); $this->addOption( 'backup-to', 'Backup database to the given file', false, true ); $this->addOption( 'check-syntax', 'Check SQL file(s) for syntax errors', false, true ); diff --git a/maintenance/update.php b/maintenance/update.php index 8c1ad17450..f96ee39a3b 100644 --- a/maintenance/update.php +++ b/maintenance/update.php @@ -47,13 +47,19 @@ class UpdateMediaWiki extends Maintenance { $this->addOption( 'doshared', 'Also update shared tables' ); $this->addOption( 'nopurge', 'Do not purge the objectcache table after updates' ); $this->addOption( 'noschema', 'Only do the updates that are not done during schema updates' ); - $this->addOption( 'schema', 'Output SQL to do the schema updates instead of doing them. Works even when $wgAllowSchemaUpdates is false', false, true ); + $this->addOption( + 'schema', + 'Output SQL to do the schema updates instead of doing them. Works ' + . 'even when $wgAllowSchemaUpdates is false', + false, + true + ); $this->addOption( 'force', 'Override when $wgAllowSchemaUpdates disables this script' ); } function getDbType() { /* If we used the class constant PHP4 would give a parser error here */ - return 2 /* Maintenance::DB_ADMIN */; + return 2; /* Maintenance::DB_ADMIN */ } function compatChecks() { @@ -85,7 +91,11 @@ class UpdateMediaWiki extends Maintenance { function execute() { global $wgVersion, $wgLang, $wgAllowSchemaUpdates; - if ( !$wgAllowSchemaUpdates && !( $this->hasOption( 'force' ) || $this->hasOption( 'schema' ) || $this->hasOption( 'noschema' ) ) ) { + if ( !$wgAllowSchemaUpdates + && !( $this->hasOption( 'force' ) + || $this->hasOption( 'schema' ) + || $this->hasOption( 'noschema' ) ) + ) { $this->error( "Do not run update.php on this wiki. If you're seeing this you should\n" . "probably ask for some help in performing your schema updates or use\n" . "the --noschema and --schema options to get an SQL file for someone\n" @@ -131,7 +141,8 @@ class UpdateMediaWiki extends Maintenance { $this->output( "Depending on the size of your database this may take a while!\n" ); if ( !$this->hasOption( 'quick' ) ) { - $this->output( "Abort with control-c in the next five seconds (skip this countdown with --quick) ... " ); + $this->output( "Abort with control-c in the next five seconds " + . "(skip this countdown with --quick) ... " ); wfCountDown( 5 ); } diff --git a/maintenance/updateArticleCount.php b/maintenance/updateArticleCount.php index 7964a21f82..470647a4c4 100644 --- a/maintenance/updateArticleCount.php +++ b/maintenance/updateArticleCount.php @@ -49,10 +49,16 @@ class UpdateArticleCount extends Maintenance { if ( $this->hasOption( 'update' ) ) { $this->output( "Updating site statistics table... " ); $dbw = wfGetDB( DB_MASTER ); - $dbw->update( 'site_stats', array( 'ss_good_articles' => $result ), array( 'ss_row_id' => 1 ), __METHOD__ ); + $dbw->update( + 'site_stats', + array( 'ss_good_articles' => $result ), + array( 'ss_row_id' => 1 ), + __METHOD__ + ); $this->output( "done.\n" ); } else { - $this->output( "To update the site statistics table, run the script with the --update option.\n" ); + $this->output( "To update the site statistics table, run the script " + . "with the --update option.\n" ); } } } diff --git a/maintenance/updateDoubleWidthSearch.php b/maintenance/updateDoubleWidthSearch.php index 41988d1b25..f863697ba5 100644 --- a/maintenance/updateDoubleWidthSearch.php +++ b/maintenance/updateDoubleWidthSearch.php @@ -36,7 +36,12 @@ class UpdateDoubleWidthSearch extends Maintenance { parent::__construct(); $this->mDescription = "Script to normalize double-byte latin UTF-8 characters"; $this->addOption( 'q', 'quiet', false, true ); - $this->addOption( 'l', 'How long the searchindex and revision tables will be locked for', false, true ); + $this->addOption( + 'l', + 'How long the searchindex and revision tables will be locked for', + false, + true + ); } public function getDbType() { diff --git a/maintenance/updateRestrictions.php b/maintenance/updateRestrictions.php index 175447e780..5b5cc04895 100644 --- a/maintenance/updateRestrictions.php +++ b/maintenance/updateRestrictions.php @@ -59,7 +59,12 @@ class UpdateRestrictions extends Maintenance { while ( $blockEnd <= $end ) { $this->output( "...doing page_id from $blockStart to $blockEnd\n" ); $cond = "page_id BETWEEN $blockStart AND $blockEnd AND page_restrictions !=''"; - $res = $db->select( 'page', array( 'page_id', 'page_namespace', 'page_restrictions' ), $cond, __METHOD__ ); + $res = $db->select( + 'page', + array( 'page_id', 'page_namespace', 'page_restrictions' ), + $cond, + __METHOD__ + ); $batch = array(); foreach ( $res as $row ) { $oldRestrictions = array(); @@ -108,7 +113,13 @@ class UpdateRestrictions extends Maintenance { // Kill any broken rows from previous imports $db->delete( 'page_restrictions', array( 'pr_level' => '' ) ); // Kill other invalid rows - $db->deleteJoin( 'page_restrictions', 'page', 'pr_page', 'page_id', array( 'page_namespace' => NS_MEDIAWIKI ) ); + $db->deleteJoin( + 'page_restrictions', + 'page', + 'pr_page', + 'page_id', + array( 'page_namespace' => NS_MEDIAWIKI ) + ); $this->output( "...Done!\n" ); } } diff --git a/maintenance/updateSearchIndex.php b/maintenance/updateSearchIndex.php index 0691bee811..68a51bd9a5 100644 --- a/maintenance/updateSearchIndex.php +++ b/maintenance/updateSearchIndex.php @@ -42,8 +42,18 @@ class UpdateSearchIndex extends Maintenance { $this->mDescription = "Script for periodic off-peak updating of the search index"; $this->addOption( 's', 'starting timestamp', false, true ); $this->addOption( 'e', 'Ending timestamp', false, true ); - $this->addOption( 'p', 'File for saving/loading timestamps, searchUpdate.WIKI_ID.pos by default', false, true ); - $this->addOption( 'l', 'How long the searchindex and revision tables will be locked for', false, true ); + $this->addOption( + 'p', + 'File for saving/loading timestamps, searchUpdate.WIKI_ID.pos by default', + false, + true + ); + $this->addOption( + 'l', + 'How long the searchindex and revision tables will be locked for', + false, + true + ); } public function getDbType() { diff --git a/maintenance/userDupes.inc b/maintenance/userDupes.inc index bd3338a937..bc8fbcfad1 100644 --- a/maintenance/userDupes.inc +++ b/maintenance/userDupes.inc @@ -125,7 +125,8 @@ class UserDupes { if ( $this->reassigned > 0 ) { if ( $doDelete ) { - $this->out( "$this->reassigned duplicate accounts had edits reassigned to a canonical record id.\n" ); + $this->out( "$this->reassigned duplicate accounts had edits " + . "reassigned to a canonical record id.\n" ); } else { $this->out( "$this->reassigned duplicate accounts need to have edits reassigned.\n" ); } @@ -133,9 +134,11 @@ class UserDupes { if ( $this->trimmed > 0 ) { if ( $doDelete ) { - $this->out( "$this->trimmed duplicate user records were deleted from " . wfWikiID() . ".\n" ); + $this->out( "$this->trimmed duplicate user records were deleted from " + . wfWikiID() . ".\n" ); } else { - $this->out( "$this->trimmed duplicate user accounts were found on " . wfWikiID() . " which can be removed safely.\n" ); + $this->out( "$this->trimmed duplicate user accounts were found on " + . wfWikiID() . " which can be removed safely.\n" ); } } diff --git a/maintenance/userOptions.inc b/maintenance/userOptions.inc index 5d113526f2..5998cb59a1 100644 --- a/maintenance/userOptions.inc +++ b/maintenance/userOptions.inc @@ -155,7 +155,9 @@ class UserOptions { $userValue = $user->getOption( $this->mAnOption ); if ( $userValue <> $defaultOptions[$this->mAnOption] ) { + // @codingStandardsIgnoreStart Ignore silencing errors is discouraged warning @$ret[$this->mAnOption][$userValue]++; + // @codingStandardsIgnoreEnd } } else { @@ -163,7 +165,9 @@ class UserOptions { foreach ( $defaultOptions as $name => $defaultValue ) { $userValue = $user->getOption( $name ); if ( $userValue <> $defaultValue ) { + // @codingStandardsIgnoreStart Ignore silencing errors is discouraged warning @$ret[$name][$userValue]++; + // @codingStandardsIgnoreEnd } } } @@ -200,7 +204,8 @@ class UserOptions { if ( $curValue == $this->mOldValue ) { if ( !$this->mQuiet ) { - print "Setting {$this->mAnOption} for $username from '{$this->mOldValue}' to '{$this->mNewValue}'): "; + print "Setting {$this->mAnOption} for $username from '{$this->mOldValue}' " . + "to '{$this->mNewValue}'): "; } // Change value -- 2.20.1