Fixed some spacing in maintenance folder
authorumherirrender <umherirrender_de.wp@web.de>
Thu, 18 Apr 2013 18:48:44 +0000 (20:48 +0200)
committerumherirrender <umherirrender_de.wp@web.de>
Thu, 18 Apr 2013 18:48:44 +0000 (20:48 +0200)
Added spaces before if, foreach
Added some braces for one line statements

Change-Id: I9657f72996358f8c1c154cea1ea97970d973723c

79 files changed:
maintenance/Maintenance.php
maintenance/backupTextPass.inc
maintenance/cdb.php
maintenance/checkSyntax.php
maintenance/cleanupAncientTables.php
maintenance/cleanupPreferences.php
maintenance/cleanupRemovedModules.php
maintenance/cleanupTitles.php
maintenance/cleanupUploadStash.php
maintenance/cleanupWatchlist.php
maintenance/compareParsers.php
maintenance/convertLinks.php
maintenance/deleteArchivedFiles.inc
maintenance/deleteDefaultMessages.php
maintenance/deleteImageMemcached.php
maintenance/deleteOrphanedRevisions.php
maintenance/deleteSelfExternals.php
maintenance/dev/includes/router.php
maintenance/doMaintenance.php
maintenance/dumpBackup.php
maintenance/dumpIterator.php
maintenance/dumpLinks.php
maintenance/dumpSisterSites.php
maintenance/fetchText.php
maintenance/fixSlaveDesync.php
maintenance/generateSitemap.php
maintenance/getLagTimes.php
maintenance/importDump.php
maintenance/importImages.inc
maintenance/importImages.php
maintenance/initSiteStats.php
maintenance/install.php
maintenance/language/StatOutputs.php
maintenance/language/checkDupeMessages.php
maintenance/language/checkLanguage.inc
maintenance/language/langmemusage.php
maintenance/language/messages.inc
maintenance/language/writeMessagesArray.inc
maintenance/mcc.php
maintenance/mctest.php
maintenance/mergeMessageFileList.php
maintenance/mwdocgen.php
maintenance/namespaceDupes.php
maintenance/nukeNS.php
maintenance/nukePage.php
maintenance/oracle/alterSharedConstraints.php
maintenance/orphans.php
maintenance/parse.php
maintenance/populateFilearchiveSha1.php
maintenance/populateLogSearch.php
maintenance/populateParentId.php
maintenance/populateRevisionLength.php
maintenance/preprocessDump.php
maintenance/preprocessorFuzzTest.php
maintenance/protect.php
maintenance/proxyCheck.php
maintenance/purgeDeletedFiles.php
maintenance/purgeList.php
maintenance/reassignEdits.php
maintenance/rebuildFileCache.php
maintenance/rebuildmessages.php
maintenance/rebuildrecentchanges.php
maintenance/rebuildtextindex.php
maintenance/refreshImageMetadata.php
maintenance/refreshLinks.php
maintenance/renderDump.php
maintenance/runBatchedQuery.php
maintenance/showJobs.php
maintenance/showSiteStats.php
maintenance/sql.php
maintenance/sqlite.inc
maintenance/storage/checkStorage.php
maintenance/storage/compressOld.php
maintenance/storage/dumpRev.php
maintenance/storage/recompressTracked.php
maintenance/updateSearchIndex.php
maintenance/updateSpecialPages.php
maintenance/userDupes.inc
maintenance/userOptions.inc

