From 89d8c583d7d6dd03f10382208a2cf5d43e2f7c3e Mon Sep 17 00:00:00 2001 From: Siebrand Mazeland Date: Tue, 22 Apr 2014 22:55:50 +0200 Subject: [PATCH] Pass phpcs-strict on maintenance/ (2/8) Change-Id: I69e2bca3c98fe9d3713c852699f49b7b4c868338 --- maintenance/rebuildrecentchanges.php | 16 ++++++++-- maintenance/rebuildtextindex.php | 6 ++-- maintenance/refreshImageMetadata.php | 45 +++++++++++++++++++++++----- maintenance/removeUnusedAccounts.php | 10 +++++-- maintenance/resetUserTokens.php | 16 +++++++--- maintenance/rollbackEdits.php | 10 +++++-- maintenance/runBatchedQuery.php | 3 +- maintenance/runJobs.php | 4 ++- maintenance/showCacheStats.php | 30 +++++++++++++++---- maintenance/showJobs.php | 5 +++- 10 files changed, 117 insertions(+), 28 deletions(-) diff --git a/maintenance/rebuildrecentchanges.php b/maintenance/rebuildrecentchanges.php index 2a9bb4fc61..2c83454eba 100644 --- a/maintenance/rebuildrecentchanges.php +++ b/maintenance/rebuildrecentchanges.php @@ -82,7 +82,11 @@ class RebuildRecentchanges extends Maintenance { '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_source' => $dbw->conditional( + 'page_is_new != 0', + $dbw->addQuotes( RecentChange::SRC_NEW ), + $dbw->addQuotes( RecentChange::SRC_EDIT ) + ), 'rc_deleted' => 'rev_deleted' ), array( 'rev_timestamp > ' . $dbw->addQuotes( $dbw->timestamp( $cutoff ) ), @@ -182,7 +186,12 @@ class RebuildRecentchanges extends Maintenance { $cutoff = time() - $wgRCMaxAge; list( $logging, $page ) = $dbw->tableNamesN( 'logging', 'page' ); - $dbw->insertSelect( 'recentchanges', array( 'user', "$logging LEFT JOIN $page ON (log_namespace=page_namespace AND log_title=page_title)" ), + $dbw->insertSelect( + 'recentchanges', + array( + 'user', + "$logging LEFT JOIN $page ON (log_namespace=page_namespace AND log_title=page_title)" + ), array( 'rc_timestamp' => 'log_timestamp', 'rc_user' => 'log_user', @@ -223,7 +232,8 @@ class RebuildRecentchanges extends Maintenance { $dbw = wfGetDB( DB_MASTER ); - list( $recentchanges, $usergroups, $user ) = $dbw->tableNamesN( 'recentchanges', 'user_groups', 'user' ); + list( $recentchanges, $usergroups, $user ) = + $dbw->tableNamesN( 'recentchanges', 'user_groups', 'user' ); $botgroups = User::getGroupsWithPermission( 'bot' ); $autopatrolgroups = $wgUseRCPatrol ? User::getGroupsWithPermission( 'autopatrol' ) : array(); diff --git a/maintenance/rebuildtextindex.php b/maintenance/rebuildtextindex.php index 722db26cfe..bc85c666af 100644 --- a/maintenance/rebuildtextindex.php +++ b/maintenance/rebuildtextindex.php @@ -59,10 +59,12 @@ class RebuildTextIndex extends Maintenance { $this->db = wfGetDB( DB_MASTER ); if ( $this->db->getType() == 'sqlite' ) { if ( !DatabaseSqlite::getFulltextSearchModule() ) { - $this->error( "Your version of SQLite module for PHP doesn't support full-text search (FTS3).\n", true ); + $this->error( "Your version of SQLite module for PHP doesn't " + . "support full-text search (FTS3).\n", true ); } if ( !$this->db->checkForEnabledSearch() ) { - $this->error( "Your database schema is not configured for full-text search support. Run update.php.\n", true ); + $this->error( "Your database schema is not configured for " + . "full-text search support. Run update.php.\n", true ); } } diff --git a/maintenance/refreshImageMetadata.php b/maintenance/refreshImageMetadata.php index ae8d5083cb..95dc10bdf8 100644 --- a/maintenance/refreshImageMetadata.php +++ b/maintenance/refreshImageMetadata.php @@ -47,14 +47,41 @@ class RefreshImageMetadata extends Maintenance { $this->mDescription = 'Script to update image metadata records'; $this->setBatchSize( 200 ); - $this->addOption( 'force', 'Reload metadata from file even if the metadata looks ok', false, false, 'f' ); - $this->addOption( 'broken-only', 'Only fix really broken records, leave old but still compatible records alone.' ); - $this->addOption( 'verbose', 'Output extra information about each upgraded/non-upgraded file.', false, false, 'v' ); + $this->addOption( + 'force', + 'Reload metadata from file even if the metadata looks ok', + false, + false, + 'f' + ); + $this->addOption( + 'broken-only', + 'Only fix really broken records, leave old but still compatible records alone.' + ); + $this->addOption( + 'verbose', + 'Output extra information about each upgraded/non-upgraded file.', + false, + false, + 'v' + ); $this->addOption( 'start', 'Name of file to start with', false, true ); $this->addOption( 'end', 'Name of file to end with', false, true ); - $this->addOption( 'mime', '(Inefficient!) Only refresh files with this mime type. Can accept wild-card image/*', false, true ); - $this->addOption( 'metadata-contains', '(Inefficient!) Only refresh files where the img_metadata field contains this string. Can be used if its known a specific property was being extracted incorrectly.', false, true ); + $this->addOption( + 'mime', + '(Inefficient!) Only refresh files with this mime type. Can accept wild-card image/*', + false, + true + ); + $this->addOption( + 'metadata-contains', + '(Inefficient!) Only refresh files where the img_metadata field ' + . 'contains this string. Can be used if its known a specific ' + . 'property was being extracted incorrectly.', + false, + true + ); } @@ -155,9 +182,13 @@ class RefreshImageMetadata extends Maintenance { $total = $upgraded + $leftAlone; if ( $force ) { - $this->output( "\nFinished refreshing file metadata for $total files. $upgraded needed to be refreshed, $leftAlone did not need to be but were refreshed anyways, and $error refreshes were suspicious.\n" ); + $this->output( "\nFinished refreshing file metadata for $total files. " + . "$upgraded needed to be refreshed, $leftAlone did not need to " + . "be but were refreshed anyways, and $error refreshes were suspicious.\n" ); } else { - $this->output( "\nFinished refreshing file metadata for $total files. $upgraded were refreshed, $leftAlone were already up to date, and $error refreshes were suspicious.\n" ); + $this->output( "\nFinished refreshing file metadata for $total files. " + . "$upgraded were refreshed, $leftAlone were already up to date, " + . "and $error refreshes were suspicious.\n" ); } } diff --git a/maintenance/removeUnusedAccounts.php b/maintenance/removeUnusedAccounts.php index 4ceab4feae..55b23601ab 100644 --- a/maintenance/removeUnusedAccounts.php +++ b/maintenance/removeUnusedAccounts.php @@ -58,7 +58,8 @@ class RemoveUnusedAccounts extends Maintenance { } $touchedSeconds = 86400 * $touched; foreach ( $res as $row ) { - # Check the account, but ignore it if it's within a $excludedGroups group or if it's touched within the $touchedSeconds seconds. + # Check the account, but ignore it if it's within a $excludedGroups + # group or if it's touched within the $touchedSeconds seconds. $instance = User::newFromId( $row->user_id ); if ( count( array_intersect( $instance->getEffectiveGroups(), $excludedGroups ) ) == 0 && $this->isInactiveAccount( $row->user_id, true ) @@ -85,7 +86,12 @@ class RemoveUnusedAccounts extends Maintenance { $this->output( "done.\n" ); # Update the site_stats.ss_users field $users = $dbw->selectField( 'user', 'COUNT(*)', array(), __METHOD__ ); - $dbw->update( 'site_stats', array( 'ss_users' => $users ), array( 'ss_row_id' => 1 ), __METHOD__ ); + $dbw->update( + 'site_stats', + array( 'ss_users' => $users ), + array( 'ss_row_id' => 1 ), + __METHOD__ + ); } elseif ( $count > 0 ) { $this->output( "\nRun the script again with --delete to remove them from the database.\n" ); } diff --git a/maintenance/resetUserTokens.php b/maintenance/resetUserTokens.php index 9847ccc82b..a1ee3deba3 100644 --- a/maintenance/resetUserTokens.php +++ b/maintenance/resetUserTokens.php @@ -34,9 +34,15 @@ require_once __DIR__ . '/Maintenance.php'; class ResetUserTokens extends Maintenance { public function __construct() { parent::__construct(); - $this->mDescription = "Reset the user_token of all users on the wiki. Note that this may log some of them out."; + $this->mDescription = + "Reset the user_token of all users on the wiki. Note that this may log some of them out."; $this->addOption( 'nowarn', "Hides the 5 seconds warning", false, false ); - $this->addOption( 'nulls', 'Only reset tokens that are currently null (string of \x00\'s)', false, false ); + $this->addOption( + 'nulls', + 'Only reset tokens that are currently null (string of \x00\'s)', + false, + false + ); $this->setBatchSize( 1000 ); } @@ -45,14 +51,16 @@ class ResetUserTokens extends Maintenance { if ( !$this->getOption( 'nowarn' ) ) { if ( $this->nullsOnly ) { - $this->output( "The script is about to reset the user_token for USERS WITH NULL TOKENS in the database.\n" ); + $this->output( "The script is about to reset the user_token " + . "for USERS WITH NULL TOKENS in the database.\n" ); } else { $this->output( "The script is about to reset the user_token for ALL USERS in the database.\n" ); $this->output( "This may log some of them out and is not necessary unless you believe your\n" ); $this->output( "user table has been compromised.\n" ); } $this->output( "\n" ); - $this->output( "Abort with control-c in the next five seconds (skip this countdown with --nowarn) ... " ); + $this->output( "Abort with control-c in the next five seconds " + . "(skip this countdown with --nowarn) ... " ); wfCountDown( 5 ); } diff --git a/maintenance/rollbackEdits.php b/maintenance/rollbackEdits.php index 1e0e441eef..6bb0fb816d 100644 --- a/maintenance/rollbackEdits.php +++ b/maintenance/rollbackEdits.php @@ -33,8 +33,14 @@ require_once __DIR__ . '/Maintenance.php'; class RollbackEdits extends Maintenance { public function __construct() { parent::__construct(); - $this->mDescription = "Rollback all edits by a given user or IP provided they're the most recent edit"; - $this->addOption( 'titles', 'A list of titles, none means all titles where the given user is the most recent', false, true ); + $this->mDescription = + "Rollback all edits by a given user or IP provided they're the most recent edit"; + $this->addOption( + 'titles', + 'A list of titles, none means all titles where the given user is the most recent', + false, + true + ); $this->addOption( 'user', 'A user or IP to rollback all edits for', true, true ); $this->addOption( 'summary', 'Edit summary to use', false, true ); $this->addOption( 'bot', 'Mark the edits as bot' ); diff --git a/maintenance/runBatchedQuery.php b/maintenance/runBatchedQuery.php index 76340cdb32..af8890509e 100644 --- a/maintenance/runBatchedQuery.php +++ b/maintenance/runBatchedQuery.php @@ -33,7 +33,8 @@ require_once __DIR__ . '/Maintenance.php'; class BatchedQueryRunner extends Maintenance { public function __construct() { parent::__construct(); - $this->mDescription = "Run a query repeatedly until it affects 0 rows, and wait for slaves in between.\n" . + $this->mDescription = + "Run a query repeatedly until it affects 0 rows, and wait for slaves in between.\n" . "NOTE: You need to set a LIMIT clause yourself."; } diff --git a/maintenance/runJobs.php b/maintenance/runJobs.php index 13f526c48b..c3eb4ba11e 100644 --- a/maintenance/runJobs.php +++ b/maintenance/runJobs.php @@ -79,7 +79,9 @@ class RunJobs extends Maintenance { $backoffs = $this->loadBackoffs(); // map of (type => UNIX expiry) $startingBackoffs = $backoffs; // avoid unnecessary writes - $backoffExpireFunc = function( $t ) { return $t > time(); }; + $backoffExpireFunc = function ( $t ) { + return $t > time(); + }; $jobsRun = 0; // counter $flags = JobQueueGroup::USE_CACHE; diff --git a/maintenance/showCacheStats.php b/maintenance/showCacheStats.php index 854910f9ea..3d16af141d 100644 --- a/maintenance/showCacheStats.php +++ b/maintenance/showCacheStats.php @@ -55,8 +55,16 @@ class ShowCacheStats extends Maintenance { $total = $hits + $expired + $absent + $stub; if ( $total ) { $this->output( sprintf( "hits: %-10d %6.2f%%\n", $hits, $hits / $total * 100 ) ); - $this->output( sprintf( "expired: %-10d %6.2f%%\n", $expired, $expired / $total * 100 ) ); - $this->output( sprintf( "absent: %-10d %6.2f%%\n", $absent, $absent / $total * 100 ) ); + $this->output( sprintf( + "expired: %-10d %6.2f%%\n", + $expired, + $expired / $total * 100 + ) ); + $this->output( sprintf( + "absent: %-10d %6.2f%%\n", + $absent, + $absent / $total * 100 + ) ); $this->output( sprintf( "stub threshold: %-10d %6.2f%%\n", $stub, $stub / $total * 100 ) ); $this->output( sprintf( "total: %-10d %6.2f%%\n", $total, 100 ) ); } else { @@ -70,7 +78,11 @@ class ShowCacheStats extends Maintenance { $total = $hits + $misses; if ( $total ) { $this->output( sprintf( "hits: %-10d %6.2f%%\n", $hits, $hits / $total * 100 ) ); - $this->output( sprintf( "misses: %-10d %6.2f%%\n", $misses, $misses / $total * 100 ) ); + $this->output( sprintf( + "misses: %-10d %6.2f%%\n", + $misses, + $misses / $total * 100 + ) ); $this->output( sprintf( "updates: %-10d\n", $updates ) ); } else { $this->output( "no statistics available\n" ); @@ -83,8 +95,16 @@ class ShowCacheStats extends Maintenance { $total = $hits + $misses + $uncacheable; if ( $total ) { $this->output( sprintf( "hits: %-10d %6.2f%%\n", $hits, $hits / $total * 100 ) ); - $this->output( sprintf( "misses: %-10d %6.2f%%\n", $misses, $misses / $total * 100 ) ); - $this->output( sprintf( "uncacheable: %-10d %6.2f%%\n", $uncacheable, $uncacheable / $total * 100 ) ); + $this->output( sprintf( + "misses: %-10d %6.2f%%\n", + $misses, + $misses / $total * 100 + ) ); + $this->output( sprintf( + "uncacheable: %-10d %6.2f%%\n", + $uncacheable, + $uncacheable / $total * 100 + ) ); } else { $this->output( "no statistics available\n" ); } diff --git a/maintenance/showJobs.php b/maintenance/showJobs.php index 5e2113045b..38f346b40d 100644 --- a/maintenance/showJobs.php +++ b/maintenance/showJobs.php @@ -38,7 +38,10 @@ class ShowJobs extends Maintenance { parent::__construct(); $this->mDescription = "Show number of jobs waiting in master database"; $this->addOption( 'group', 'Show number of jobs per job type' ); - $this->addOption( 'list', 'Show a complete list of all jobs in a machine-readable format, instead of statistics' ); + $this->addOption( + 'list', + 'Show a complete list of all jobs in a machine-readable format, instead of statistics' + ); } public function execute() { -- 2.20.1