Update formatting in maintenance/ (3/4)
authorSiebrand Mazeland <siebrand@kitano.nl>
Wed, 23 Apr 2014 18:09:13 +0000 (20:09 +0200)
committerSiebrand Mazeland <siebrand@kitano.nl>
Wed, 23 Apr 2014 18:09:13 +0000 (20:09 +0200)
Change-Id: I4390c4ea12a6a626b0e6817b6446635116ca9fe3

40 files changed:
maintenance/fixExtLinksProtocolRelative.php
maintenance/fixSlaveDesync.php
maintenance/fixTimestamps.php
maintenance/generateJsonI18n.php
maintenance/generateSitemap.php
maintenance/getConfiguration.php
maintenance/getSlaveServer.php
maintenance/importDump.php
maintenance/importImages.inc
maintenance/importImages.php
maintenance/importSiteScripts.php
maintenance/importTextFile.php
maintenance/install.php
maintenance/jsduck/eg-iframe.html
maintenance/language/StatOutputs.php
maintenance/language/generateCollationData.php
maintenance/language/languages.inc
maintenance/mctest.php
maintenance/mergeMessageFileList.php
maintenance/minify.php
maintenance/mwdocgen.php
maintenance/namespaceDupes.php
maintenance/nukeNS.php
maintenance/oracle/alterSharedConstraints.php
maintenance/orphans.php
maintenance/parse.php
maintenance/populateCategory.php
maintenance/populateFilearchiveSha1.php
maintenance/populateImageSha1.php
maintenance/populateLogSearch.php
maintenance/populateLogUsertext.php
maintenance/populateParentId.php
maintenance/populateRecentChangesSource.php
maintenance/populateRevisionLength.php
maintenance/populateRevisionSha1.php
maintenance/preprocessDump.php
maintenance/preprocessorFuzzTest.php
maintenance/purgeChangedFiles.php
maintenance/purgeChangedPages.php
maintenance/purgeList.php

index 920b2b0..0c60e62 100644 (file)
@@ -50,6 +50,7 @@ class FixExtLinksProtocolRelative extends LoggedUpdateMaintenance {
                $db = wfGetDB( DB_MASTER );
                if ( !$db->tableExists( 'externallinks' ) ) {
                        $this->error( "externallinks table does not exist" );
+
                        return false;
                }
                $this->output( "Fixing protocol-relative entries in the externallinks table...\n" );
@@ -91,6 +92,7 @@ class FixExtLinksProtocolRelative extends LoggedUpdateMaintenance {
                        );
                }
                $this->output( "Done, $count rows updated.\n" );
+
                return true;
        }
 }
index cbb2e9d..a5418ce 100644 (file)
@@ -101,6 +101,7 @@ class FixSlaveDesync extends Maintenance {
                        }
                }
                $this->output( "\n" );
+
                return $desync;
        }
 
