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

maintenance/showSiteStats.php
maintenance/sql.php
maintenance/sqlite.php
maintenance/update.php
maintenance/updateArticleCount.php
maintenance/updateDoubleWidthSearch.php
maintenance/updateRestrictions.php
maintenance/updateSearchIndex.php
maintenance/userDupes.inc
maintenance/userOptions.inc

index 49148b3..6bf4daa 100644 (file)
@@ -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
+                       ) );
                }
        }
 }
index d43c8dc..b20b0cf 100644 (file)
@@ -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;
index 8a78524..dbd8ed1 100644 (file)
@@ -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 );
index 8c1ad17..f96ee39 100644 (file)
@@ -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 );
                }
 
index 7964a21..470647a 100644 (file)
@@ -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" );
                }
        }
 }
index 41988d1..f863697 100644 (file)
@@ -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() {
index 175447e..5b5cc04 100644 (file)
@@ -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" );
        }
 }
index 0691bee..68a51bd 100644 (file)
@@ -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() {
index bd3338a..bc8fbcf 100644 (file)
@@ -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" );
                        }
                }
 
index 5d11352..5998cb5 100644 (file)
@@ -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