Pass phpcs-strict on maintenance/ (2/8)
authorSiebrand Mazeland <siebrand@kitano.nl>
Tue, 22 Apr 2014 20:55:50 +0000 (22:55 +0200)
committerSiebrand <siebrand@kitano.nl>
Tue, 22 Apr 2014 21:25:47 +0000 (21:25 +0000)
Change-Id: I69e2bca3c98fe9d3713c852699f49b7b4c868338

maintenance/rebuildrecentchanges.php
maintenance/rebuildtextindex.php
maintenance/refreshImageMetadata.php
maintenance/removeUnusedAccounts.php
maintenance/resetUserTokens.php
maintenance/rollbackEdits.php
maintenance/runBatchedQuery.php
maintenance/runJobs.php
maintenance/showCacheStats.php
maintenance/showJobs.php

index 2a9bb4f..2c83454 100644 (file)
@@ -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();
index 722db26..bc85c66 100644 (file)
@@ -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 );
                        }
                }
 
index ae8d508..95dc10b 100644 (file)
@@ -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" );
                }
        }
 
index 4ceab4f..55b2360 100644 (file)
@@ -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" );
                }
index 9847ccc..a1ee3de 100644 (file)
@@ -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 );
                }
 
index 1e0e441..6bb0fb8 100644 (file)
@@ -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' );
index 76340cd..af88905 100644 (file)
@@ -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.";
        }
 
index 13f526c..c3eb4ba 100644 (file)
@@ -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;
index 854910f..3d16af1 100644 (file)
@@ -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" );
                }
index 5e21130..38f346b 100644 (file)
@@ -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() {