@@ -136,6 +137,7 @@ class FixSlaveDesync extends Maintenance {
                if ( !$found ) {
                        $this->output( "page_id $pageID seems fine\n" );
                        $dbw->commit( __METHOD__ );
+
                        return;
                }
 
index f96a917..5431cf2 100644 (file)
@@ -85,11 +85,11 @@ class FixTimestamps extends Maintenance {
                        if ( $sign == 0 || $sign == $expectedSign ) {
                                // Monotonic change
                                $lastNormal = $timestamp;
-                               ++ $numGoodRevs;
+                               ++$numGoodRevs;
                                continue;
                        } elseif ( abs( $delta ) <= $grace ) {
                                // Non-monotonic change within grace interval
-                               ++ $numGoodRevs;
+                               ++$numGoodRevs;
                                continue;
                        } else {
                                // Non-monotonic change larger than grace interval
@@ -100,7 +100,7 @@ class FixTimestamps extends Maintenance {
                $numBadRevs = count( $badRevs );
                if ( $numBadRevs > $numGoodRevs ) {
                        $this->error(
-               "The majority of revisions in the search interval are marked as bad.
+                               "The majority of revisions in the search interval are marked as bad.
 
                Are you sure the offset ($offset) has the right sign? Positive means the clock
                was incorrectly set forward, negative means the clock was incorrectly set back.
index 6c4ff20..7fe3bd9 100644 (file)
@@ -50,6 +50,7 @@ class GenerateJsonI18n extends Maintenance {
 
                if ( $this->hasOption( 'shim-only' ) ) {
                        $this->shimOnly( $phpfile, $jsondir );
+
                        return;
                }
 
@@ -184,6 +185,7 @@ PHP;
                $jsondir = str_replace( '\\', '/', $jsondir );
                $shim = str_replace( '{{OUT}}', $jsondir, $shim );
                $shim = str_replace( '{{FUNC}}', 'wfJsonI18nShim' . wfRandomString( 16 ), $shim );
+
                return $shim;
        }
 
@@ -216,6 +218,7 @@ PHP;
        protected function getAuthorsFromComment( $comment ) {
                $matches = null;
                preg_match_all( '/@author (.*?)$/m', $comment, $matches );
+
                return $matches && $matches[1] ? $matches[1] : array();
        }
 }
index b5681c1..c43851e 100644 (file)
@@ -263,6 +263,7 @@ class GenerateSitemap extends Maintenance {
                global $wgSitemapNamespaces;
                if ( is_array( $wgSitemapNamespaces ) ) {
                        $this->namespaces = $wgSitemapNamespaces;
+
                        return;
                }
 
@@ -343,7 +344,7 @@ class GenerateSitemap extends Maintenance {
 
                        $fns = $wgContLang->getFormattedNsText( $namespace );
                        $this->output( "$namespace ($fns)\n" );
-                       $skippedRedirects = 0;  // Number of redirects skipped for that namespace
+                       $skippedRedirects = 0; // Number of redirects skipped for that namespace
                        foreach ( $res as $row ) {
                                if ( $this->skipRedirects && $row->page_is_redirect ) {
                                        $skippedRedirects++;
@@ -415,6 +416,7 @@ class GenerateSitemap extends Maintenance {
                        throw new MWException( __METHOD__
                                . " error opening file $file with flags $flags. Check permissions?" );
                }
+
                return $resource;
        }
 
@@ -457,6 +459,7 @@ class GenerateSitemap extends Maintenance {
         */
        function sitemapFilename( $namespace, $count ) {
                $ext = $this->compress ? '.gz' : '';
+
                return "sitemap-{$this->identifier}-NS_$namespace-$count.xml$ext";
        }
 
index 52cb209..1db53f3 100644 (file)
@@ -63,7 +63,7 @@ class GetConfiguration extends Maintenance {
                $format = strtolower( $this->getOption( 'format', 'PHP' ) );
 
                $validFormat = in_array( $format, self::$outFormats );
-               if ( ! $validFormat ) {
+               if ( !$validFormat ) {
                        $this->error( "--format set to an unrecognized format", 0 );
                        $error_out = true;
                }
@@ -87,11 +87,11 @@ class GetConfiguration extends Maintenance {
        public function finalSetup() {
                parent::finalSetup();
 
-               $this->regex = $this->getOption( 'regex' ) ?: $this->getOption( 'iregex' );
+               $this->regex = $this->getOption( 'regex' ) ? : $this->getOption( 'iregex' );
                if ( $this->regex ) {
                        $this->regex = '/' . $this->regex . '/';
                        if ( $this->hasOption( 'iregex' ) ) {
-                               $this->regex .= 'i';  # case insensitive regex
+                               $this->regex .= 'i'; # case insensitive regex
                        }
                }
 
@@ -115,7 +115,7 @@ class GetConfiguration extends Maintenance {
                $res = array();
 
                # Sane default: dump any wg / wmg variable
-               if ( ! $this->regex && ! $this->getOption( 'settings' ) ) {
+               if ( !$this->regex && !$this->getOption( 'settings' ) ) {
                        $this->regex = '/^wm?g/';
                }
 
@@ -165,7 +165,7 @@ class GetConfiguration extends Maintenance {
        protected function formatVarDump( $res ) {
                $ret = '';
                foreach ( $res as $key => $value ) {
-                       ob_start();  # intercept var_dump() output
+                       ob_start(); # intercept var_dump() output
                        print "\${$key} = ";
                        var_dump( $value );
                        # grab var_dump() output and discard it from the output buffer
@@ -182,10 +182,12 @@ class GetConfiguration extends Maintenance {
                                        return false;
                                }
                        }
+
                        return true;
                } elseif ( is_scalar( $value ) ) {
                        return true;
                }
+
                return false;
        }
 }
index d618825..68c1943 100644 (file)
@@ -34,6 +34,7 @@ class GetSlaveServer extends Maintenance {
                $this->addOption( "group", "Query group to check specifically" );
                $this->mDescription = "Report the hostname of a slave server";
        }
+
        public function execute() {
                global $wgAllDBsAreLocalhost;
                if ( $wgAllDBsAreLocalhost ) {
index 88e7120..1f7cbf5 100644 (file)
@@ -111,6 +111,7 @@ TEXT;
        function setNsfilter( array $namespaces ) {
                if ( count( $namespaces ) == 0 ) {
                        $this->nsFilter = false;
+
                        return;
                }
                $this->nsFilter = array_unique( array_map( array( $this, 'getNsIndex' ), $namespaces ) );
@@ -143,6 +144,7 @@ TEXT;
                        echo wfBacktrace();
                        $this->error( "Cannot get namespace of object in " . __METHOD__, true );
                }
+
                return is_array( $this->nsFilter ) && !in_array( $ns, $this->nsFilter );
        }
 
@@ -157,6 +159,7 @@ TEXT;
                $title = $rev->getTitle();
                if ( !$title ) {
                        $this->progress( "Got bogus revision with null title!" );
+
                        return;
                }
 
@@ -189,6 +192,7 @@ TEXT;
                                // bluuuh hack
                                // call_user_func( $this->uploadCallback, $revision );
                                $dbw = wfGetDB( DB_MASTER );
+
                                return $dbw->deadlockLoop( array( $revision, 'importUpload' ) );
                        }
                }
@@ -248,6 +252,7 @@ TEXT;
                }
 
                $file = fopen( $filename, 'rt' );
+
                return $this->importFromHandle( $file );
        }
 
@@ -256,6 +261,7 @@ TEXT;
                if ( self::posix_isatty( $file ) ) {
                        $this->maybeHelp( true );
                }
+
                return $this->importFromHandle( $file );
        }
 
index 7caedea..b803e3d 100644 (file)
@@ -46,6 +46,7 @@ function findFiles( $dir, $exts, $recurse = false ) {
                                        $files = array_merge( $files, findFiles( $dir . '/' . $file, $exts, true ) );
                                }
                        }
+
                        return $files;
                } else {
                        return array();
@@ -63,9 +64,10 @@ function findFiles( $dir, $exts, $recurse = false ) {
  */
 function splitFilename( $filename ) {
        $parts = explode( '.', $filename );
-       $ext = $parts[ count( $parts ) - 1 ];
-       unset( $parts[ count( $parts ) - 1 ] );
+       $ext = $parts[count( $parts ) - 1];
+       unset( $parts[count( $parts ) - 1] );
        $fname = implode( '.', $parts );
+
        return array( $fname, $ext );
 }
 
index ba77354..3dd4a9e 100644 (file)
@@ -290,25 +290,24 @@ if ( $count > 0 ) {
                        }
 
                        if ( $doProtect ) {
-                                       # Protect the file
-                                       echo "\nWaiting for slaves...\n";
-                                       // Wait for slaves.
-                                       sleep( 2.0 ); # Why this sleep?
-                                       wfWaitForSlaves();
-
-                                       echo "\nSetting image restrictions ... ";
-
-                                       $cascade = false;
-                                       $restrictions = array();
-                                       foreach ( $title->getRestrictionTypes() as $type ) {
-                                               $restrictions[$type] = $protectLevel;
-                                       }
+                               # Protect the file
+                               echo "\nWaiting for slaves...\n";
+                               // Wait for slaves.
+                               sleep( 2.0 ); # Why this sleep?
+                               wfWaitForSlaves();
+
+                               echo "\nSetting image restrictions ... ";
+
+                               $cascade = false;
+                               $restrictions = array();
+                               foreach ( $title->getRestrictionTypes() as $type ) {
+                                       $restrictions[$type] = $protectLevel;
+                               }
 
-                                       $page = WikiPage::factory( $title );
-                                       $status = $page->doUpdateRestrictions( $restrictions, array(), $cascade, '', $user );
-                                       echo ( $status->isOK() ? 'done' : 'failed' ) . "\n";
+                               $page = WikiPage::factory( $title );
+                               $status = $page->doUpdateRestrictions( $restrictions, array(), $cascade, '', $user );
+                               echo ( $status->isOK() ? 'done' : 'failed' ) . "\n";
                        }
-
                } else {
                        echo "failed. (at recordUpload stage)\n";
                        $svar = 'failed';
@@ -328,14 +327,21 @@ if ( $count > 0 ) {
 
        # Print out some statistics
        echo "\n";
-       foreach ( array( 'count' => 'Found', 'limit' => 'Limit', 'ignored' => 'Ignored',
-               'added' => 'Added', 'skipped' => 'Skipped', 'overwritten' => 'Overwritten',
-               'failed' => 'Failed' ) as $var => $desc ) {
+       foreach (
+               array(
+                       'count' => 'Found',
+                       'limit' => 'Limit',
+                       'ignored' => 'Ignored',
+                       'added' => 'Added',
+                       'skipped' => 'Skipped',
+                       'overwritten' => 'Overwritten',
+                       'failed' => 'Failed'
+               ) as $var => $desc
+       ) {
                if ( $$var > 0 ) {
                        echo "{$desc}: {$$var}\n";
                }
        }
-
 } else {
        echo "No suitable files could be found for import.\n";
 }
index fd768b3..7705ec9 100644 (file)
@@ -65,13 +65,12 @@ class ImportSiteScripts extends Maintenance {
                        $content = ContentHandler::makeContent( $text, $wikiPage->getTitle() );
                        $wikiPage->doEditContent( $content, "Importing from $url", 0, false, $user );
                }
-
        }
 
        protected function fetchScriptList() {
                $data = array(
                        'action' => 'query',
-                       'format' => 'php',//'json',
+                       'format' => 'php', //'json',
                        'list' => 'allpages',
                        'apnamespace' => '8',
                        'aplimit' => '500',
@@ -100,7 +99,6 @@ class ImportSiteScripts extends Maintenance {
                } while ( isset( $result['query-continue'] ) );
 
                return $pages;
-
        }
 }
 
index c7df6c3..f73dd1c 100644 (file)
@@ -60,33 +60,29 @@ if ( count( $args ) < 1 || isset( $options['help'] ) ) {
                                        $content = ContentHandler::makeContent( $text, $title );
                                        $page->doEditContent( $content, $comment, $flags, false, $user );
                                        echo "done.\n";
-
                                } else {
                                        echo "invalid username.\n";
                                }
-
                        } else {
                                echo "page exists.\n";
                        }
-
                } else {
                        echo "invalid title.\n";
                }
-
        } else {
                echo "does not exist.\n";
        }
-
 }
 
 function titleFromFilename( $filename ) {
        $parts = explode( '/', $filename );
-       $parts = explode( '.', $parts[ count( $parts ) - 1 ] );
+       $parts = explode( '.', $parts[count( $parts ) - 1] );
+
        return $parts[0];
 }
 
 function showHelp() {
-print <<<EOF
+       print <<<EOF
 USAGE: php importTextFile.php <options> <filename>
 
 <filename> : Path to the file containing page content to import
index 6fc4782..20d6ad5 100644 (file)
@@ -133,6 +133,7 @@ class CommandLineInstaller extends Maintenance {
                        $installer->showMessage( 'config-env-good' );
                } else {
                        $installer->showStatusMessage( $status );
+
                        return;
                }
                if ( !$this->hasOption( 'env-checks' ) ) {
index 86eae4b..7dc4afa 100644 (file)
@@ -1,88 +1,88 @@
 <!DOCTYPE html>
 <html>
 <head>
-    <meta charset="utf-8">
-    <title>MediaWiki Code Example</title>
-    <script src="modules/startup.js"></script>
-    <script>
-        function startUp() {
-            mw.config = new mw.Map();
-        }
-    </script>
-    <script src="modules/jquery/jquery.js"></script>
-    <script src="modules/mediawiki/mediawiki.js"></script>
-    <style>
-        .mw-jsduck-log {
-            position: relative;
-            min-height: 3em;
-            margin-top: 2em;
-            background: #f7f7f7;
-            border: 1px solid #e4e4e4;
-        }
+       <meta charset="utf-8">
+       <title>MediaWiki Code Example</title>
+       <script src="modules/startup.js"></script>
+       <script>
+               function startUp() {
+                       mw.config = new mw.Map();
+               }
+       </script>
+       <script src="modules/jquery/jquery.js"></script>
+       <script src="modules/mediawiki/mediawiki.js"></script>
+       <style>
+               .mw-jsduck-log {
+                       position: relative;
+                       min-height: 3em;
+                       margin-top: 2em;
+                       background: #f7f7f7;
+                       border: 1px solid #e4e4e4;
+               }
 
-        .mw-jsduck-log::after {
-            position: absolute;
-            bottom: 100%;
-            right: -1px;
-            padding: 0.5em;
-            background: #fff;
-            border: 1px solid #e4e4e4;
-            border-bottom: 0;
-            border-radius: 0.5em 0.5em 0 0;
-            font: normal 0.5em sans-serif;
-            content: 'console';
-        }
+               .mw-jsduck-log::after {
+                       position: absolute;
+                       bottom: 100%;
+                       right: -1px;
+                       padding: 0.5em;
+                       background: #fff;
+                       border: 1px solid #e4e4e4;
+                       border-bottom: 0;
+                       border-radius: 0.5em 0.5em 0 0;
+                       font: normal 0.5em sans-serif;
+                       content: 'console';
+               }
 
-        .mw-jsduck-log-line {
-            padding: 0.2em 0.5em;
-            white-space: pre-wrap;
-        }
+               .mw-jsduck-log-line {
+                       padding: 0.2em 0.5em;
+                       white-space: pre-wrap;
+               }
 
-        .mw-jsduck-log-line:nth-child(odd) {
-            background: #fff;
-        }
-    </style>
+               .mw-jsduck-log-line:nth-child(odd) {
+                       background: #fff;
+               }
+       </style>
 </head>
 <body>
-    <script>
-        /**
-         * Basic log console for the example iframe in documentation pages.
-         */
-        ( function () {
-            var pre;
-            mw.log = function () {
-                var str, i, len, line;
-                if ( !pre ) {
-                    pre = document.createElement( 'pre' );
-                    pre.className = 'mw-jsduck-log';
-                    document.body.appendChild( pre );
-                }
-                str = [];
-                for ( i = 0, len = arguments.length; i < len; i++ ) {
-                    str.push( String( arguments[ i ] ) );
-                }
-                line = document.createElement( 'div' );
-                line.className = 'mw-jsduck-log-line';
-                line.appendChild(
-                    document.createTextNode( str.join( ' , ' ) + '\n' )
-                );
-                pre.appendChild( line );
-            };
-        }() );
+<script>
+       /**
+        * Basic log console for the example iframe in documentation pages.
+        */
+       ( function () {
+               var pre;
+               mw.log = function () {
+                       var str, i, len, line;
+                       if ( !pre ) {
+                               pre = document.createElement( 'pre' );
+                               pre.className = 'mw-jsduck-log';
+                               document.body.appendChild( pre );
+                       }
+                       str = [];
+                       for ( i = 0, len = arguments.length; i < len; i++ ) {
+                               str.push( String( arguments[ i ] ) );
+                       }
+                       line = document.createElement( 'div' );
+                       line.className = 'mw-jsduck-log-line';
+                       line.appendChild(
+                                       document.createTextNode( str.join( ' , ' ) + '\n' )
+                       );
+                       pre.appendChild( line );
+               };
+       }() );
 
-        /**
-         * Method called by jsduck to execute the example code.
-         */
-        function loadInlineExample( code, options, callback ) {
-            try {
-                eval( code );
-                callback && callback( true );
-            } catch (e) {
-                mw.log( 'Uncaught exception: ' + e );
-                callback && callback( false, e );
-                throw e;
-            }
-        }
-    </script>
+       /**
+        * Method called by jsduck to execute the example code.
+        */
+       function loadInlineExample( code, options, callback ) {
+               try {
+                       eval( code );
+                       callback && callback( true );
+               } catch ( e ) {
+                       mw.log( 'Uncaught exception: ' + e );
+                       callback && callback( false, e );
+                       throw e;
+               }
+       }
+</script>
 </body>
 </html>
index f9390f6..31ce702 100644 (file)
@@ -29,6 +29,7 @@ class StatsOutput {
                wfSuppressWarnings();
                $return = sprintf( '%.' . $accuracy . 'f%%', 100 * $subset / $total );
                wfRestoreWarnings();
+
                return $return;
        }
 
index db6c315..2bb5e6b 100644 (file)
@@ -365,7 +365,7 @@ class UcdXmlReader {
                $xml = $this->open();
                $this->callback = $callback;
 
-               while ( $xml->name !== 'repertoire' && $xml->next() );
+               while ( $xml->name !== 'repertoire' && $xml->next() ) ;
 
                while ( $xml->read() ) {
                        if ( $xml->nodeType == XMLReader::ELEMENT ) {
@@ -389,7 +389,7 @@ class UcdXmlReader {
                if ( !$this->xml ) {
                        throw new MWException( __METHOD__ . ": unable to open {$this->fileName}" );
                }
-               while ( $this->xml->name !== 'ucd' && $this->xml->read() );
+               while ( $this->xml->name !== 'ucd' && $this->xml->read() ) ;
                $this->xml->read();
 
                return $this->xml;
@@ -450,7 +450,7 @@ class UcdXmlReader {
                }
 
                $xml = $this->open();
-               while ( $xml->name !== 'blocks' && $xml->read() );
+               while ( $xml->name !== 'blocks' && $xml->read() ) ;
 
                while ( $xml->read() ) {
                        if ( $xml->nodeType == XMLReader::ELEMENT ) {
index cc7b471..6e5b29d 100644 (file)
@@ -28,7 +28,7 @@ class Languages {
        /** @var array List of languages */
        protected $mLanguages;
 
-       /** @var array Raw list of the messages in each language  */
+       /** @var array Raw list of the messages in each language */
        protected $mRawMessages;
 
        /** @var array Messages in each language (except for English), divided to groups */
index 243f97c..da49e55 100644 (file)
@@ -67,7 +67,7 @@ class McTest extends Maintenance {
                foreach ( $servers as $server ) {
                        $this->output(
                                str_pad( $server, $maxSrvLen ),
-                               $server  # output channel
+                               $server # output channel
                        );
 
                        $mcc = new MemCachedClientforWiki( array(
@@ -107,6 +107,7 @@ class McTest extends Maintenance {
         */
        private function microtime_float() {
                list( $usec, $sec ) = explode( " ", microtime() );
+
                return ( (float)$usec + (float)$sec );
        }
 }
index f016a2c..2a6f8a8 100644 (file)
@@ -125,6 +125,7 @@ class MergeMessageFileList extends Maintenance {
                if ( $fileLines === false ) {
                        $this->hasError = true;
                        $this->error( "Unable to open list file $fileName." );
+
                        return $files;
                }
                # Strip comments, discard empty lines, and trim leading and trailing
@@ -142,6 +143,7 @@ class MergeMessageFileList extends Maintenance {
                                }
                        }
                }
+
                return $files;
        }
 }
index ec936c8..efecaad 100644 (file)
@@ -49,7 +49,6 @@ class MinifyScript extends Maintenance {
                $this->mDescription = "Minify a file or set of files.\n\n" .
                        "If --outfile is not specified, then the output file names will have a .min extension\n" .
                        "added, e.g. jquery.js -> jquery.min.js.";
-
        }
 
        public function execute() {
@@ -66,6 +65,7 @@ class MinifyScript extends Maintenance {
 
                        // Minify one file
                        $this->minify( $this->getArg( 0 ), $this->getOption( 'outfile' ) );
+
                        return;
                }
 
@@ -103,6 +103,7 @@ class MinifyScript extends Maintenance {
                        $this->error( "No file extension, cannot determine type: $fileName" );
                        exit( 1 );
                }
+
                return substr( $fileName, $dotPos + 1 );
        }
 
index b22dd88..ee0ff01 100644 (file)
@@ -152,15 +152,13 @@ You might want to delete the temporary file:
 ---------------------------------------------------
 
 TEXT
-       );
+               );
 
                if ( $exitcode !== 0 ) {
                        $this->error( "Something went wrong (exit: $exitcode)\n",
                                $exitcode );
                }
-
        }
-
 }
 
 $maintClass = 'MWDocGen';
index 5fc972c..a152091 100644 (file)
@@ -44,9 +44,9 @@ class NamespaceConflictChecker extends Maintenance {
                $this->mDescription = "";
                $this->addOption( 'fix', 'Attempt to automatically fix errors' );
                $this->addOption( 'suffix', "Dupes will be renamed with correct namespace with " .
-                                                                       "<text> appended after the article name", false, true );
+                       "<text> appended after the article name", false, true );
                $this->addOption( 'prefix', "Do an explicit check for the given title prefix " .
-                                                                       "appended after the article name", false, true );
+                       "appended after the article name", false, true );
        }
 
        public function execute() {
@@ -138,6 +138,7 @@ class NamespaceConflictChecker extends Maintenance {
                foreach ( $spaces as $name => $ns ) {
                        $ok = $this->checkNamespace( $ns, $name, $fix, $suffix ) && $ok;
                }
+
                return $ok;
        }
 
@@ -152,6 +153,7 @@ class NamespaceConflictChecker extends Maintenance {
                foreach ( $result as $row ) {
                        $prefixes[] = $row['iw_prefix'];
                }
+
                return $prefixes;
        }
 
@@ -178,6 +180,7 @@ class NamespaceConflictChecker extends Maintenance {
                                $ok = $this->resolveConflict( $row, $resolvable, $suffix ) && $ok;
                        }
                }
+
                return $ok;
        }
 
@@ -191,6 +194,7 @@ class NamespaceConflictChecker extends Maintenance {
         */
        private function checkPrefix( $key, $prefix, $fix, $suffix = '' ) {
                $this->output( "Checking prefix \"$prefix\" vs namespace $key\n" );
+
                return $this->checkNamespace( $key, $prefix, $fix, $suffix );
        }
 
@@ -231,6 +235,7 @@ class NamespaceConflictChecker extends Maintenance {
                foreach ( $result as $row ) {
                        $set[] = $row;
                }
+
                return $set;
        }
 
@@ -251,6 +256,7 @@ class NamespaceConflictChecker extends Maintenance {
                                $row->oldnamespace,
                                $row->oldtitle ) );
                        $this->output( "...  *** cannot resolve automatically; illegal title ***\n" );
+
                        return false;
                }
 
@@ -265,6 +271,7 @@ class NamespaceConflictChecker extends Maintenance {
                $id = $newTitle->getArticleID();
                if ( $id ) {
                        $this->output( "...  *** cannot resolve automatically; page exists with ID $id ***\n" );
+
                        return false;
                } else {
                        return true;
@@ -288,6 +295,7 @@ class NamespaceConflictChecker extends Maintenance {
                                $title = Title::makeTitleSafe( $row->namespace, $row->title );
                                if ( !$title ) {
                                        $this->output( "... !!! invalid title\n" );
+
                                        return false;
                                }
                                $id = $title->getArticleID();
@@ -300,6 +308,7 @@ class NamespaceConflictChecker extends Maintenance {
                        $this->output( "...  *** using suffixed form [[" . $title->getPrefixedText() . "]] ***\n" );
                }
                $this->resolveConflictOn( $row, 'page', 'page' );
+
                return true;
        }
 
@@ -326,6 +335,7 @@ class NamespaceConflictChecker extends Maintenance {
                        ),
                        __METHOD__ );
                $this->output( "ok.\n" );
+
                return true;
        }
 }
index 479dcf7..64bf1b6 100644 (file)
@@ -91,7 +91,7 @@ class NukeNS extends Maintenance {
                                        $child = $this->runChild( 'NukePage', 'nukePage.php' );
                                        $child->deleteRevisions( $revs );
                                        $this->purgeRedundantText( true );
-                                       $n_deleted ++;
+                                       $n_deleted++;
                                }
                        } else {
                                $this->output( "skip: " . $title->getPrefixedText() . "\n" );
index 8f0b83f..eea6f7b 100644 (file)
@@ -44,6 +44,7 @@ class AlterSharedConstraints extends Maintenance {
 
                if ( $wgSharedDB == null ) {
                        $this->output( "Database sharing is not enabled\n" );
+
                        return;
                }
 
@@ -66,29 +67,28 @@ class AlterSharedConstraints extends Maintenance {
                                                AND uccpk.table_name = '$ltable'" );
                        while ( ( $row = $result->fetchRow() ) !== false ) {
 
-                                       $this->output( "Altering {$row['constraint_name']} ..." );
+                               $this->output( "Altering {$row['constraint_name']} ..." );
 
-                                       try {
-                                               $dbw->query( "ALTER TABLE {$row['table_name']}
+                               try {
+                                       $dbw->query( "ALTER TABLE {$row['table_name']}
                                                        DROP CONSTRAINT {$wgDBprefix}{$row['constraint_name']}" );
-                                       } catch ( DBQueryError $exdb ) {
-                                               if ( $exdb->errno != 2443 ) {
-                                                       throw $exdb;
-                                               }
+                               } catch ( DBQueryError $exdb ) {
+                                       if ( $exdb->errno != 2443 ) {
+                                               throw $exdb;
                                        }
+                               }
 
-                                       $deleteRule = $row['delete_rule'] == 'NO ACTION' ? '' : "ON DELETE {$row['delete_rule']}";
-                                       $dbw->query( "ALTER TABLE {$row['table_name']}
+                               $deleteRule = $row['delete_rule'] == 'NO ACTION' ? '' : "ON DELETE {$row['delete_rule']}";
+                               $dbw->query( "ALTER TABLE {$row['table_name']}
                                                ADD CONSTRAINT {$wgDBprefix}{$row['constraint_name']}
                                                FOREIGN KEY ({$row['column_name']})
                                                REFERENCES {$wgSharedDB}.$stable({$row['pk_column_name']})
                                                {$deleteRule} {$row['deferrable']} INITIALLY {$row['deferred']}" );
 
-                                       $this->output( "DONE\n" );
+                               $this->output( "DONE\n" );
                        }
                }
        }
-
 }
 
 $maintClass = "AlterSharedConstraints";
index 1a8052b..7e27107 100644 (file)
@@ -40,9 +40,9 @@ class Orphans extends Maintenance {
        public function __construct() {
                parent::__construct();
                $this->mDescription = "Look for 'orphan' revisions hooked to pages which don't exist\n" .
-                                                               "and 'childless' pages with no revisions\n" .
-                                                               "Then, kill the poor widows and orphans\n" .
-                                                               "Man this is depressing";
+                       "and 'childless' pages with no revisions\n" .
+                       "Then, kill the poor widows and orphans\n" .
+                       "Man this is depressing";
                $this->addOption( 'fix', 'Actually fix broken entries' );
        }
 
index 0ec1de9..9af57da 100644 (file)
@@ -116,10 +116,10 @@ class CLIParser extends Maintenance {
         * @return Title object
         */
        protected function getTitle() {
-               $title =
-                       $this->getOption( 'title' )
+               $title = $this->getOption( 'title' )
                        ? $this->getOption( 'title' )
                        : 'CLIParser';
+
                return Title::newFromText( $title );
        }
 
index 15087f8..ab0ca1e 100644 (file)
@@ -92,8 +92,9 @@ TEXT;
                        );
                        if ( $row ) {
                                $this->output( "Category table already populated.  Use php " .
-                               "maintenance/populateCategory.php\n--force from the command line " .
-                               "to override.\n" );
+                                       "maintenance/populateCategory.php\n--force from the command line " .
+                                       "to override.\n" );
+
                                return true;
                        }
                }
@@ -141,16 +142,17 @@ TEXT;
                }
 
                if ( $dbw->insert(
-                               'updatelog',
-                               array( 'ul_key' => 'populate category' ),
-                               __METHOD__,
-                               'IGNORE'
-                       )
-               ) {
+                       'updatelog',
+                       array( 'ul_key' => 'populate category' ),
+                       __METHOD__,
+                       'IGNORE'
+               ) ) {
                        $this->output( "Category population complete.\n" );
+
                        return true;
                } else {
                        $this->output( "Could not insert category population row.\n" );
+
                        return false;
                }
        }
index c579d4f..850a5a5 100644 (file)
@@ -51,6 +51,7 @@ class PopulateFilearchiveSha1 extends LoggedUpdateMaintenance {
 
                if ( !$dbw->fieldExists( $table, 'fa_sha1', __METHOD__ ) ) {
                        $this->output( "fa_sha1 column does not exist\n\n", true );
+
                        return false;
                }
 
index 575573b..d7c26d5 100644 (file)
@@ -77,6 +77,7 @@ class PopulateImageSha1 extends LoggedUpdateMaintenance {
                        );
                        if ( !$res ) {
                                $this->error( "No such file: $file", true );
+
                                return false;
                        }
                        $this->output( "Populating img_sha1 field for specified files\n" );
index 83e470d..4c1a72e 100644 (file)
@@ -56,11 +56,13 @@ class PopulateLogSearch extends LoggedUpdateMaintenance {
                $db = $this->getDB( DB_MASTER );
                if ( !$db->tableExists( 'log_search' ) ) {
                        $this->error( "log_search does not exist" );
+
                        return false;
                }
                $start = $db->selectField( 'logging', 'MIN(log_id)', false, __FUNCTION__ );
                if ( !$start ) {
                        $this->output( "Nothing to do.\n" );
+
                        return true;
                }
                $end = $db->selectField( 'logging', 'MAX(log_id)', false, __FUNCTION__ );
@@ -126,8 +128,8 @@ class PopulateLogSearch extends LoggedUpdateMaintenance {
                                        // Add item author relations...
                                        $log->addRelations( 'target_author_id', $userIds, $row->log_id );
                                        $log->addRelations( 'target_author_ip', $userIPs, $row->log_id );
-                               // RevisionDelete logs - log events
                                } elseif ( LogEventsList::typeAction( $row, $delTypes, 'event' ) ) {
+                                       // RevisionDelete logs - log events
                                        $params = LogPage::extractParams( $row->log_params );
                                        // Param format: <item CSV> [<ofield> <nfield>]
                                        if ( count( $params ) < 1 ) {
@@ -159,6 +161,7 @@ class PopulateLogSearch extends LoggedUpdateMaintenance {
                        wfWaitForSlaves();
                }
                $this->output( "Done populating log_search table.\n" );
+
                return true;
        }
 }
index e579e52..96cb1ec 100644 (file)
@@ -52,6 +52,7 @@ class PopulateLogUsertext extends LoggedUpdateMaintenance {
                $start = $db->selectField( 'logging', 'MIN(log_id)', false, __METHOD__ );
                if ( !$start ) {
                        $this->output( "Nothing to do.\n" );
+
                        return true;
                }
                $end = $db->selectField( 'logging', 'MAX(log_id)', false, __METHOD__ );
@@ -77,6 +78,7 @@ class PopulateLogUsertext extends LoggedUpdateMaintenance {
                        wfWaitForSlaves();
                }
                $this->output( "Done populating log_user_text field.\n" );
+
                return true;
        }
 }
index 35eef83..f77978f 100644 (file)
@@ -49,6 +49,7 @@ class PopulateParentId extends LoggedUpdateMaintenance {
                $db = wfGetDB( DB_MASTER );
                if ( !$db->tableExists( 'revision' ) ) {
                        $this->error( "revision table does not exist" );
+
                        return false;
                }
                $this->output( "Populating rev_parent_id column\n" );
@@ -56,6 +57,7 @@ class PopulateParentId extends LoggedUpdateMaintenance {
                $end = $db->selectField( 'revision', 'MAX(rev_id)', false, __FUNCTION__ );
                if ( is_null( $start ) || is_null( $end ) ) {
                        $this->output( "...revision table seems to be empty, nothing to do.\n" );
+
                        return true;
                }
                # Do remaining chunk
@@ -119,6 +121,7 @@ class PopulateParentId extends LoggedUpdateMaintenance {
                        wfWaitForSlaves();
                }
                $this->output( "rev_parent_id population complete ... {$count} rows [{$changed} changed]\n" );
+
                return true;
        }
 }
index e9c9407..25a51d7 100644 (file)
@@ -46,6 +46,7 @@ class PopulateRecentChangesSource extends LoggedUpdateMaintenance {
                $start = $dbw->selectField( 'recentchanges', 'MIN(rc_id)', false, __METHOD__ );
                if ( !$start ) {
                        $this->output( "Nothing to do.\n" );
+
                        return true;
                }
                $end = $dbw->selectField( 'recentchanges', 'MAX(rc_id)', false, __METHOD__ );
index 636d63e..b73ac7f 100644 (file)
@@ -49,6 +49,7 @@ class PopulateRevisionLength extends LoggedUpdateMaintenance {
                        $this->error( "archive table does not exist", true );
                } elseif ( !$db->fieldExists( 'revision', 'rev_len', __METHOD__ ) ) {
                        $this->output( "rev_len column does not exist\n\n", true );
+
                        return false;
                }
 
@@ -60,6 +61,7 @@ class PopulateRevisionLength extends LoggedUpdateMaintenance {
 
                $this->output( "rev_len and ar_len population complete "
                        . "[$rev revision rows, $ar archive rows].\n" );
+
                return true;
        }
 
@@ -76,6 +78,7 @@ class PopulateRevisionLength extends LoggedUpdateMaintenance {
                $end = $db->selectField( $table, "MAX($idCol)", false, __METHOD__ );
                if ( !$start || !$end ) {
                        $this->output( "...$table table seems to be empty.\n" );
+
                        return 0;
                }
 
@@ -133,6 +136,7 @@ class PopulateRevisionLength extends LoggedUpdateMaintenance {
                        # This should not happen, but sometimes does (bug 20757)
                        $id = $row->$idCol;
                        $this->output( "Content of $table $id unavailable!\n" );
+
                        return false;
                }
 
index 03f9b09..f06b56b 100644 (file)
@@ -50,6 +50,7 @@ class PopulateRevisionSha1 extends LoggedUpdateMaintenance {
                        $this->error( "archive table does not exist", true );
                } elseif ( !$db->fieldExists( 'revision', 'rev_sha1', __METHOD__ ) ) {
                        $this->output( "rev_sha1 column does not exist\n\n", true );
+
                        return false;
                }
 
@@ -63,6 +64,7 @@ class PopulateRevisionSha1 extends LoggedUpdateMaintenance {
 
                $this->output( "rev_sha1 and ar_sha1 population complete "
                        . "[$rc revision rows, $ac archive rows].\n" );
+
                return true;
        }
 
@@ -78,6 +80,7 @@ class PopulateRevisionSha1 extends LoggedUpdateMaintenance {
                $end = $db->selectField( $table, "MAX($idCol)", false, __METHOD__ );
                if ( !$start || !$end ) {
                        $this->output( "...$table table seems to be empty.\n" );
+
                        return 0;
                }
 
@@ -104,6 +107,7 @@ class PopulateRevisionSha1 extends LoggedUpdateMaintenance {
                        $blockEnd += $this->mBatchSize;
                        wfWaitForSlaves();
                }
+
                return $count;
        }
 
@@ -131,6 +135,7 @@ class PopulateRevisionSha1 extends LoggedUpdateMaintenance {
                        }
                }
                $db->commit( __METHOD__ );
+
                return $count;
        }
 
@@ -150,11 +155,13 @@ class PopulateRevisionSha1 extends LoggedUpdateMaintenance {
                        $text = $rev->getSerializedData();
                } catch ( MWException $e ) {
                        $this->output( "Data of revision with {$idCol}={$row->$idCol} unavailable!\n" );
+
                        return false; // bug 22624?
                }
                if ( !is_string( $text ) ) {
                        # This should not happen, but sometimes does (bug 20757)
                        $this->output( "Data of revision with {$idCol}={$row->$idCol} unavailable!\n" );
+
                        return false;
                } else {
                        $db->update( $table,
@@ -162,6 +169,7 @@ class PopulateRevisionSha1 extends LoggedUpdateMaintenance {
                                array( $idCol => $row->$idCol ),
                                __METHOD__
                        );
+
                        return true;
                }
        }
@@ -176,12 +184,14 @@ class PopulateRevisionSha1 extends LoggedUpdateMaintenance {
                        $rev = Revision::newFromArchiveRow( $row );
                } catch ( MWException $e ) {
                        $this->output( "Text of revision with timestamp {$row->ar_timestamp} unavailable!\n" );
+
                        return false; // bug 22624?
                }
                $text = $rev->getSerializedData();
                if ( !is_string( $text ) ) {
                        # This should not happen, but sometimes does (bug 20757)
                        $this->output( "Data of revision with timestamp {$row->ar_timestamp} unavailable!\n" );
+
                        return false;
                } else {
                        # Archive table as no PK, but (NS,title,time) should be near unique.
@@ -196,6 +206,7 @@ class PopulateRevisionSha1 extends LoggedUpdateMaintenance {
                                ),
                                __METHOD__
                        );
+
                        return true;
                }
        }
index c69e5c2..17d97b0 100644 (file)
@@ -41,6 +41,7 @@ class PreprocessDump extends DumpIterator {
 
        public function getStripList() {
                global $wgParser;
+
                return $wgParser->getStripList();
        }
 
index 498ddf6..9155623 100644 (file)
@@ -121,6 +121,7 @@ class PPFuzzTester {
                // It's done by the MW UI, so it's a reasonably legitimate thing to do.
                global $wgContLang;
                $s = $wgContLang->normalize( $s );
+
                return $s;
        }
 
@@ -136,7 +137,8 @@ class PPFuzzTester {
 
        function pickEntryPoint() {
                $count = count( $this->entryPoints );
-               return $this->entryPoints[ mt_rand( 0, $count - 1 ) ];
+
+               return $this->entryPoints[mt_rand( 0, $count - 1 )];
        }
 }
 
@@ -182,6 +184,7 @@ class PPFuzzTest {
                                'text' => $text,
                                'finalTitle' => $finalTitle );
                }
+
                return $this->templates[$titleText];
        }
 
@@ -211,7 +214,7 @@ class PPFuzzTest {
 //                     "Output type: {$this->outputType}\n" .
                        "Entry point: {$this->entryPoint}\n" .
                        "User: " . ( $this->fancySig ? 'fancy' : 'no-fancy' ) .
-                               ' ' . var_export( $this->nickname, true ) . "\n" .
+                       ' ' . var_export( $this->nickname, true ) . "\n" .
                        "Main text: " . var_export( $this->mainText, true ) . "\n";
                foreach ( $this->templates as $titleText => $template ) {
                        $finalTitle = $template['finalTitle'];
index 91c36f2..1e702de 100644 (file)
@@ -177,7 +177,6 @@ class PurgeChangedFiles extends Maintenance {
                                                        // Sanity check to avoid data loss
                                                        $repo->getBackend()->delete( array( 'src' => $file->getPath() ) );
                                                        $this->verbose( "Deleted orphan file: {$file->getPath()}.\n" );
-
                                                } else {
                                                        $this->error( "File was not deleted: {$file->getPath()}.\n" );
                                                }
@@ -185,7 +184,6 @@ class PurgeChangedFiles extends Maintenance {
 
                                        // Purge items from fileachive table (rows are likely here)
                                        $this->purgeFromArchiveTable( $repo, $file );
-
                                } elseif ( $logType === 'move' ) {
                                        // Purge the target file as well
 
@@ -232,7 +230,6 @@ class PurgeChangedFiles extends Maintenance {
                                        // Sanity check to avoid data loss
                                        $repo->getBackend()->delete( array( 'src' => $ofile->getPath() ) );
                                        $this->output( "Deleted orphan file: {$ofile->getPath()}.\n" );
-
                                } else {
                                        $this->error( "File was not deleted: {$ofile->getPath()}.\n" );
                                }
@@ -244,6 +241,7 @@ class PurgeChangedFiles extends Maintenance {
        protected function getDeletedPath( LocalRepo $repo, LocalFile $file ) {
                $hash = $repo->getFileSha1( $file->getPath() );
                $key = "{$hash}.{$file->getExtension()}";
+
                return $repo->getDeletedHashPath( $key ) . $key;
        }
 
@@ -257,7 +255,6 @@ class PurgeChangedFiles extends Maintenance {
                        $this->output( $msg );
                }
        }
-
 }
 
 $maintClass = "PurgeChangedFiles";
index 071ac09..f0b6ec7 100644 (file)
@@ -183,6 +183,7 @@ class PurgeChangedPages extends Maintenance {
                        }
                }
                $lastValueLeft = count( $rows ) ? $rows[count( $rows ) - 1]->$column : null;
+
                return array( $rows, $lastValueLeft );
        }
 }
index 8a3818a..2e19630 100644 (file)
@@ -141,7 +141,6 @@ class PurgeList extends Maintenance {
                        $u->doUpdate();
                }
        }
-
 }
 
 $maintClass = "PurgeList";