index 08d8641..d68b831 100644 (file)
@@ -54,8 +54,8 @@ abstract class Maintenance {
         * Constants for DB access type
         * @see Maintenance::getDbType()
         */
-       const DB_NONE  = 0;
-       const DB_STD   = 1;
+       const DB_NONE = 0;
+       const DB_STD = 1;
        const DB_ADMIN = 2;
 
        // Const for getStdin()
@@ -153,7 +153,7 @@ abstract class Maintenance {
                        return false; // last call should be to this function
                }
                $includeFuncs = array( 'require_once', 'require', 'include', 'include_once' );
-               for( $i = 1; $i < $count; $i++ ) {
+               for ( $i = 1; $i < $count; $i++ ) {
                        if ( !in_array( $bt[$i]['function'], $includeFuncs ) ) {
                                return false; // previous calls should all be "requires"
                        }
@@ -428,7 +428,7 @@ abstract class Maintenance {
                                "server name detection may fail in command line scripts.", false, true );
 
                # Save generic options to display them separately in help
-               $this->mGenericParameters = $this->mParams ;
+               $this->mGenericParameters = $this->mParams;
 
                # Script dependant options:
 
@@ -515,7 +515,7 @@ abstract class Maintenance {
                $wgCommandLineMode = true;
 
                # Turn off output buffering if it's on
-               while( ob_get_level() > 0 ) {
+               while ( ob_get_level() > 0 ) {
                        ob_end_flush();
                }
 
@@ -634,7 +634,7 @@ abstract class Maintenance {
                        } elseif ( substr( $arg, 0, 1 ) == '-' ) {
                                # Short options
                                for ( $p = 1; $p < strlen( $arg ); $p++ ) {
-                                       $option = $arg { $p } ;
+                                       $option = $arg { $p };
                                        if ( !isset( $this->mParams[$option] ) && isset( $this->mShortParamsMap[$option] ) ) {
                                                $option = $this->mShortParamsMap[$option];
                                        }
@@ -712,7 +712,7 @@ abstract class Maintenance {
         * @param $force boolean Whether to force the help to show, default false
         */
        protected function maybeHelp( $force = false ) {
-               if( !$force && !$this->hasOption( 'help' ) ) {
+               if ( !$force && !$this->hasOption( 'help' ) ) {
                        return;
                }
 
@@ -743,8 +743,9 @@ abstract class Maintenance {
                                } else {
                                        $output .= '[' . $arg['name'] . ']';
                                }
-                               if ( $k < count( $this->mArgList ) - 1 )
+                               if ( $k < count( $this->mArgList ) - 1 ) {
                                        $output .= ' ';
+                               }
                        }
                }
                $this->output( "$output\n\n" );
@@ -765,7 +766,7 @@ abstract class Maintenance {
                $this->output( "\n" );
 
                $scriptDependantParams = $this->mDependantParameters;
-               if( count($scriptDependantParams) > 0 ) {
+               if ( count($scriptDependantParams) > 0 ) {
                        $this->output( "Script dependant parameters:\n" );
                        // Parameters description
                        foreach ( $scriptDependantParams as $par => $info ) {
@@ -790,7 +791,7 @@ abstract class Maintenance {
                        $this->mGenericParameters,
                        $this->mDependantParameters
                );
-               if( count($scriptSpecificParams) > 0 ) {
+               if ( count($scriptSpecificParams) > 0 ) {
                        $this->output( "Script specific parameters:\n" );
                        // Parameters description
                        foreach ( $scriptSpecificParams as $par => $info ) {
@@ -806,7 +807,7 @@ abstract class Maintenance {
                }
 
                // Print arguments
-               if( count( $this->mArgList ) > 0 ) {
+               if ( count( $this->mArgList ) > 0 ) {
                        $this->output( "Arguments:\n" );
                        // Arguments description
                        foreach ( $this->mArgList as $info ) {
@@ -839,7 +840,7 @@ abstract class Maintenance {
                $wgCommandLineMode = true;
 
                # Override $wgServer
-               if( $this->hasOption( 'server') ) {
+               if ( $this->hasOption( 'server' ) ) {
                        $wgServer = $this->getOption( 'server', $wgServer );
                }
 
@@ -906,7 +907,7 @@ abstract class Maintenance {
 
                if ( isset( $this->mOptions['conf'] ) ) {
                        $settingsFile = $this->mOptions['conf'];
-               } elseif ( defined("MW_CONFIG_FILE") ) {
+               } elseif ( defined( "MW_CONFIG_FILE" ) ) {
                        $settingsFile = MW_CONFIG_FILE;
                } else {
                        $settingsFile = "$IP/LocalSettings.php";
@@ -1190,7 +1191,9 @@ abstract class Maintenance {
                                        $st = fgets( STDIN, 1024 );
                                }
                        }
-                       if ( $st === false ) return false;
+                       if ( $st === false ) {
+                               return false;
+                       }
                        $resp = trim( $st );
                        return $resp;
                }
index eaac02c..c99f004 100644 (file)
@@ -141,8 +141,9 @@ class TextPassDumper extends BackupDumper {
        function dump( $history, $text = WikiExporter::TEXT ) {
                // Notice messages will foul up your XML output even if they're
                // relatively harmless.
-               if ( ini_get( 'display_errors' ) )
+               if ( ini_get( 'display_errors' ) ) {
                        ini_set( 'display_errors', 'stderr' );
+               }
 
                $this->initProgress( $this->history );
 
@@ -611,17 +612,21 @@ class TextPassDumper extends BackupDumper {
 
        private function closeSpawn() {
                wfSuppressWarnings();
-               if ( $this->spawnRead )
+               if ( $this->spawnRead ) {
                        fclose( $this->spawnRead );
+               }
                $this->spawnRead = false;
-               if ( $this->spawnWrite )
+               if ( $this->spawnWrite ) {
                        fclose( $this->spawnWrite );
+               }
                $this->spawnWrite = false;
-               if ( $this->spawnErr )
+               if ( $this->spawnErr ) {
                        fclose( $this->spawnErr );
+               }
                $this->spawnErr = false;
-               if ( $this->spawnProc )
+               if ( $this->spawnProc ) {
                        pclose( $this->spawnProc );
+               }
                $this->spawnProc = false;
                wfRestoreWarnings();
        }
@@ -631,11 +636,15 @@ class TextPassDumper extends BackupDumper {
 
                $ok = fwrite( $this->spawnWrite, "$id\n" );
                // $this->progress( ">> $id" );
-               if ( !$ok ) return false;
+               if ( !$ok ) {
+                       return false;
+               }
 
                $ok = fflush( $this->spawnWrite );
                // $this->progress( ">> [flush]" );
-               if ( !$ok ) return false;
+               if ( !$ok ) {
+                       return false;
+               }
 
                // check that the text id they are sending is the one we asked for
                // this avoids out of sync revision text errors we have encountered in the past
@@ -649,18 +658,24 @@ class TextPassDumper extends BackupDumper {
 
                $len = fgets( $this->spawnRead );
                // $this->progress( "<< " . trim( $len ) );
-               if ( $len === false ) return false;
+               if ( $len === false ) {
+                       return false;
+               }
 
                $nbytes = intval( $len );
                // actual error, not zero-length text
-               if ( $nbytes < 0 ) return false;
+               if ( $nbytes < 0 ) {
+                       return false;
+               }
 
                $text = "";
 
                // Subprocess may not send everything at once, we have to loop.
                while ( $nbytes > strlen( $text ) ) {
                        $buffer = fread( $this->spawnRead, $nbytes - strlen( $text ) );
-                       if ( $buffer === false ) break;
+                       if ( $buffer === false ) {
+                               break;
+                       }
                        $text .= $buffer;
                }
 
index c06c2cd..9e56e1b 100644 (file)
@@ -28,7 +28,7 @@ require_once( __DIR__ . '/commandLine.inc' );
 function cdbShowHelp( $command ) {
        $commandList = array(
                'load' => 'load a cdb file for reading',
-               'get'  => 'get a value for a key',
+               'get' => 'get a value for a key',
                'exit' => 'exit cdb',
                'quit' => 'exit cdb',
                'help' => 'help about a command',
@@ -55,7 +55,9 @@ do {
        static $fileHandle;
 
        $line = Maintenance::readconsole();
-       if ( $line === false ) exit;
+       if ( $line === false ) {
+               exit;
+       }
 
        $args = explode( ' ', $line );
        $command = array_shift( $args );
@@ -67,25 +69,25 @@ do {
                        cdbShowHelp( array_shift( $args ) );
                        break;
                case 'load':
-                       if( !isset( $args[0] ) ) {
+                       if ( !isset( $args[0] ) ) {
                                print "Need a filename there buddy\n";
                                break;
                        }
                        $file = $args[0];
                        print "Loading cdb file $file...";
                        $fileHandle = CdbReader::open( $file );
-                       if( !$fileHandle ) {
+                       if ( !$fileHandle ) {
                                print "not a cdb file or unable to read it\n";
                        } else {
                                print "ok\n";
                        }
                        break;
                case 'get':
-                       if( !$fileHandle ) {
+                       if ( !$fileHandle ) {
                                print "Need to load a cdb file first\n";
                                break;
                        }
-                       if( !isset( $args[0] ) ) {
+                       if ( !isset( $args[0] ) ) {
                                print "Need to specify a key, Luke\n";
                                break;
                        }
index 1e44e23..efb9471 100644 (file)
@@ -221,12 +221,14 @@ class CheckSyntax extends Maintenance {
        private function isSuitableFile( $file ) {
                $file = str_replace( '\\', '/', $file );
                $ext = pathinfo( $file, PATHINFO_EXTENSION );
-               if ( $ext != 'php' && $ext != 'inc' && $ext != 'php5' )
+               if ( $ext != 'php' && $ext != 'inc' && $ext != 'php5' ) {
                        return false;
+               }
                foreach ( $this->mIgnorePaths as $regex ) {
                        $m = array();
-                       if ( preg_match( "~{$regex}~", $file, $m ) )
+                       if ( preg_match( "~{$regex}~", $file, $m ) ) {
                                return false;
+                       }
                }
                return true;
        }
@@ -328,14 +330,15 @@ class CheckSyntax extends Maintenance {
        private function checkForMistakes( $file ) {
                foreach ( $this->mNoStyleCheckPaths as $regex ) {
                        $m = array();
-                       if ( preg_match( "~{$regex}~", $file, $m ) )
+                       if ( preg_match( "~{$regex}~", $file, $m ) ) {
                                return;
+                       }
                }
 
                $text = file_get_contents( $file );
                $tokens = token_get_all( $text );
 
-               $this->checkEvilToken( $file, $tokens, '@', 'Error supression operator (@)');
+               $this->checkEvilToken( $file, $tokens, '@', 'Error supression operator (@)' );
                $this->checkRegex( $file, $text, '/^[\s\r\n]+<\?/', 'leading whitespace' );
                $this->checkRegex( $file, $text, '/\?>[\s\r\n]*$/', 'trailing ?>' );
                $this->checkRegex( $file, $text, '/^[\xFF\xFE\xEF]/', 'byte-order mark' );
index dbc2e0d..87f14d0 100644 (file)
@@ -38,7 +38,7 @@ class CleanupAncientTables extends Maintenance {
        }
 
        public function execute() {
-               if( !$this->hasOption( 'force' ) ) {
+               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"
@@ -61,7 +61,7 @@ class CleanupAncientTables extends Maintenance {
                        'validate', // 1.6
                );
 
-               foreach( $ancientTables as $table ) {
+               foreach ( $ancientTables as $table ) {
                        if ( $db->tableExists( $table, __METHOD__ ) ) {
                                $this->output( "Dropping table $table..." );
                                $db->dropTable( $table, __METHOD__ );
@@ -78,7 +78,7 @@ class CleanupAncientTables extends Maintenance {
                        'user_timestamp',
                        'usertext_timestamp',
                );
-               foreach( $oldIndexes as $index ) {
+               foreach ( $oldIndexes as $index ) {
                        if ( $db->indexExists( 'text', $index, __METHOD__ ) ) {
                                $this->output( "Dropping index $index from the text table..." );
                                $db->query( "DROP INDEX " . $db->addIdentifierQuotes( $index )
@@ -97,7 +97,7 @@ class CleanupAncientTables extends Maintenance {
                        'old_minor_edit',
                        'inverse_timestamp',
                );
-               foreach( $oldFields as $field ) {
+               foreach ( $oldFields as $field ) {
                        if ( $db->fieldExists( 'text', $field, __METHOD__ ) ) {
                                $this->output( "Dropping the $field field from the text table..." );
                                $db->query( "ALTER TABLE  " . $db->tableName( 'text' )
index c0a526b..58c87e5 100644 (file)
@@ -36,7 +36,7 @@ class CleanupPreferences extends Maintenance {
 
                $dbw = wfGetDB( DB_MASTER );
                $dbw->begin( __METHOD__ );
-               foreach( $wgHiddenPrefs as $item ) {
+               foreach ( $wgHiddenPrefs as $item ) {
                        $dbw->delete(
                                'user_properties',
                                array( 'up_property' => $item ),
index 2085da9..700ae1a 100644 (file)
@@ -58,7 +58,7 @@ class CleanupRemovedModules extends Maintenance {
                        $this->output( "Batch $i: $numRows rows\n" );
                        $i++;
                        wfWaitForSlaves( $maxlag );
-               } while( $numRows > 0 );
+               } while ( $numRows > 0 );
                $this->output( "done\n" );
 
                $this->output( "Cleaning up msg_resource table...\n" );
@@ -72,7 +72,7 @@ class CleanupRemovedModules extends Maintenance {
                        $this->output( "Batch $i: $numRows rows\n" );
                        $i++;
                        wfWaitForSlaves( $maxlag );
-               } while( $numRows > 0 );
+               } while ( $numRows > 0 );
                $this->output( "done\n" );
 
                $this->output( "Cleaning up msg_resource_links table...\n" );
@@ -85,7 +85,7 @@ class CleanupRemovedModules extends Maintenance {
                        $this->output( "Batch $i: $numRows rows\n" );
                        $i++;
                        wfWaitForSlaves( $maxlag );
-               } while( $numRows > 0 );
+               } while ( $numRows > 0 );
                $this->output( "done\n" );
        }
 }
index 66f9e87..cbbd5d9 100644 (file)
@@ -83,8 +83,12 @@ class TitleCleanup extends TableCleanup {
                $legalized = preg_replace_callback( "!([^$legal])!",
                        array( &$this, 'hexChar' ),
                        $row->page_title );
-               if ( $legalized == '.' ) $legalized = '(dot)';
-               if ( $legalized == '_' ) $legalized = '(space)';
+               if ( $legalized == '.' ) {
+                       $legalized = '(dot)';
+               }
+               if ( $legalized == '_' ) {
+                       $legalized = '(space)';
+               }
                $legalized = 'Broken/' . $legalized;
 
                $title = Title::newFromText( $legalized );
@@ -121,7 +125,9 @@ class TitleCleanup extends TableCleanup {
 
                        # Old cleanupTitles could move articles there. See bug 23147.
                        $ns = $row->page_namespace;
-                       if ( $ns < 0 ) $ns = 0;
+                       if ( $ns < 0 ) {
+                               $ns = 0;
+                       }
 
                        $clean = 'Broken/' . $prior;
                        $verified = Title::makeTitleSafe( $ns, $clean );
index 441e8ae..97dee97 100644 (file)
@@ -65,7 +65,7 @@ class UploadStashCleanup extends Maintenance {
                } else {
                        // finish the read before starting writes.
                        $keys = array();
-                       foreach( $res as $row ) {
+                       foreach ( $res as $row ) {
                                array_push( $keys, $row->us_key );
                        }
 
@@ -76,7 +76,7 @@ class UploadStashCleanup extends Maintenance {
                        $stash = new UploadStash( $repo );
 
                        $i = 0;
-                       foreach( $keys as $key ) {
+                       foreach ( $keys as $key ) {
                                $i++;
                                try {
                                        $stash->getFile( $key, true );
@@ -94,7 +94,7 @@ class UploadStashCleanup extends Maintenance {
                }
 
                // Delete all the corresponding thumbnails...
-               $dir      = $tempRepo->getZonePath( 'thumb' );
+               $dir = $tempRepo->getZonePath( 'thumb' );
                $iterator = $tempRepo->getBackend()->getFileList( array( 'dir' => $dir ) );
                $this->output( "Deleting old thumbnails...\n" );
                $i = 0;
@@ -112,7 +112,7 @@ class UploadStashCleanup extends Maintenance {
                $this->output( "$i done\n" );
 
                // Apparently lots of stash files are not registered in the DB...
-               $dir      = $tempRepo->getZonePath( 'public' );
+               $dir = $tempRepo->getZonePath( 'public' );
                $iterator = $tempRepo->getBackend()->getFileList( array( 'dir' => $dir ) );
                $this->output( "Deleting orphaned temp files...\n" );
                if ( strpos( $dir, '/local-temp' ) === false ) { // sanity check
index fbab6a3..c3458dc 100644 (file)
@@ -77,9 +77,9 @@ class WatchlistCleanup extends TableCleanup {
                if ( !$this->dryrun && $this->hasOption( 'fix' ) ) {
                        $dbw = wfGetDB( DB_MASTER );
                        $dbw->delete( 'watchlist', array(
-                               'wl_user'      => $row->wl_user,
+                               'wl_user' => $row->wl_user,
                                'wl_namespace' => $row->wl_namespace,
-                               'wl_title'     => $row->wl_title ),
+                               'wl_title' => $row->wl_title ),
                        __METHOD__ );
                        $this->output( "- removed\n" );
                        return 1;
index 1f3ac1c..b361117 100644 (file)
@@ -55,8 +55,8 @@ class CompareParsers extends DumpIterator {
        }
 
        public function checkOptions() {
-               if ( $this->hasOption('save-failed') ) {
-                       $this->saveFailed = $this->getOption('save-failed');
+               if ( $this->hasOption( 'save-failed' ) ) {
+                       $this->saveFailed = $this->getOption( 'save-failed' );
                }
 
                $this->stripParametersEnabled = $this->hasOption( 'strip-parameters' );
@@ -87,8 +87,9 @@ class CompareParsers extends DumpIterator {
 
        public function conclusions() {
                $this->error( "{$this->failed} failed revisions out of {$this->count}" );
-               if ($this->count > 0)
+               if ( $this->count > 0 ) {
                        $this->output( " (" . ( $this->failed / $this->count ) . "%)\n" );
+               }
        }
 
        function stripParameters( $text ) {
index 5f7b02e..7404b5a 100644 (file)
@@ -82,7 +82,7 @@ This gives a huge speed improvement for very large links tables which are MyISAM
 
                list ( $cur, $links, $links_temp, $links_backup ) = $dbw->tableNamesN( 'cur', 'links', 'links_temp', 'links_backup' );
 
-               if( $dbw->tableExists( 'pagelinks' ) ) {
+               if ( $dbw->tableExists( 'pagelinks' ) ) {
                        $this->output( "...have pagelinks; skipping old links table updates\n" );
                        return;
                }
@@ -183,9 +183,10 @@ This gives a huge speed improvement for very large links tables which are MyISAM
                                        }
                                        $dbw->query( implode( "", $sqlWrite ) );
                                        $totalTuplesInserted += $tuplesAdded;
-                                       if ( $reportLinksConvProgress )
+                                       if ( $reportLinksConvProgress ) {
                                                $this->output( " done. Total $totalTuplesInserted tuples inserted.\n" );
-                                               $this->performanceLog( $fh, $totalTuplesInserted . " " . ( $this->getMicroTime() - $baseTime ) . "\n"  );
+                                               $this->performanceLog( $fh, $totalTuplesInserted . " " . ( $this->getMicroTime() - $baseTime ) . "\n" );
+                                       }
                                }
                        }
                        $this->output( "$totalTuplesInserted valid titles and $numBadLinks invalid titles were processed.\n\n" );
index 792ee6c..d58e9a4 100644 (file)
@@ -42,7 +42,7 @@ class DeleteArchivedFilesImplementation {
                        $group = $row->fa_storage_group;
                        $id = $row->fa_id;
                        $path = $repo->getZonePath( 'deleted' ) . '/' . $repo->getDeletedHashPath( $key ) . $key;
-                       if( isset( $row->fa_sha1 ) ) {
+                       if ( isset( $row->fa_sha1 ) ) {
                                $sha1 = $row->fa_sha1;
                        } else {
                                // old row, populate from key
index 4ab6d1d..7f6764b 100644 (file)
@@ -51,7 +51,7 @@ class DeleteDefaultMessages extends Maintenance {
                        )
                );
 
-               if( $dbr->numRows( $res ) == 0 ) {
+               if ( $dbr->numRows( $res ) == 0 ) {
                        # No more messages left
                        $this->output( "done.\n" );
                        return;
index 3c8c5fd..4ac64ca 100644 (file)
@@ -59,13 +59,15 @@ class DeleteImageCache extends Maintenance {
                $total = $this->getImageCount();
 
                foreach ( $res as $row ) {
-                       if ( $i % $this->report == 0 )
+                       if ( $i % $this->report == 0 ) {
                                $this->output( sprintf( "%s: %13s done (%s)\n", wfWikiID(), "$i/$total", wfPercent( $i / $total * 100 ) ) );
+                       }
                        $md5 = md5( $row->img_name );
                        $wgMemc->delete( wfMemcKey( 'Image', $md5 ) );
 
-                       if ( $sleep != 0 )
+                       if ( $sleep != 0 ) {
                                usleep( $sleep );
+                       }
 
                        ++$i;
                }
index f0da9a8..1eb7262 100644 (file)
@@ -54,8 +54,9 @@ class DeleteOrphanedRevisions extends Maintenance {
 
                # Stash 'em all up for deletion (if needed)
                $revisions = array();
-               foreach ( $res as $row )
+               foreach ( $res as $row ) {
                        $revisions[] = $row->rev_id;
+               }
                $count = count( $revisions );
                $this->output( "found {$count}.\n" );
 
@@ -83,8 +84,9 @@ class DeleteOrphanedRevisions extends Maintenance {
         * @param $dbw DatabaseBase class (needs to be a master)
         */
        private function deleteRevs( $id, &$dbw ) {
-               if ( !is_array( $id ) )
+               if ( !is_array( $id ) ) {
                        $id = array( $id );
+               }
                $dbw->delete( 'revision', array( 'rev_id' => $id ), __METHOD__ );
        }
 }
index da220d6..7d16f8a 100644 (file)
@@ -47,7 +47,9 @@ class DeleteSelfExternals extends Maintenance {
                                . $db->buildLike( $wgServer . '/', $db->anyString() ), $this->mBatchSize );
                        $this->output( "Deleting a batch\n" );
                        $db->query( $q );
-                       if ( !$db->affectedRows() ) return;
+                       if ( !$db->affectedRows() ) {
+                               return;
+                       }
                }
        }
 }
index 1d5070b..d277e57 100644 (file)
@@ -25,8 +25,8 @@ if ( PHP_SAPI != 'cli-server' ) {
        die( "This script can only be run by php's cli-server sapi." );
 }
 
-ini_set('display_errors', 1);
-error_reporting(E_ALL);
+ini_set( 'display_errors', 1 );
+error_reporting( E_ALL );
 
 if ( isset( $_SERVER["SCRIPT_FILENAME"] ) ) {
        # Known resource, sometimes a script sometimes a file
@@ -83,16 +83,16 @@ if ( $mime ) {
        # This way we can serve things like .svg files that the built-in
        # PHP webserver doesn't understand.
        # ;) Nicely enough we just happen to bundle a mime.types file
-       $f = fopen($file, 'rb');
+       $f = fopen( $file, 'rb' );
        if ( preg_match( '#^text/#', $mime ) ) {
                # Text should have a charset=UTF-8 (php's webserver does this too)
-               header("Content-Type: $mime; charset=UTF-8");
+               header( "Content-Type: $mime; charset=UTF-8" );
        } else {
-               header("Content-Type: $mime");
+               header( "Content-Type: $mime" );
        }
-       header("Content-Length: " . filesize($file));
+       header( "Content-Length: " . filesize( $file ) );
        // Stream that out to the browser
-       fpassthru($f);
+       fpassthru( $f );
        return true;
 }
 
index 210c5a2..2e138e0 100644 (file)
@@ -34,7 +34,7 @@ if ( !defined( 'RUN_MAINTENANCE_IF_MAIN' ) ) {
 // Wasn't included from the file scope, halt execution (probably wanted the class)
 // If a class is using commandLine.inc (old school maintenance), they definitely
 // cannot be included and will proceed with execution
-if( !Maintenance::shouldExecute() && $maintClass != 'CommandLineInc' ) {
+if ( !Maintenance::shouldExecute() && $maintClass != 'CommandLineInc' ) {
        return;
 }
 
@@ -100,8 +100,9 @@ if ( $maintenance->getDbType() === Maintenance::DB_ADMIN &&
 }
 
 if ( $maintenance->getDbType() === Maintenance::DB_NONE ) {
-       if ( $wgLocalisationCacheConf['storeClass'] === false && ( $wgLocalisationCacheConf['store'] == 'db' || ( $wgLocalisationCacheConf['store'] == 'detect' && !$wgCacheDirectory ) ) )
+       if ( $wgLocalisationCacheConf['storeClass'] === false && ( $wgLocalisationCacheConf['store'] == 'db' || ( $wgLocalisationCacheConf['store'] == 'detect' && !$wgCacheDirectory ) ) ) {
                $wgLocalisationCacheConf['storeClass'] = 'LCStore_Null';
+       }
 }
 $maintenance->finalSetup();
 // Some last includes
index c9546c6..8c35023 100644 (file)
@@ -27,7 +27,7 @@
 
 $originalDir = getcwd();
 
-$optionsWithArgs = array( 'pagelist', 'start', 'end', 'revstart', 'revend');
+$optionsWithArgs = array( 'pagelist', 'start', 'end', 'revstart', 'revend' );
 
 require_once( __DIR__ . '/commandLine.inc' );
 require_once( __DIR__ . '/backup.inc' );
index 9e61bd4..2b3417a 100644 (file)
@@ -47,13 +47,13 @@ abstract class DumpIterator extends Maintenance {
        }
 
        public function execute() {
-               if ( !( $this->hasOption('file') ^ $this->hasOption('dump') ) ) {
-                       $this->error("You must provide a file or dump", true);
+               if ( !( $this->hasOption( 'file' ) ^ $this->hasOption( 'dump' ) ) ) {
+                       $this->error( "You must provide a file or dump", true );
                }
 
                $this->checkOptions();
 
-               if ( $this->hasOption('file') ) {
+               if ( $this->hasOption( 'file' ) ) {
                        $revision = new WikiRevision;
 
                        $revision->setText( file_get_contents( $this->getOption( 'file' ) ) );
@@ -64,10 +64,10 @@ abstract class DumpIterator extends Maintenance {
 
                $this->startTime = microtime( true );
 
-               if ( $this->getOption('dump') == '-' ) {
+               if ( $this->getOption( 'dump' ) == '-' ) {
                        $source = new ImportStreamSource( $this->getStdin() );
                } else {
-                       $this->error("Sorry, I don't support dump filenames yet. Use - and provide it on stdin on the meantime.", true);
+                       $this->error( "Sorry, I don't support dump filenames yet. Use - and provide it on stdin on the meantime.", true );
                }
                $importer = new WikiImporter( $source );
 
@@ -82,8 +82,9 @@ abstract class DumpIterator extends Maintenance {
 
                $delta = microtime( true ) - $this->startTime;
                $this->error( "Done {$this->count} revisions in " . round($delta, 2) . " seconds " );
-               if ($delta > 0)
+               if ( $delta > 0 ) {
                        $this->error( round($this->count / $delta, 2) . " pages/sec" );
+               }
 
                # Perform the memory_get_peak_usage() when all the other data has been output so there's no damage if it dies.
                # It is only available since 5.2.0 (since 5.2.1 if you haven't compiled with --enable-memory-limit)
@@ -122,8 +123,9 @@ abstract class DumpIterator extends Maintenance {
 
                $this->count++;
                if ( isset( $this->from ) ) {
-                       if ( $this->from != $title )
+                       if ( $this->from != $title ) {
                                return;
+                       }
                        $this->output( "Skipped " . ($this->count - 1) . " pages\n" );
 
                        $this->count = 1;
index 7dfbec1..7760beb 100644 (file)
@@ -69,8 +69,9 @@ class DumpLinks extends Maintenance {
                        $link = Title::makeTitle( $row->pl_namespace, $row->pl_title );
                        $this->output( " " . $link->getPrefixedURL() );
                }
-               if ( isset( $lastPage ) )
+               if ( isset( $lastPage ) ) {
                        $this->output( "\n" );
+               }
        }
 }
 
index 1eecfe4..1ddb9ad 100644 (file)
@@ -43,8 +43,9 @@ class DumpSisterSites extends Maintenance {
                $dbr->bufferResults( false );
                $result = $dbr->select( 'page',
                        array( 'page_namespace', 'page_title' ),
-                       array( 'page_namespace'   => NS_MAIN,
-                                  'page_is_redirect' => 0,
+                       array(
+                               'page_namespace' => NS_MAIN,
+                               'page_is_redirect' => 0,
                        ),
                        __METHOD__ );
 
index a705bcc..f166c43 100644 (file)
@@ -45,7 +45,7 @@ class FetchText extends Maintenance {
         *
         * note that that the text string itself is *not* followed by newline
         */
-        public function execute() {
+       public function execute() {
                $db = wfGetDB( DB_SLAVE );
                $stdin = $this->getStdin();
                while ( !feof( $stdin ) ) {
index ab7603d..2e8622b 100644 (file)
@@ -106,10 +106,10 @@ class FixSlaveDesync extends Maintenance {
                        $db = wfGetDB( $i );
                        /*
                        if ( !$db->masterPosWait( $masterFile, $masterPos, 10 ) ) {
-                                  $this->output( "Slave is too lagged, aborting\n" );
-                                  $dbw->commit( __METHOD__ );
-                                  sleep(10);
-                                  return;
+                               $this->output( "Slave is too lagged, aborting\n" );
+                               $dbw->commit( __METHOD__ );
+                               sleep(10);
+                               return;
                        }*/
                        $latest = $db->selectField( 'page', 'page_latest', array( 'page_id' => $pageID ), __METHOD__ );
                        $max = $db->selectField( 'revision', 'MAX(rev_id)', false, __METHOD__ );
index adea97e..44867d0 100644 (file)
@@ -167,7 +167,7 @@ class GenerateSitemap extends Maintenance {
                }
                $this->identifier = $this->getOption( 'identifier', wfWikiID() );
                $this->compress = $this->getOption( 'compress', 'yes' ) !== 'no';
-               $this->skipRedirects = $this->getOption( 'skip-redirects', false ) !== false ;
+               $this->skipRedirects = $this->getOption( 'skip-redirects', false ) !== false;
                $this->dbr = wfGetDB( DB_SLAVE );
                $this->generateNamespaces();
                $this->timestamp = wfTimestamp( TS_ISO_8601, wfTimestampNow() );
@@ -231,7 +231,7 @@ class GenerateSitemap extends Maintenance {
                        wfMkdirParents( $fspath, null, __METHOD__ ) or die( "Can not create directory $fspath.\n" );
                }
 
-               return realpath( $fspath ) . DIRECTORY_SEPARATOR ;
+               return realpath( $fspath ) . DIRECTORY_SEPARATOR;
        }
 
        /**
@@ -255,8 +255,9 @@ class GenerateSitemap extends Maintenance {
                        )
                );
 
-               foreach ( $res as $row )
+               foreach ( $res as $row ) {
                        $this->namespaces[] = $row->page_namespace;
+               }
        }
 
        /**
@@ -346,7 +347,9 @@ class GenerateSitemap extends Maintenance {
                                if ( $wgContLang->hasVariants() ) {
                                        $variants = $wgContLang->getVariants();
                                        foreach ( $variants as $vCode ) {
-                                               if ( $vCode == $wgContLang->getCode() ) continue; // we don't want default variant
+                                               if ( $vCode == $wgContLang->getCode() ) {
+                                                       continue; // we don't want default variant
+                                               }
                                                $entry = $this->fileEntry( $title->getCanonicalURL( '', $vCode ), $date, $this->priority( $namespace ) );
                                                $length += strlen( $entry );
                                                $this->write( $this->file, $entry );
@@ -374,7 +377,7 @@ class GenerateSitemap extends Maintenance {
         */
        function open( $file, $flags ) {
                $resource = $this->compress ? gzopen( $file, $flags ) : fopen( $file, $flags );
-               if( $resource === false ) {
+               if ( $resource === false ) {
                        wfDebugDieBacktrace( __METHOD__ . " error opening file $file with flags $flags. Check permissions?" );
                }
                return $resource;
@@ -384,23 +387,25 @@ class GenerateSitemap extends Maintenance {
         * gzwrite() / fwrite() wrapper
         */
        function write( &$handle, $str ) {
-               if( $handle === true || $handle === false ) {
+               if ( $handle === true || $handle === false ) {
                        wfDebugDieBacktrace( __METHOD__ . " was passed a boolean as a file handle.\n" );
                }
-               if ( $this->compress )
+               if ( $this->compress ) {
                        gzwrite( $handle, $str );
-               else
+               } else {
                        fwrite( $handle, $str );
+               }
        }
 
        /**
         * gzclose() / fclose() wrapper
         */
        function close( &$handle ) {
-               if ( $this->compress )
+               if ( $this->compress ) {
                        gzclose( $handle );
-               else
+               } else {
                        fclose( $handle );
+               }
        }
 
        /**
index 72b1d48..68be9f1 100644 (file)
@@ -39,7 +39,7 @@ class GetLagTimes extends Maintenance {
 
                if ( $lb->getServerCount() == 1 ) {
                        $this->error( "This script dumps replication lag times, but you don't seem to have\n"
-                                                 . "a multi-host db server configuration." );
+                               . "a multi-host db server configuration." );
                } else {
                        $lags = $lb->getLagTimes();
                        foreach ( $lags as $n => $lag ) {
index 9553a1f..beadb90 100644 (file)
@@ -34,16 +34,16 @@ require_once( __DIR__ . '/Maintenance.php' );
 class BackupReader extends Maintenance {
        public $reportingInterval = 100;
        public $pageCount = 0;
-       public $revCount  = 0;
-       public $dryRun    = false;
-       public $uploads   = false;
+       public $revCount = 0;
+       public $dryRun = false;
+       public $uploads = false;
        public $imageBasePath = false;
-       public $nsFilter  = false;
+       public $nsFilter = false;
 
        function __construct() {
                parent::__construct();
-               $gz = in_array('compress.zlib', stream_get_wrappers()) ? 'ok' : '(disabled; requires PHP zlib module)';
-               $bz2 = in_array('compress.bzip2', stream_get_wrappers()) ? 'ok' : '(disabled; requires PHP bzip2 module)';
+               $gz = in_array( 'compress.zlib', stream_get_wrappers() ) ? 'ok' : '(disabled; requires PHP zlib module)';
+               $bz2 = in_array( 'compress.bzip2', stream_get_wrappers() ) ? 'ok' : '(disabled; requires PHP bzip2 module)';
 
                $this->mDescription = <<<TEXT
 This script reads pages from an XML file as produced from Special:Export or
@@ -73,7 +73,7 @@ TEXT;
        }
 
        public function execute() {
-               if( wfReadOnly() ) {
+               if ( wfReadOnly() ) {
                        $this->error( "Wiki is in read-only mode; you'll need to disable it for import to work.", true );
                }
 
@@ -91,7 +91,7 @@ TEXT;
                        $this->setNsfilter( explode( '|', $this->getOption( 'namespaces' ) ) );
                }
 
-               if( $this->hasArg() ) {
+               if ( $this->hasArg() ) {
                        $this->importFromFile( $this->getArg() );
                } else {
                        $this->importFromStdin();
@@ -247,7 +247,7 @@ TEXT;
 
        function importFromStdin() {
                $file = fopen( 'php://stdin', 'rt' );
-               if( self::posix_isatty( $file ) ) {
+               if ( self::posix_isatty( $file ) ) {
                        $this->maybeHelp( true );
                }
                return $this->importFromHandle( $file );
@@ -259,7 +259,7 @@ TEXT;
                $source = new ImportStreamSource( $handle );
                $importer = new WikiImporter( $source );
 
-               if( $this->hasOption( 'debug' ) ) {
+               if ( $this->hasOption( 'debug' ) ) {
                        $importer->setDebug( true );
                }
                if ( $this->hasOption( 'no-updates' ) ) {
index 2b3d551..5ae6d6b 100644 (file)
@@ -99,7 +99,9 @@ function findAuxFile( $file, $auxExtension, $maxStrip = 1 ) {
                }
 
                $idx = strrpos( $n, '.' );
-               if ( !$idx ) break;
+               if ( !$idx ) {
+                       break;
+               }
 
                $n = substr( $n, 0, $idx );
                $maxStrip -= 1;
index 9d9a77d..abc1b87 100644 (file)
@@ -185,10 +185,11 @@ if ( $count > 0 ) {
                if ( isset( $options['source-wiki-url'] ) ) {
                        /* find comment text directly from source wiki, through MW's API */
                        $real_comment = getFileCommentFromSourceWiki( $options['source-wiki-url'], $base );
-                       if ( $real_comment === false )
+                       if ( $real_comment === false ) {
                                $commentText = $comment;
-                       else
+                       } else {
                                $commentText = $real_comment;
+                       }
 
                        /* find user directly from source wiki, through MW's API */
                        $real_user = getFileUserFromSourceWiki( $options['source-wiki-url'], $base );
@@ -273,7 +274,7 @@ if ( $count > 0 ) {
 
                                        $cascade = false;
                                        $restrictions = array();
-                                       foreach( $title->getRestrictionTypes() as $type ) {
+                                       foreach ( $title->getRestrictionTypes() as $type ) {
                                                $restrictions[$type] = $protectLevel;
                                        }
 
@@ -304,8 +305,9 @@ if ( $count > 0 ) {
        foreach ( array( 'count' => 'Found', 'limit' => 'Limit', 'ignored' => 'Ignored',
                'added' => 'Added', 'skipped' => 'Skipped', 'overwritten' => 'Overwritten',
                'failed' => 'Failed' ) as $var => $desc ) {
-               if ( $$var > 0 )
+               if ( $$var > 0 ) {
                        echo( "{$desc}: {$$var}\n" );
+               }
        }
 
 } else {
index 1990659..84556b2 100644 (file)
@@ -48,7 +48,7 @@ class InitSiteStats extends Maintenance {
                $edits = $counter->edits();
                $this->output( "{$edits}\nCounting number of articles..." );
 
-               $good  = $counter->articles();
+               $good = $counter->articles();
                $this->output( "{$good}\nCounting total pages..." );
 
                $pages = $counter->pages();
index 242358b..56f9259 100644 (file)
@@ -109,13 +109,13 @@ class CommandLineInstaller extends Maintenance {
                        InstallerOverrides::getCliInstaller( $siteName, $adminName, $this->mOptions );
 
                $status = $installer->doEnvironmentChecks();
-               if( $status->isGood() ) {
+               if ( $status->isGood() ) {
                        $installer->showMessage( 'config-env-good' );
                } else {
                        $installer->showStatusMessage( $status );
                        return;
                }
-               if( !$this->hasOption( 'env-checks' ) ) {
+               if ( !$this->hasOption( 'env-checks' ) ) {
                        $installer->execute();
                        $installer->writeConfigurationFile( $this->getOption( 'confpath', $IP ) );
                }
index 20fb477..e9d8c86 100644 (file)
@@ -1,5 +1,7 @@
 <?php
-if ( !defined( 'MEDIAWIKI' ) ) die();
+if ( !defined( 'MEDIAWIKI' ) ) {
+       die();
+}
 /**
  * Statistic output classes.
  *
@@ -52,9 +54,9 @@ class wikiStatsOutput extends statsOutput {
                echo "'''Note:''' These statistics can be generated by running <code>php maintenance/language/transstat.php</code>.\n\n";
                echo "For additional information on specific languages (the message names, the actual problems, etc.), run <code>php maintenance/language/checkLanguage.php --lang=foo</code>.\n\n";
                echo 'English (en) is excluded because it is the default localization';
-               if( is_array( $wgDummyLanguageCodes ) ) {
+               if ( is_array( $wgDummyLanguageCodes ) ) {
                        $dummyCodes = array();
-                       foreach( $wgDummyLanguageCodes as $dummyCode => $correctCode ) {
+                       foreach ( $wgDummyLanguageCodes as $dummyCode => $correctCode ) {
                                $dummyCodes[] = Language::fetchLanguageName( $dummyCode ) . ' (' . $dummyCode . ')';
                        }
                        echo ', as well as the following languages that are not intended for system message translations, usually because they redirect to other language codes: ' . implode( ', ', $dummyCodes );
@@ -80,7 +82,9 @@ class wikiStatsOutput extends statsOutput {
                        # Weigh reverse with factor 20 so coloring takes effect more quickly as
                        # this option is used solely for reporting 'bad' percentages.
                        $v = $v * 20;
-                       if ( $v > 255 ) $v = 255;
+                       if ( $v > 255 ) {
+                               $v = 255;
+                       }
                        $v = 255 - $v;
                }
                if ( $v < 128 ) {
index 6abf7b4..55e34be 100644 (file)
@@ -82,12 +82,14 @@ if ( $run ) {
        }
        include( $messagesFile );
        $messageExist = isset( $messages );
-       if ( $messageExist )
+       if ( $messageExist ) {
                $wgMessages[$langCode] = $messages;
+       }
        include( $messagesFileC );
        $messageCExist = isset( $messages );
-       if ( $messageCExist )
+       if ( $messageCExist ) {
                $wgMessages[$langCodeC] = $messages;
+       }
        $count = 0;
 
        if ( ( $messageExist ) && ( $messageCExist ) ) {
@@ -126,9 +128,11 @@ if ( $run ) {
                        }
                }
        } else {
-               if ( !$messageExist )
+               if ( !$messageExist ) {
                        echo "There are no messages defined in $langCode.\n";
-               if ( !$messageCExist )
+               }
+               if ( !$messageCExist ) {
                        echo "There are no messages defined in $langCodeC.\n";
+               }
        }
 }
index 3fa8ede..413d650 100644 (file)
@@ -384,7 +384,7 @@ ENDS;
                                                echo "[messages are hidden]\n";
                                        } else {
                                                foreach ( $messages as $key => $value ) {
-                                                       if( !in_array( $check, $this->nonMessageChecks() ) ) {
+                                                       if ( !in_array( $check, $this->nonMessageChecks() ) ) {
                                                                $key = $this->formatKey( $key, $code );
                                                        }
                                                        if ( $this->level == 2 || empty( $value ) ) {
@@ -411,7 +411,7 @@ ENDS;
                        $problems = 0;
                        $detailTextForLangChecks = array();
                        foreach ( $results as $check => $messages ) {
-                               if( in_array( $check, $this->nonMessageChecks() ) ) {
+                               if ( in_array( $check, $this->nonMessageChecks() ) ) {
                                        continue;
                                }
                                $count = count( $messages );
@@ -463,9 +463,9 @@ EOL;
         * @return bool True if there are any results, false if not.
         */
        protected function isEmpty() {
-               foreach( $this->results as $results ) {
-                       foreach( $results as $messages ) {
-                               if( !empty( $messages ) ) {
+               foreach ( $this->results as $results ) {
+                       foreach ( $results as $messages ) {
+                               if ( !empty( $messages ) ) {
                                        return false;
                                }
                        }
@@ -645,15 +645,15 @@ ENDS;
         * @throws MWException
         */
        protected function checkLanguage( $code ) {
-               foreach( $this->extensions as $extension ) {
+               foreach ( $this->extensions as $extension ) {
                        $this->L = $extension;
                        $this->results = array();
                        $this->results[$code] = parent::checkLanguage( $code );
 
-                       if( !$this->isEmpty() ) {
+                       if ( !$this->isEmpty() ) {
                                echo $extension->name() . ":\n";
 
-                               if( $this->level > 0 ) {
+                               if ( $this->level > 0 ) {
                                        switch( $this->output ) {
                                                case 'plain':
                                                        $this->outputText();
index ad29efb..dcace15 100644 (file)
@@ -39,8 +39,9 @@ class LangMemUsage extends Maintenance {
        }
 
        public function execute() {
-               if ( !function_exists( 'memory_get_usage' ) )
+               if ( !function_exists( 'memory_get_usage' ) ) {
                        $this->error( "You must compile PHP with --enable-memory-limit", true );
+               }
 
                $langtool = new languages();
                $memlast = $memstart = memory_get_usage();
index 39083f9..3b9fadf 100644 (file)
@@ -2479,7 +2479,7 @@ $wgMessageStructure = array(
                'javascripttest-pagetext-noframework',
                'javascripttest-pagetext-unknownframework',
                'javascripttest-pagetext-frameworks',
-               'javascripttest-pagetext-skins' ,
+               'javascripttest-pagetext-skins',
                'javascripttest-qunit-name',
                'javascripttest-qunit-intro',
                'javascripttest-qunit-heading',
@@ -3168,16 +3168,16 @@ $wgMessageStructure = array(
                'exif-lightsource-255',
        ),
        'exif-flash' => array(
-               'exif-flash-fired-0' ,
-               'exif-flash-fired-1' ,
-               'exif-flash-return-0' ,
-               'exif-flash-return-2' ,
-               'exif-flash-return-3' ,
-               'exif-flash-mode-1' ,
-               'exif-flash-mode-2' ,
-               'exif-flash-mode-3' ,
-               'exif-flash-function-1' ,
-               'exif-flash-redeye-1' ,
+               'exif-flash-fired-0',
+               'exif-flash-fired-1',
+               'exif-flash-return-0',
+               'exif-flash-return-2',
+               'exif-flash-return-3',
+               'exif-flash-mode-1',
+               'exif-flash-mode-2',
+               'exif-flash-mode-3',
+               'exif-flash-function-1',
+               'exif-flash-redeye-1',
        ),
        'exif-focalplaneresolutionunit' => array(
                'exif-focalplaneresolutionunit-2',
index 17e1b2e..973e9c4 100644 (file)
@@ -50,25 +50,27 @@ class MessageWriter {
                $sortedMessages = $messages[1];
 
                # Write to the file
-               if ( $messagesFolder )
+               if ( $messagesFolder ) {
                        $filename = Language::getFileName( "$messagesFolder/Messages", $code );
-               else
+               } else {
                        $filename = Language::getMessagesFileName( $code );
+               }
 
-               if ( file_exists( $filename ) )
+               if ( file_exists( $filename ) ) {
                        $contents = file_get_contents( $filename );
-               else
+               } else {
                        $contents = '<?php
 $messages = array(
 );
 ';
+               }
 
-               if( strpos( $contents, '$messages' ) !== false ) {
+               if ( strpos( $contents, '$messages' ) !== false ) {
                        $contents = explode( '$messages', $contents );
-                       if( $messagesText == '$messages' . $contents[1] ) {
+                       if ( $messagesText == '$messages' . $contents[1] ) {
                                echo "Generated messages for language $code. Same as the current file.\n";
                        } else {
-                               if( $write ) {
+                               if ( $write ) {
                                        $new = $contents[0];
                                        $new .= $messagesText;
                                        file_put_contents( $filename, $new );
@@ -77,12 +79,13 @@ $messages = array(
                                        echo "Generated messages for language $code. Please run the script again (without the parameter \"dry-run\") to write the array to the file.\n";
                                }
                        }
-                       if( $listUnknown && isset( $sortedMessages['unknown'] ) && !empty( $sortedMessages['unknown'] ) ) {
-                               if ( $removeUnknown )
+                       if ( $listUnknown && isset( $sortedMessages['unknown'] ) && !empty( $sortedMessages['unknown'] ) ) {
+                               if ( $removeUnknown ) {
                                        echo "\nThe following " . count( $sortedMessages['unknown'] ) . " unknown messages have been removed:\n";
-                               else
+                               } else {
                                        echo "\nThere are " . count( $sortedMessages['unknown'] ) . " unknown messages, please check them:\n";
-                               foreach( $sortedMessages['unknown'] as $key => $value ) {
+                               }
+                               foreach ( $sortedMessages['unknown'] as $key => $value ) {
                                        echo "* " . $key . "\n";
                                }
                        }
@@ -117,12 +120,12 @@ $messages = array(
 
                # Sort messages to blocks
                $sortedMessages['unknown'] = $messages;
-               foreach( self::$messageStructure as $blockName => $block ) {
+               foreach ( self::$messageStructure as $blockName => $block ) {
                        /**
                         * @var $block array
                         */
-                       foreach( $block as $key ) {
-                               if( array_key_exists( $key, $sortedMessages['unknown'] ) ) {
+                       foreach ( $block as $key ) {
+                               if ( array_key_exists( $key, $sortedMessages['unknown'] ) ) {
                                        $sortedMessages[$blockName][$key] = $sortedMessages['unknown'][$key];
                                        unset( $sortedMessages['unknown'][$key] );
                                }
@@ -132,13 +135,13 @@ $messages = array(
                # Write all the messages
                $messagesText = "\$messages = array(
 ";
-               foreach( $sortedMessages as $block => $messages ) {
+               foreach ( $sortedMessages as $block => $messages ) {
                        # Skip if it's the block of unknown messages - handle that in the end of file
-                       if( $block == 'unknown' ) {
+                       if ( $block == 'unknown' ) {
                                continue;
                        }
 
-                       if( $ignoredComments ) {
+                       if ( $ignoredComments ) {
                                $ignored = self::$ignoredMessages;
                                $optional = self::$optionalMessages;
                        } else {
@@ -175,10 +178,10 @@ $messages = array(
                $commentArray = array();
 
                # List of keys only
-               foreach( $messages as $key ) {
-                       if( in_array( $key, $ignored ) ) {
+               foreach ( $messages as $key ) {
+                       if ( in_array( $key, $ignored ) ) {
                                $commentArray[$key] = ' # ' . self::$ignoredComment;
-                       } elseif( in_array( $key, $optional ) ) {
+                       } elseif ( in_array( $key, $optional ) ) {
                                $commentArray[$key] = ' # ' . self::$optionalComment;
                        }
                }
@@ -202,13 +205,13 @@ $messages = array(
                $blockText = '';
 
                # Skip the block if it includes no messages
-               if( empty( $messages ) ) {
+               if ( empty( $messages ) ) {
                        return '';
                }
 
                # Format the block comment (if exists); check for multiple lines comments
-               if( !empty( $blockComment ) ) {
-                       if( strpos( $blockComment, "\n" ) === false ) {
+               if ( !empty( $blockComment ) ) {
+                       if ( strpos( $blockComment, "\n" ) === false ) {
                                $blockText .= "$prefix# $blockComment
 ";
                        } else {
@@ -223,7 +226,7 @@ $blockComment
                $maxKeyLength = max( array_map( 'strlen', array_keys( $messages ) ) );
 
                # Format the messages
-               foreach( $messages as $key => $value ) {
+               foreach ( $messages as $key => $value ) {
                        # Add the key name
                        $blockText .= "$prefix'$key'";
 
@@ -241,16 +244,16 @@ $blockComment
                        $single = "'";
                        $double = '"';
 
-                       if( strpos( $value, $single ) === false ) {
+                       if ( strpos( $value, $single ) === false ) {
                                # Nothing ugly, just use '
                                $blockText .= $single . $value . $single;
-                       } elseif( strpos( $value, $double ) === false && !preg_match('/\$[a-zA-Z_\x7f-\xff]/', $value) ) {
+                       } elseif ( strpos( $value, $double ) === false && !preg_match( '/\$[a-zA-Z_\x7f-\xff]/', $value ) ) {
                                # No "-quotes, no variables that need quoting, use "
                                $blockText .= $double . $value . $double;
                        } else {
                                # Something needs quoting, pick the quote which causes less quoting
                                $quote = substr_count( $value, $double ) + substr_count( $value, '$' ) >= substr_count( $value, $single ) ? $single : $double;
-                               if( $quote === $double ) {
+                               if ( $quote === $double ) {
                                        $extra = '$';
                                } else {
                                        $extra = '';
@@ -262,7 +265,7 @@ $blockComment
                        $blockText .= ',';
 
                        # Add comments, if there is any
-                       if( array_key_exists( $key, $messageComments ) ) {
+                       if ( array_key_exists( $key, $messageComments ) ) {
                                $blockText .= $messageComments[$key];
                        }
 
index 6ff8a17..4bed0d4 100644 (file)
@@ -48,7 +48,7 @@ if ( $cache ) {
        $servers = $wgObjectCaches[$cache]['servers'];
 } elseif ( $wgMainCacheType === CACHE_MEMCACHED ) {
        $mcc->set_servers( $wgMemCachedServers );
-} elseif( isset( $wgObjectCaches[$wgMainCacheType]['servers'] ) ) {
+} elseif ( isset( $wgObjectCaches[$wgMainCacheType]['servers'] ) ) {
        $mcc->set_servers( $wgObjectCaches[$wgMainCacheType]['servers'] );
 } else {
        print "MediaWiki isn't configured for Memcached usage\n";
@@ -116,7 +116,9 @@ do {
        $quit = false;
 
        $line = Maintenance::readconsole();
-       if ( $line === false ) exit;
+       if ( $line === false ) {
+               exit;
+       }
 
        $args = explode( ' ', $line );
        $command = array_shift( $args );
index 469feca..91a106b 100644 (file)
@@ -34,7 +34,7 @@ class mcTest extends Maintenance {
        public function __construct() {
                parent::__construct();
                $this->mDescription = "Makes several 'set', 'incr' and 'get' requests on every"
-                                                         . " memcached server and shows a report";
+                       . " memcached server and shows a report";
                $this->addOption( 'i', 'Number of iterations', false, true );
                $this->addOption( 'cache', 'Use servers from this $wgObjectCaches store', false, true );
                $this->addArg( 'server[:port]', 'Memcached server to test, with optional port', false );
@@ -54,7 +54,7 @@ class mcTest extends Maintenance {
                        $servers = array( $this->getArg() );
                } elseif ( $wgMainCacheType === CACHE_MEMCACHED ) {
                        global $wgMemCachedServers;
-                       $servers = $wgMemCachedServers ;
+                       $servers = $wgMemCachedServers;
                } elseif ( isset( $wgObjectCaches[$wgMainCacheType]['servers'] ) ) {
                        $servers = $wgObjectCaches[$wgMainCacheType]['servers'];
                } else {
index fbba977..06cdfb0 100644 (file)
@@ -61,7 +61,7 @@ class MergeMessageFileList extends Maintenance {
                if ( $this->hasOption( 'extensions-dir' ) ) {
                        $extdir = $this->getOption( 'extensions-dir' );
                        $entries = scandir( $extdir );
-                       foreach( $entries as $extname ) {
+                       foreach ( $entries as $extname ) {
                                if ( $extname == '.' || $extname == '..' || !is_dir( "$extdir/$extname" ) ) {
                                        continue;
                                }
index 4fad7a7..6148cc4 100644 (file)
@@ -61,7 +61,7 @@ $doxygenTemplate = $mwPath . 'maintenance/Doxyfile';
 $doxygenInputFilter = "php {$mwPath}maintenance/mwdoc-filter.php";
 
 /** where Phpdoc should output documentation */
-$doxyOutput = $mwPath . 'docs' . DIRECTORY_SEPARATOR ;
+$doxyOutput = $mwPath . 'docs' . DIRECTORY_SEPARATOR;
 
 $doxyVersion = 'master';
 
@@ -122,14 +122,14 @@ function generateConfigFile( $doxygenTemplate, $outputDirectory, $stripFromPath,
        // Replace template placeholders by correct values.
        $replacements = array(
                '{{OUTPUT_DIRECTORY}}' => $outputDirectory,
-               '{{STRIP_FROM_PATH}}'  => $stripFromPath,
-               '{{CURRENT_VERSION}}'  => $currentVersion,
-               '{{INPUT}}'            => $input,
-               '{{EXCLUDE}}'          => $exclude,
+               '{{STRIP_FROM_PATH}}' => $stripFromPath,
+               '{{CURRENT_VERSION}}' => $currentVersion,
+               '{{INPUT}}' => $input,
+               '{{EXCLUDE}}' => $exclude,
                '{{EXCLUDE_PATTERNS}}' => $excludePatterns,
-               '{{HAVE_DOT}}'         => `which dot` ? 'YES' : 'NO',
-               '{{GENERATE_MAN}}'     => $doxyGenerateMan ? 'YES' : 'NO',
-               '{{INPUT_FILTER}}'     => $doxygenInputFilter,
+               '{{HAVE_DOT}}' => `which dot` ? 'YES' : 'NO',
+               '{{GENERATE_MAN}}' => $doxyGenerateMan ? 'YES' : 'NO',
+               '{{INPUT_FILTER}}' => $doxygenInputFilter,
        );
        $tmpCfg = str_replace( array_keys( $replacements ), array_values( $replacements ), $template );
        $tmpFileName = tempnam( wfTempDir(), 'mwdocgen-' );
@@ -147,11 +147,21 @@ unset( $file );
 if ( is_array( $argv ) ) {
        for ($i = 0; $i < count($argv); $i++ ) {
                switch( $argv[$i] ) {
-               case '--all':         $input = 0; break;
-               case '--includes':    $input = 1; break;
-               case '--languages':   $input = 2; break;
-               case '--maintenance': $input = 3; break;
-               case '--skins':       $input = 4; break;
+               case '--all':
+                       $input = 0;
+                       break;
+               case '--includes':
+                       $input = 1;
+                       break;
+               case '--languages':
+                       $input = 2;
+                       break;
+               case '--maintenance':
+                       $input = 3;
+                       break;
+               case '--skins':
+                       $input = 4;
+                       break;
                case '--file':
                        $input = 5;
                        $i++;
@@ -159,7 +169,9 @@ if ( is_array( $argv ) ) {
                                $file = $argv[$i];
                        }
                        break;
-               case '--no-extensions': $input = 6; break;
+               case '--no-extensions':
+                       $input = 6;
+                       break;
                case '--output':
                        $i++;
                        if ( isset( $argv[$i] ) ) {
@@ -217,8 +229,7 @@ Several documentation possibilities:
  5 : only a given file
  6 : all but the extensions directory
 OPTIONS;
-       while ( !is_numeric( $input ) )
-       {
+       while ( !is_numeric( $input ) ) {
                $input = readaline( "\nEnter your choice [0]:" );
                if ( $input == '' ) {
                        $input = 0;
@@ -227,11 +238,21 @@ OPTIONS;
 }
 
 switch ( $input ) {
-case 0: $input = $mwPath;  break;
-case 1: $input = $mwPathI; break;
-case 2: $input = $mwPathL; break;
-case 3: $input = $mwPathM; break;
-case 4: $input = $mwPathS; break;
+case 0:
+       $input = $mwPath;
+       break;
+case 1:
+       $input = $mwPathI;
+       break;
+case 2:
+       $input = $mwPathL;
+       break;
+case 3:
+       $input = $mwPathM;
+       break;
+case 4:
+       $input = $mwPathS;
+       break;
 case 5:
        if ( !isset( $file ) ) {
                $file = readaline( "Enter file name $mwPath" );
index 6067a82..c111b3b 100644 (file)
@@ -207,10 +207,10 @@ class NamespaceConflictChecker extends Maintenance {
         * @return array
         */
        private function getConflicts( $ns, $name ) {
-               $page  = 'page';
+               $page = 'page';
                $table = $this->db->tableName( $page );
 
-               $prefix     = $this->db->strencode( $name );
+               $prefix = $this->db->strencode( $name );
                $encNamespace = $this->db->addQuotes( $ns );
 
                $titleSql = "TRIM(LEADING '$prefix:' FROM {$page}_title)";
@@ -318,12 +318,12 @@ class NamespaceConflictChecker extends Maintenance {
                $this->db->update( $table,
                        array(
                                "{$prefix}_namespace" => $newTitle->getNamespace(),
-                               "{$prefix}_title"     => $newTitle->getDBkey(),
+                               "{$prefix}_title" => $newTitle->getDBkey(),
                        ),
                        array(
                                // "{$prefix}_namespace" => 0,
-                               // "{$prefix}_title"     => $row->oldtitle,
-                               "{$prefix}_id"           => $row->id,
+                               // "{$prefix}_title" => $row->oldtitle,
+                               "{$prefix}_id" => $row->id,
                        ),
                        __METHOD__ );
                $this->output( "ok.\n" );
index c471a44..e18f362 100644 (file)
@@ -66,7 +66,7 @@ class NukeNS extends Maintenance {
                foreach ( $res as $row ) {
                        // echo "$ns_name:".$row->page_title, "\n";
                        $title = Title::makeTitle( $ns, $row->page_title );
-                       $id   = $title->getArticleID();
+                       $id = $title->getArticleID();
 
                        // Get corresponding revisions
                        $res2 = $dbw->query( "SELECT rev_id FROM $tbl_rev WHERE rev_page = $id" );
@@ -94,7 +94,7 @@ class NukeNS extends Maintenance {
                                        $n_deleted ++;
                                }
                        } else {
-                         $this->output( "skip: " . $title->getPrefixedText() . "\n" );
+                               $this->output( "skip: " . $title->getPrefixedText() . "\n" );
                        }
                }
                $dbw->commit( __METHOD__ );
index 89dffe0..bca3237 100644 (file)
@@ -54,7 +54,7 @@ class NukePage extends Maintenance {
                $this->output( "Searching for \"$name\"..." );
                $title = Title::newFromText( $name );
                if ( $title ) {
-                       $id   = $title->getArticleID();
+                       $id = $title->getArticleID();
                        $real = $title->getPrefixedText();
                        $isGoodArticle = $title->isContentPage();
                        $this->output( "found \"$real\" with ID $id.\n" );
index a46c5e1..47f5ff7 100644 (file)
@@ -53,7 +53,7 @@ class AlterSharedConstraints extends Maintenance {
                        if ( $wgSharedPrefix != null ) {
                                $ltable = preg_replace( "/^$wgSharedPrefix(.*)/i", "$wgDBprefix\\1", $stable );
                        } else {
-                               $ltable = "{$wgDBprefix}{$stable}" ;
+                               $ltable = "{$wgDBprefix}{$stable}";
                        }
 
                        $result = $dbw->query( "SELECT uc.constraint_name, uc.table_name, ucc.column_name, uccpk.table_name pk_table_name, uccpk.column_name pk_column_name, uc.delete_rule, uc.deferrable, uc.deferred
index 3b1a9b0..bae0b88 100644 (file)
@@ -171,7 +171,7 @@ class Orphans extends Maintenance {
         */
        private function checkSeparation( $fix ) {
                $dbw = wfGetDB( DB_MASTER );
-               $page     = $dbw->tableName( 'page' );
+               $page = $dbw->tableName( 'page' );
                $revision = $dbw->tableName( 'revision' );
 
                if ( $fix ) {
@@ -209,7 +209,7 @@ class Orphans extends Maintenance {
                                                        'revision',
                                                        'rev_id',
                                                        array(
-                                                               'rev_page'      => $row->page_id,
+                                                               'rev_page' => $row->page_id,
                                                                'rev_timestamp' => $row2->max_timestamp ) );
                                                $this->output( "... updating to revision $maxId\n" );
                                                $maxRev = Revision::newFromId( $maxId );
index 8ca9fbb..14976c9 100644 (file)
@@ -85,10 +85,10 @@ class CLIParser extends Maintenance {
         */
        protected function Wikitext() {
 
-               $php_stdin  = 'php://stdin';
+               $php_stdin = 'php://stdin';
                $input_file = $this->getArg( 0, $php_stdin );
 
-               if( $input_file === $php_stdin ) {
+               if ( $input_file === $php_stdin ) {
                        $ctrl = wfIsWindows() ? 'CTRL+Z' : 'CTRL+D';
                        $this->error( basename(__FILE__) . ": warning: reading wikitext from STDIN. Press $ctrl to parse.\n" );
                }
@@ -113,7 +113,7 @@ class CLIParser extends Maintenance {
                $title =
                        $this->getOption( 'title' )
                        ? $this->getOption( 'title' )
-                       : 'CLIParser' ;
+                       : 'CLIParser';
                return Title::newFromText( $title );
        }
 
index 27e692d..3a02d71 100644 (file)
@@ -86,7 +86,7 @@ class PopulateFilearchiveSha1 extends LoggedUpdateMaintenance {
                        }
 
                        $done += $i;
-                       if( $i !== $batchSize ) {
+                       if ( $i !== $batchSize ) {
                                break;
                        }
 
@@ -94,7 +94,7 @@ class PopulateFilearchiveSha1 extends LoggedUpdateMaintenance {
                        $this->output( sprintf(
                                "id %d done (up to %d), %5.3f%%  \r", $lastId, $endId, $lastId / $endId * 100 ) );
                        wfWaitForSlaves();
-               } while( true );
+               } while ( true );
 
                $processingTime = microtime( true ) - $startTime;
                $this->output( sprintf( "\nDone %d files in %.1f seconds\n", $done, $processingTime ) );
index 99d8155..c372891 100644 (file)
@@ -75,7 +75,9 @@ class PopulateLogSearch extends LoggedUpdateMaintenance {
                                if ( LogEventsList::typeAction( $row, $delTypes, 'revision' ) ) {
                                        $params = LogPage::extractParams( $row->log_params );
                                        // Param format: <urlparam> <item CSV> [<ofield> <nfield>]
-                                       if ( count( $params ) < 2 ) continue; // bad row?
+                                       if ( count( $params ) < 2 ) {
+                                               continue; // bad row?
+                                       }
                                        $field = RevisionDeleter::getRelationType( $params[0] );
                                        // B/C, the params may start with a title key (<title> <urlparam> <CSV>)
                                        if ( $field == null ) {
@@ -97,8 +99,9 @@ class PopulateLogSearch extends LoggedUpdateMaintenance {
                                        $log->addRelations( $field, $items, $row->log_id );
                                        // Determine what table to query...
                                        $prefix = substr( $field, 0, strpos( $field, '_' ) ); // db prefix
-                                       if ( !isset( self::$tableMap[$prefix] ) )
+                                       if ( !isset( self::$tableMap[$prefix] ) ) {
                                                continue; // bad row?
+                                       }
                                        $table = self::$tableMap[$prefix];
                                        $userField = $prefix . '_user';
                                        $userTextField = $prefix . '_user_text';
@@ -109,10 +112,11 @@ class PopulateLogSearch extends LoggedUpdateMaintenance {
                                                array( $field => $items )
                                        );
                                        foreach ( $sres as $srow ) {
-                                               if ( $srow->$userField > 0 )
+                                               if ( $srow->$userField > 0 ) {
                                                        $userIds[] = intval( $srow->$userField );
-                                               elseif ( $srow->$userTextField != '' )
+                                               } elseif ( $srow->$userTextField != '' ) {
                                                        $userIPs[] = $srow->$userTextField;
+                                               }
                                        }
                                        // Add item author relations...
                                        $log->addRelations( 'target_author_id', $userIds, $row->log_id );
@@ -121,7 +125,9 @@ class PopulateLogSearch extends LoggedUpdateMaintenance {
                                } elseif ( LogEventsList::typeAction( $row, $delTypes, 'event' ) ) {
                                        $params = LogPage::extractParams( $row->log_params );
                                        // Param format: <item CSV> [<ofield> <nfield>]
-                                       if ( count( $params ) < 1 ) continue; // bad row
+                                       if ( count( $params ) < 1 ) {
+                                               continue; // bad row
+                                       }
                                        $items = explode( ',', $params[0] );
                                        $log = new LogPage( $row->log_type );
                                        // Add item relations...
@@ -133,10 +139,11 @@ class PopulateLogSearch extends LoggedUpdateMaintenance {
                                                array( 'log_id' => $items )
                                        );
                                        foreach ( $sres as $srow ) {
-                                               if ( $srow->log_user > 0 )
+                                               if ( $srow->log_user > 0 ) {
                                                        $userIds[] = intval( $srow->log_user );
-                                               elseif ( IP::isIPAddress( $srow->log_user_text ) )
+                                               } elseif ( IP::isIPAddress( $srow->log_user_text ) ) {
                                                        $userIPs[] = $srow->log_user_text;
+                                               }
                                        }
                                        $log->addRelations( 'target_author_id', $userIds, $row->log_id );
                                        $log->addRelations( 'target_author_ip', $userIPs, $row->log_id );
index e81d4ff..c9b7b99 100644 (file)
@@ -98,8 +98,9 @@ class PopulateParentId extends LoggedUpdateMaintenance {
                                        }
                                }
                                $previousID = intval( $previousID );
-                               if ( $previousID != $row->rev_parent_id )
+                               if ( $previousID != $row->rev_parent_id ) {
                                        $changed++;
+                               }
                                # Update the row...
                                $db->update( 'revision',
                                        array( 'rev_parent_id' => $previousID ),
index 1491421..58f4407 100644 (file)
@@ -70,12 +70,16 @@ class PopulateRevisionLength extends LoggedUpdateMaintenance {
                $fields = Revision::selectFields();
                while ( $blockStart <= $end ) {
                        $this->output( "...doing rev_id from $blockStart to $blockEnd\n" );
-                       $res = $db->select( 'revision',
-                                               $fields,
-                                               array( "rev_id >= $blockStart",
-                                                  "rev_id <= $blockEnd",
-                                                  "rev_len IS NULL" ),
-                                               __METHOD__ );
+                       $res = $db->select(
+                               'revision',
+                               $fields,
+                               array(
+                                       "rev_id >= $blockStart",
+                                       "rev_id <= $blockEnd",
+                                       "rev_len IS NULL"
+                               ),
+                               __METHOD__
+                       );
                        # Go through and update rev_len from these rows.
                        foreach ( $res as $row ) {
                                $rev = new Revision( $row );
index bb3d68b..3e46205 100644 (file)
@@ -86,9 +86,8 @@ class PreprocessDump extends DumpIterator {
 
                try {
                        $this->mPreprocessor->preprocessToObj( strval( $content->getNativeData() ), 0 );
-               }
-               catch(Exception $e) {
-                       $this->error("Caught exception " . $e->getMessage() . " in " . $rev->getTitle()->getPrefixedText() );
+               } catch ( Exception $e ) {
+                       $this->error( "Caught exception " . $e->getMessage() . " in " . $rev->getTitle()->getPrefixedText() );
                }
        }
 }
index 49c7aee..0a1a9f6 100644 (file)
@@ -29,7 +29,7 @@ class PPFuzzTester {
        public $hairs = array(
                '[[', ']]', '{{', '{{', '}}', '}}', '{{{', '}}}',
                '<', '>', '<nowiki', '<gallery', '</nowiki>', '</gallery>', '<nOwIkI>', '</NoWiKi>',
-               '<!--' , '-->',
+               '<!--', '-->',
                "\n==", "==\n",
                '|', '=', "\n", ' ', "\t", "\x7f",
                '~~', '~~~', '~~~~', 'subst:',
index ff13bd6..8f4caa8 100644 (file)
@@ -67,7 +67,7 @@ class Protect extends Maintenance {
                }
 
                $restrictions = array();
-               foreach( $t->getRestrictionTypes() as $type ) {
+               foreach ( $t->getRestrictionTypes() as $type ) {
                        $restrictions[$type] = $protection;
                }
 
index 2ccf703..c408dcb 100644 (file)
@@ -21,7 +21,7 @@
  * @ingroup Maintenance
  */
 
-if( PHP_SAPI != 'cli' ) {
+if ( PHP_SAPI != 'cli' ) {
        die( 1 );
 }
 
@@ -42,7 +42,7 @@ if ( ( isset( $_REQUEST ) && array_key_exists( 'argv', $_REQUEST ) ) || count( $
        $ip = $argv[1];
        $port = $argv[2];
        $url = $argv[3];
-       $host = trim(`hostname`);
+       $host = trim( `hostname` );
        $output = "Connecting to $ip:$port, target $url, this hostname $host\n";
 
        # Open socket
index cd62716..c6a6e29 100644 (file)
@@ -53,8 +53,8 @@ class PurgeDeletedFiles extends Maintenance {
 
                $conds = array(
                        'log_namespace' => NS_FILE,
-                       'log_type'      => $logType,
-                       'log_action'    => array( 'delete', 'revision' )
+                       'log_type' => $logType,
+                       'log_action' => array( 'delete', 'revision' )
                );
                $start = $this->getOption( 'starttime' );
                if ( $start ) {
index 0945c9d..52e7fec 100644 (file)
@@ -44,7 +44,7 @@ class PurgeList extends Maintenance {
                if ( $this->hasOption( 'all' ) ) {
                        $this->purgeNamespace( false );
                } elseif ( $this->hasOption( 'namespace' ) ) {
-                       $this->purgeNamespace( intval( $this->getOption( 'namespace') ) );
+                       $this->purgeNamespace( intval( $this->getOption( 'namespace' ) ) );
                } else {
                        $this->doPurge();
                }
@@ -129,7 +129,7 @@ class PurgeList extends Maintenance {
                        }
                } else {
                        if ( $this->hasOption( 'verbose' ) ) {
-                               $this->output( implode( "\n", $urls ) . "\n"  );
+                               $this->output( implode( "\n", $urls ) . "\n" );
                        }
                        $u = new SquidUpdate( $urls );
                        $u->doUpdate();
index 2d79f36..b55a779 100644 (file)
@@ -46,7 +46,7 @@ class ReassignEdits extends Maintenance {
                if ( $this->hasArg( 0 ) && $this->hasArg( 1 ) ) {
                        # Set up the users involved
                        $from = $this->initialiseUser( $this->getArg( 0 ) );
-                       $to   = $this->initialiseUser( $this->getArg( 1 ) );
+                       $to = $this->initialiseUser( $this->getArg( 1 ) );
 
                        # If the target doesn't exist, and --force is not set, stop here
                        if ( $to->getId() || $this->hasOption( 'force' ) ) {
index 3165b97..f3a42c4 100644 (file)
@@ -153,8 +153,9 @@ class RebuildFileCache extends Maintenance {
                $this->output( "Done!\n" );
 
                // Remove these to be safe
-               if ( isset( $wgTitle ) )
+               if ( isset( $wgTitle ) ) {
                        unset( $wgTitle );
+               }
        }
 }
 
index a70e591..dfaae24 100644 (file)
@@ -45,8 +45,9 @@ class RebuildMessages extends Maintenance {
                foreach ( $databases as $db ) {
                        $this->output( "Deleting message cache for {$db}... " );
                        $messageMemc->delete( "{$db}:messages" );
-                       if ( $wgEnableSidebarCache )
+                       if ( $wgEnableSidebarCache ) {
                                $messageMemc->delete( "{$db}:sidebar" );
+                       }
                        $this->output( "Deleted\n" );
                }
        }
index ea2051e..6609531 100644 (file)
@@ -105,7 +105,7 @@ class RebuildRecentchanges extends Maintenance {
 
                # Fill in the rc_last_oldid field, which points to the previous edit
                $sql = "SELECT rc_cur_id,rc_this_oldid,rc_timestamp FROM $recentchanges " .
-                 "ORDER BY rc_cur_id,rc_timestamp";
+                       "ORDER BY rc_cur_id,rc_timestamp";
                $res = $dbw->query( $sql, DB_MASTER );
 
                $lastCurId = 0;
@@ -142,12 +142,12 @@ class RebuildRecentchanges extends Maintenance {
                                $dbw->update( 'recentchanges',
                                        array(
                                                'rc_last_oldid' => $lastOldId,
-                                               'rc_new'        => $new,
-                                               'rc_type'       => $new,
-                                               'rc_old_len'    => $lastSize,
-                                               'rc_new_len'    => $size,
+                                               'rc_new' => $new,
+                                               'rc_type' => $new,
+                                               'rc_old_len' => $lastSize,
+                                               'rc_new_len' => $size,
                                        ), array(
-                                               'rc_cur_id'     => $lastCurId,
+                                               'rc_cur_id' => $lastCurId,
                                                'rc_this_oldid' => $obj->rc_this_oldid,
                                        ),
                                        __METHOD__
index 534b7ca..8ff2b7b 100644 (file)
@@ -147,7 +147,7 @@ class RebuildTextIndex extends Maintenance {
                $searchindex = $this->db->tableName( 'searchindex' );
                $this->output( "\nRebuild the index...\n" );
                $sql = "ALTER TABLE $searchindex ADD FULLTEXT si_title (si_title), " .
-                 "ADD FULLTEXT si_text (si_text)";
+                       "ADD FULLTEXT si_text (si_text)";
                $this->db->query( $sql, __METHOD__ );
        }
 
index 55f5b4a..a53548d 100644 (file)
@@ -151,7 +151,7 @@ class RefreshImageMetadata extends Maintenance {
                        }
                        $conds2 = array( 'img_name > ' . $dbw->addQuotes( $row->img_name ) );
                        wfWaitForSlaves();
-               } while( $res->numRows() === $this->mBatchSize );
+               } while ( $res->numRows() === $this->mBatchSize );
 
                $total = $upgraded + $leftAlone;
                if ( $force ) {
@@ -173,7 +173,7 @@ class RefreshImageMetadata extends Maintenance {
                $like = $this->getOption( 'metadata-contains', false );
 
                if ( $end !== false ) {
-                       $conds[] = 'img_name <= ' . $dbw->addQuotes( $end ) ;
+                       $conds[] = 'img_name <= ' . $dbw->addQuotes( $end );
                }
                if ( $mime !== false ) {
                        list( $major, $minor ) = File::splitMime( $mime );
index 7b25566..e3820f0 100644 (file)
@@ -281,12 +281,13 @@ class RefreshLinks extends Maintenance {
                        $this->output( "Retrieving illegal entries from $table... " );
 
                        // SELECT DISTINCT( $field ) FROM $table LEFT JOIN page ON $field=page_id WHERE page_id IS NULL;
-                       $results = $dbr->select( array( $table, 'page' ),
-                                                 $field,
-                                                 array( 'page_id' => null ),
-                                                 __METHOD__,
-                                                 'DISTINCT',
-                                                 array( 'page' => array( 'LEFT JOIN', "$field=page_id" ) )
+                       $results = $dbr->select(
+                               array( $table, 'page' ),
+                               $field,
+                               array( 'page_id' => null ),
+                               __METHOD__,
+                               'DISTINCT',
+                               array( 'page' => array( 'LEFT JOIN', "$field=page_id" ) )
                        );
 
                        $counter = 0;
index 2ba2b3d..3938915 100644 (file)
@@ -70,8 +70,9 @@ class DumpRenderer extends Maintenance {
 
                $delta = microtime( true ) - $this->startTime;
                $this->error( "Rendered {$this->count} pages in " . round($delta, 2) . " seconds " );
-               if ($delta > 0)
+               if ( $delta > 0 ) {
                        $this->error( round($this->count / $delta, 2) . " pages/sec" );
+               }
                $this->error( "\n" );
        }
 
index e113916..9b1b6e7 100644 (file)
@@ -38,8 +38,9 @@ class BatchedQueryRunner extends Maintenance {
        }
 
        public function execute() {
-               if ( !$this->hasArg() )
+               if ( !$this->hasArg() ) {
                        $this->error( "No query specified. Specify the query as a command line parameter.", true );
+               }
 
                $query = $this->getArg();
                $n = 1;
index 831746d..e7ddfa8 100644 (file)
@@ -44,7 +44,7 @@ class ShowJobs extends Maintenance {
                $group = JobQueueGroup::singleton();
                if ( $this->hasOption( 'group' ) ) {
                        foreach ( $group->getQueueTypes() as $type ) {
-                               $queue   = $group->get( $type );
+                               $queue = $group->get( $type );
                                $pending = $queue->getSize();
                                $claimed = $queue->getAcquiredCount();
                                $abandoned = $queue->getAbandonedCount();
index dbbdab9..11f3a43 100644 (file)
@@ -60,7 +60,7 @@ class ShowSiteStats extends Maintenance {
                $max_length_value = $max_length_desc = 0;
                foreach ( $fields as $field => $desc ) {
                        $max_length_value = max( $max_length_value, strlen( $stats->$field ) );
-                       $max_length_desc  = max( $max_length_desc,  strlen( $desc ) ) ;
+                       $max_length_desc = max( $max_length_desc, strlen( $desc ) );
                }
 
                // Show them
index 1169990..b10a379 100644 (file)
@@ -70,9 +70,9 @@ class MwSql extends Maintenance {
 
                $wholeLine = '';
                $newPrompt = '> ';
-               $prompt    = $newPrompt;
+               $prompt = $newPrompt;
                while ( ( $line = Maintenance::readconsole( $prompt ) ) !== false ) {
-                       if( !$line ) {
+                       if ( !$line ) {
                                # User simply pressed return key
                                continue;
                        }
@@ -94,9 +94,9 @@ class MwSql extends Maintenance {
                        try{
                                $res = $dbw->query( $wholeLine );
                                $this->sqlPrintResult( $res, $dbw );
-                               $prompt    = $newPrompt;
+                               $prompt = $newPrompt;
                                $wholeLine = '';
-                       } catch (DBQueryError $e) {
+                       } catch ( DBQueryError $e ) {
                                $doDie = ! Maintenance::posix_isatty( 0 );
                                $this->error( $e, $doDie );
                        }
index 16568ac..49f4e00 100644 (file)
@@ -73,7 +73,9 @@ class Sqlite {
 
                        $tables = $db->query( "SELECT name FROM sqlite_master WHERE type='table'", __METHOD__ );
                        foreach ( $tables as $table ) {
-                               if ( strpos( $table->name, 'sqlite_' ) === 0 ) continue;
+                               if ( strpos( $table->name, 'sqlite_' ) === 0 ) {
+                                       continue;
+                               }
 
                                $columns = $db->query( "PRAGMA table_info({$table->name})", __METHOD__ );
                                foreach ( $columns as $col ) {
@@ -89,4 +91,4 @@ class Sqlite {
                $db->close();
                return true;
        }
- };
+};
index fd9393f..b9bfe81 100644 (file)
@@ -75,7 +75,7 @@ class CheckStorage {
                        'fixable' => array(),
                );
 
-               for ( $chunkStart = 1 ; $chunkStart < $maxRevId; $chunkStart += $chunkSize ) {
+               for ( $chunkStart = 1; $chunkStart < $maxRevId; $chunkStart += $chunkSize ) {
                        $chunkEnd = $chunkStart + $chunkSize - 1;
                        // print "$chunkStart of $maxRevId\n";
 
index b0cbf28..b766fe9 100644 (file)
@@ -115,7 +115,7 @@ class CompressOld extends Maintenance {
                do {
                        $res = $dbw->select( 'text', array( 'old_id', 'old_flags', 'old_text' ),
                                "old_id>=$start", __METHOD__, array( 'ORDER BY' => 'old_id', 'LIMIT' => $chunksize, 'FOR UPDATE' ) );
-                       if( $res->numRows() == 0 ) {
+                       if ( $res->numRows() == 0 ) {
                                break;
                        }
                        $last = $start;
@@ -126,7 +126,7 @@ class CompressOld extends Maintenance {
                        }
                        $start = $last + 1; # Deletion may leave long empty stretches
                        $this->output( "$start...\n" );
-               } while( true );
+               } while ( true );
        }
 
        /**
@@ -352,13 +352,14 @@ class CompressOld extends Maintenance {
                                                # Move blob objects to External Storage
                                                $stored = $storeObj->store( $extdb, serialize( $chunk ));
                                                if ($stored === false) {
-                                                       $this->error(  "Unable to store object" );
+                                                       $this->error( "Unable to store object" );
                                                        return false;
                                                }
                                                # Store External Storage URLs instead of Stub placeholders
                                                foreach ($stubs as $stub) {
-                                                       if ( $stub === false )
+                                                       if ( $stub === false ) {
                                                                continue;
+                                                       }
                                                        # $stored should provide base path to a BLOB
                                                        $url = $stored . "/" . $stub->getHash();
                                                        $dbw->update( 'text',
index 39f08f9..3fffb82 100644 (file)
@@ -46,7 +46,7 @@ class DumpRev extends Maintenance {
                        $this->error( "Row not found", true );
                }
 
-               $flags = explode( ',',  $row->old_flags );
+               $flags = explode( ',', $row->old_flags );
                $text = $row->old_text;
                if ( in_array( 'external', $flags ) ) {
                        $this->output( "External $text\n" );
index 030a147..2a6d017 100644 (file)
@@ -279,7 +279,7 @@ class RecompressTracked {
         */
        function dispatchToSlave( $slaveId, $args ) {
                $args = (array)$args;
-               $cmd = implode( ' ',  $args );
+               $cmd = implode( ' ', $args );
                fwrite( $this->slavePipes[$slaveId], "$cmd\n" );
        }
 
index ac78484..1030338 100644 (file)
@@ -60,7 +60,7 @@ class UpdateSearchIndex extends Maintenance {
                        # We can safely delete the file when we're done though.
                        $start = file_get_contents( 'searchUpdate.pos' );
                        unlink( 'searchUpdate.pos' );
-               } elseif( is_readable( $posFile ) ) {
+               } elseif ( is_readable( $posFile ) ) {
                        $start = file_get_contents( $posFile );
                } else {
                        $start = wfTimestamp( TS_MW, time() - 86400 );
@@ -97,9 +97,8 @@ class UpdateSearchIndex extends Maintenance {
 
                $page = $dbw->tableName( 'page' );
                $sql = "SELECT rc_cur_id FROM $recentchanges
-                 JOIN $page ON rc_cur_id=page_id AND rc_this_oldid=page_latest
-                 WHERE rc_type != " . RC_LOG . " AND rc_timestamp BETWEEN '$start' AND '$end'
-                 ";
+                       JOIN $page ON rc_cur_id=page_id AND rc_this_oldid=page_latest
+                       WHERE rc_type != " . RC_LOG . " AND rc_timestamp BETWEEN '$start' AND '$end'";
                $res = $dbw->query( $sql, __METHOD__ );
 
                $this->updateSearchIndex( $maxLockTime, array( $this, 'searchIndexUpdateCallback' ), $dbw, $res );
index f92f67a..9c21bb5 100644 (file)
@@ -100,7 +100,7 @@ class UpdateSpecialPages extends Maintenance {
                        }
 
                        if ( !$this->hasOption( 'only' ) || $this->getOption( 'only' ) == $queryPage->getName() ) {
-                               $this->output( sprintf( '%-30s ',  $special ) );
+                               $this->output( sprintf( '%-30s ', $special ) );
                                if ( $queryPage->isExpensive() ) {
                                        $t1 = explode( ' ', microtime() );
                                        # Do the query
index be45a11..6fb29be 100644 (file)
@@ -112,9 +112,9 @@ class UserDupes {
                $count = count( $dupes );
 
                $this->out( "Found $count accounts with duplicate records on " . wfWikiID() . ".\n" );
-               $this->trimmed    = 0;
+               $this->trimmed = 0;
                $this->reassigned = 0;
-               $this->failed     = 0;
+               $this->failed = 0;
                foreach ( $dupes as $name ) {
                        $this->examine( $name, $doDelete );
                }
@@ -223,7 +223,7 @@ class UserDupes {
                        __METHOD__ );
 
                $firstRow = $this->db->fetchObject( $result );
-               $firstId  = $firstRow->user_id;
+               $firstId = $firstRow->user_id;
                $this->out( "Record that will be used for '$name' is user_id=$firstId\n" );
 
                foreach ( $result as $row ) {
index cbe6b05..ddbda49 100644 (file)
@@ -38,7 +38,7 @@ class userOptions {
        public $mOldValue;
        public $mNewValue;
 
-       private $mMode, $mReady ;
+       private $mMode, $mReady;
 
        /** Constructor. Will show usage and exit if script options are not correct */
        function __construct( $opts, $args ) {
@@ -60,9 +60,9 @@ class userOptions {
         */
        private function checkOpts( $opts, $args ) {
                // The three possible ways to run the script:
-               $list   = isset( $opts['list'] );
-               $usage  = isset( $opts['usage'] ) && ( count( $args ) <= 1 );
-               $change = isset( $opts['old'] ) && isset( $opts['new'] ) && ( count( $args ) <= 1 ) ;
+               $list = isset( $opts['list'] );
+               $usage = isset( $opts['usage'] ) && ( count( $args ) <= 1 );
+               $change = isset( $opts['old'] ) && isset( $opts['new'] ) && ( count( $args ) <= 1 );
 
                // We want only one of them
                $isValid = ( ( $list + $usage + $change ) == 1 );
@@ -82,18 +82,18 @@ class userOptions {
 
                $this->mQuick = isset( $opts['nowarn'] );
                $this->mQuiet = isset( $opts['quiet'] );
-               $this->mDry   = isset( $opts['dry'] );
+               $this->mDry = isset( $opts['dry'] );
 
                // Set object properties, specially 'mMode' used by run()
                if ( isset( $opts['list'] ) ) {
-                       $this->mMode = 'LISTER' ;
+                       $this->mMode = 'LISTER';
                } elseif ( isset( $opts['usage'] ) ) {
-                       $this->mMode = 'USAGER' ;
-                       $this->mAnOption = isset( $args[0] ) ? $args[0] : false ;
+                       $this->mMode = 'USAGER';
+                       $this->mAnOption = isset( $args[0] ) ? $args[0] : false;
                } elseif ( isset( $opts['old'] ) && isset( $opts['new'] ) ) {
-                       $this->mMode = 'CHANGER' ;
-                       $this->mOldValue = $opts['old'] ;
-                       $this->mNewValue = $opts['new'] ;
+                       $this->mMode = 'CHANGER';
+                       $this->mOldValue = $opts['old'];
+                       $this->mNewValue = $opts['new'];
                        $this->mAnOption = $args[0];
                } else {
                        die( "There is a bug in the software, this should never happen\n" );
@@ -212,7 +212,9 @@ class userOptions {
                                if ( !$this->mDry ) {
                                        $user->saveSettings();
                                }
-                               if ( !$this->mQuiet ) { print " OK\n"; }
+                               if ( !$this->mQuiet ) {
+                                       print " OK\n";
+                               }
 
                        } elseif ( !$this->mQuiet ) {
                                print "Not changing '$username' using <{$this->mAnOption}> = '$curValue'\n";