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

39 files changed:
maintenance/benchmarks/bench_delete_truncate.php
maintenance/benchmarks/bench_strtr_str_replace.php
maintenance/benchmarks/bench_utf8_title_check.php
maintenance/benchmarks/bench_wfBaseConvert.php
maintenance/benchmarks/bench_wfIsWindows.php
maintenance/benchmarks/benchmarkHooks.php
maintenance/benchmarks/benchmarkParse.php
maintenance/benchmarks/benchmarkPurge.php
maintenance/checkBadRedirects.php
maintenance/checkImages.php
maintenance/checkSyntax.php
maintenance/checkUsernames.php
maintenance/cleanupAncientTables.php
maintenance/cleanupCaps.php
maintenance/cleanupImages.php
maintenance/cleanupSpam.php
maintenance/cleanupWatchlist.php
maintenance/compareParsers.php
maintenance/convertLinks.php
maintenance/convertUserOptions.php
maintenance/copyFileBackend.php
maintenance/copyJobQueue.php
maintenance/createAndPromote.php
maintenance/deleteArchivedFiles.inc
maintenance/deleteArchivedFiles.php
maintenance/deleteArchivedRevisions.inc
maintenance/deleteBatch.php
maintenance/deleteDefaultMessages.php
maintenance/deleteEqualMessages.php
maintenance/deleteImageMemcached.php
maintenance/deleteRevision.php
maintenance/dev/includes/router.php
maintenance/dumpBackup.php
maintenance/dumpIterator.php
maintenance/dumpTextPass.php
maintenance/dumpUploads.php
maintenance/fetchText.php
maintenance/findHooks.php
maintenance/fixDoubleRedirects.php

index ed3fe5c..8ae4f03 100644 (file)
@@ -75,7 +75,7 @@ class BenchmarkDeleteTruncate extends Benchmarker {
        private function insertData( $dbw ) {
                $range = range( 0, 1024 );
                $data = array();
-               foreach( $range as $r ) {
+               foreach ( $range as $r ) {
                        $data[] = array( 'text' => $r );
                }
                $dbw->insert( 'test', $data, __METHOD__ );
index 99e9cfd..44c8e03 100644 (file)
@@ -50,7 +50,7 @@ class BenchStrtrStrReplace extends Benchmarker {
                        array( 'function' => array( $this, 'benchstr_replace' ) ),
                        array( 'function' => array( $this, 'benchstrtr_indirect' ) ),
                        array( 'function' => array( $this, 'benchstr_replace_indirect' ) ),
-               ));
+               ) );
                print $this->getFormattedResults();
        }
 
@@ -59,7 +59,7 @@ class BenchStrtrStrReplace extends Benchmarker {
        }
 
        function benchstr_replace() {
-               str_replace( "_", " ", "[[MediaWiki:Some_random_test_page]]");
+               str_replace( "_", " ", "[[MediaWiki:Some_random_test_page]]" );
        }
 
        function benchstrtr_indirect() {
index 1c31256..b742f66 100644 (file)
@@ -61,7 +61,7 @@ class BenchUtf8TitleCheck extends Benchmarker {
                );
                // @codingStandardsIgnoreEnd
 
-               $this->canRun = function_exists ( 'mb_check_encoding' );
+               $this->canRun = function_exists( 'mb_check_encoding' );
 
                if ( $this->canRun ) {
                        $this->mDescription = "Benchmark for using a regexp vs. mb_check_encoding " .
@@ -77,22 +77,22 @@ class BenchUtf8TitleCheck extends Benchmarker {
                        return;
                }
                $benchmarks = array();
-               foreach ($this->data as $val) {
+               foreach ( $this->data as $val ) {
                        $benchmarks[] = array(
                                'function' => array( $this, 'use_regexp' ),
-                               'args' => array( rawurldecode ( $val ) )
+                               'args' => array( rawurldecode( $val ) )
                        );
                        $benchmarks[] = array(
                                'function' => array( $this, 'use_regexp_non_capturing' ),
-                               'args' => array( rawurldecode ( $val ) )
+                               'args' => array( rawurldecode( $val ) )
                        );
                        $benchmarks[] = array(
                                'function' => array( $this, 'use_regexp_once_only' ),
-                               'args' => array( rawurldecode ( $val ) )
+                               'args' => array( rawurldecode( $val ) )
                        );
                        $benchmarks[] = array(
                                'function' => array( $this, 'use_mb_check_encoding' ),
-                               'args' => array( rawurldecode ( $val ) )
+                               'args' => array( rawurldecode( $val ) )
                        );
                }
                $this->bench( $benchmarks );
@@ -103,19 +103,19 @@ class BenchUtf8TitleCheck extends Benchmarker {
 
        function use_regexp( $s ) {
                $this->isutf8 = preg_match( '/^([\x00-\x7f]|[\xc0-\xdf][\x80-\xbf]|' .
-                               '[\xe0-\xef][\x80-\xbf]{2}|[\xf0-\xf7][\x80-\xbf]{3})+$/', $s );
+                       '[\xe0-\xef][\x80-\xbf]{2}|[\xf0-\xf7][\x80-\xbf]{3})+$/', $s );
        }
 
        function use_regexp_non_capturing( $s ) {
                // Same as above with a non-capturing subgroup.
                $this->isutf8 = preg_match( '/^(?:[\x00-\x7f]|[\xc0-\xdf][\x80-\xbf]|' .
-                               '[\xe0-\xef][\x80-\xbf]{2}|[\xf0-\xf7][\x80-\xbf]{3})+$/', $s );
+                       '[\xe0-\xef][\x80-\xbf]{2}|[\xf0-\xf7][\x80-\xbf]{3})+$/', $s );
        }
 
        function use_regexp_once_only( $s ) {
                // Same as above with a once-only subgroup.
                $this->isutf8 = preg_match( '/^(?>[\x00-\x7f]|[\xc0-\xdf][\x80-\xbf]|' .
-                               '[\xe0-\xef][\x80-\xbf]{2}|[\xf0-\xf7][\x80-\xbf]{3})+$/', $s );
+                       '[\xe0-\xef][\x80-\xbf]{2}|[\xf0-\xf7][\x80-\xbf]{3})+$/', $s );
        }
 
        function use_mb_check_encoding( $s ) {
index d08a0b0..b4be12b 100644 (file)
@@ -57,7 +57,7 @@ class BenchWfBaseConvert extends Benchmarker {
                                'function' => 'wfBaseConvert',
                                'args' => array( $number, $inbase, $outbase, 0, true, 'gmp' )
                        ),
-               ));
+               ) );
 
                $this->output( $this->getFormattedResults() );
        }
@@ -65,9 +65,10 @@ class BenchWfBaseConvert extends Benchmarker {
        protected static function makeRandomNumber( $base, $length ) {
                $baseChars = "0123456789abcdefghijklmnopqrstuvwxyz";
                $res = "";
-               for( $i = 0; $i < $length; $i++ ) {
-                       $res .= $baseChars[mt_rand(0, $base - 1)];
+               for ( $i = 0; $i < $length; $i++ ) {
+                       $res .= $baseChars[mt_rand( 0, $base - 1 )];
                }
+
                return $res;
        }
 }
index b5cb025..8446694 100644 (file)
@@ -41,7 +41,7 @@ class BenchWfIsWindows extends Benchmarker {
                $this->bench( array(
                        array( 'function' => array( $this, 'wfIsWindows' ) ),
                        array( 'function' => array( $this, 'wfIsWindowsCached' ) ),
-               ));
+               ) );
                print $this->getFormattedResults();
        }
 
@@ -57,9 +57,10 @@ class BenchWfIsWindows extends Benchmarker {
        // bench function 2
        function wfIsWindowsCached() {
                static $isWindows = null;
-               if( $isWindows == null ) {
+               if ( $isWindows == null ) {
                        $isWindows = self::is_win();
                }
+
                return $isWindows;
        }
 }
index bb7af2b..fb25b9d 100644 (file)
@@ -45,13 +45,13 @@ class BenchmarkHooks extends Benchmarker {
                $time = $this->benchHooks();
                $this->output( 'Loaded (one) hook: ' . $time . "\n" );
 
-               for( $i = 0; $i < 9; $i++ ) {
+               for ( $i = 0; $i < 9; $i++ ) {
                        $wgHooks['Test'][] = array( $this, 'test' );
                }
                $time = $this->benchHooks();
                $this->output( 'Loaded (ten) hook: ' . $time . "\n" );
 
-               for( $i = 0; $i < 90; $i++ ) {
+               for ( $i = 0; $i < 90; $i++ ) {
                        $wgHooks['Test'][] = array( $this, 'test' );
                }
                $time = $this->benchHooks();
@@ -70,6 +70,7 @@ class BenchmarkHooks extends Benchmarker {
                }
                $delta = microtime( true ) - $start;
                $pertrial = $delta / $trials;
+
                return sprintf( "Took %6.3fms",
                        $pertrial * 1000 );
        }
index cec2beb..b81f9fd 100644 (file)
@@ -47,7 +47,7 @@ class BenchmarkParse extends Maintenance {
                        false, true );
                $this->addOption( 'tpl-time',
                        'Use templates which were current at the given time (except that moves and ' .
-                               'deletes are not handled properly)',
+                       'deletes are not handled properly)',
                        false, true );
        }
 
@@ -94,7 +94,7 @@ class BenchmarkParse extends Maintenance {
                printf( "CPU time = %.3f s, wall clock time = %.3f s\n",
                        // CPU time
                        $endUsage['ru_utime.tv_sec'] + $endUsage['ru_utime.tv_usec'] * 1e-6
-                               - $startUsage['ru_utime.tv_sec'] - $startUsage['ru_utime.tv_usec'] * 1e-6,
+                       - $startUsage['ru_utime.tv_sec'] - $startUsage['ru_utime.tv_usec'] * 1e-6,
                        // Wall clock time
                        $endTime - $startTime );
        }
index dcaacab..42c1eb7 100644 (file)
@@ -68,6 +68,7 @@ class BenchmarkPurge extends Benchmarker {
                $delta = microtime( true ) - $start;
                $pertrial = $delta / $trials;
                $pertitle = $pertrial / count( $urls );
+
                return sprintf( "%4d titles in %6.2fms (%6.2fms each)",
                        count( $urls ), $pertrial * 1000.0, $pertitle * 1000.0 );
        }
@@ -82,6 +83,7 @@ class BenchmarkPurge extends Benchmarker {
                for ( $i = 0; $i < $length; $i++ ) {
                        $list[] = $this->randomUrl();
                }
+
                return $list;
        }
 
@@ -92,6 +94,7 @@ class BenchmarkPurge extends Benchmarker {
         */
        private function randomUrl() {
                global $wgServer, $wgArticlePath;
+
                return $wgServer . str_replace( '$1', $this->randomTitle(), $wgArticlePath );
        }
 
@@ -106,6 +109,7 @@ class BenchmarkPurge extends Benchmarker {
                for ( $i = 0; $i < $length; $i++ ) {
                        $str .= chr( mt_rand( ord( 'a' ), ord( 'z' ) ) );
                }
+
                return ucfirst( $str );
        }
 }
index a96e9b8..fec9291 100644 (file)
@@ -44,7 +44,7 @@ class CheckBadRedirects extends Maintenance {
 
                $count = $result->numRows();
                $this->output( "Found $count redirects.\n" .
-                                               "Checking for bad redirects:\n\n" );
+                       "Checking for bad redirects:\n\n" );
 
                foreach ( $result as $row ) {
                        $title = Title::makeTitle( $row->page_namespace, $row->page_title );
index e914645..3921c07 100644 (file)
@@ -80,7 +80,6 @@ class CheckImages extends Maintenance {
 
                                $numGood++;
                        }
-
                } while ( $res->numRows() );
 
                $this->output( "Good images: $numGood/$numImages\n" );
index e01767e..6ef4909 100644 (file)
@@ -96,7 +96,7 @@ class CheckSyntax extends Maintenance {
                $this->mIgnorePaths = array(
                        // Compat stuff, explodes on PHP 5.3
                        "includes/NamespaceCompat.php$",
-                       );
+               );
 
                $this->mNoStyleCheckPaths = array(
                        // Third-party code we don't care about
@@ -110,13 +110,14 @@ class CheckSyntax extends Maintenance {
                        "QPoll/Excel/",
                        "/geshi/",
                        "/smarty/",
-                       );
+               );
 
                if ( $this->hasOption( 'path' ) ) {
                        $path = $this->getOption( 'path' );
                        if ( !$this->addPath( $path ) ) {
                                $this->error( "Error: can't find file or directory $path\n", true );
                        }
+
                        return; // process only this path
                } elseif ( $this->hasOption( 'list-file' ) ) {
                        $file = $this->getOption( 'list-file' );
@@ -131,6 +132,7 @@ class CheckSyntax extends Maintenance {
                                $this->addPath( $path );
                        }
                        fclose( $f );
+
                        return;
                } elseif ( $this->hasOption( 'modified' ) ) {
                        $this->output( "Retrieving list from Git... " );
@@ -141,6 +143,7 @@ class CheckSyntax extends Maintenance {
                                        $this->mFiles[] = $file;
                                }
                        }
+
                        return;
                }
 
@@ -241,6 +244,7 @@ class CheckSyntax extends Maintenance {
                                return false;
                        }
                }
+
                return true;
        }
 
@@ -251,6 +255,7 @@ class CheckSyntax extends Maintenance {
         */
        private function addPath( $path ) {
                global $IP;
+
                return $this->addFileOrDir( $path ) || $this->addFileOrDir( "$IP/$path" );
        }
 
@@ -267,6 +272,7 @@ class CheckSyntax extends Maintenance {
                } else {
                        return false;
                }
+
                return true;
        }
 
@@ -313,6 +319,7 @@ class CheckSyntax extends Maintenance {
                                $this->mFailures[$file] = $errors;
                        }
                }
+
                return $ret;
        }
 
@@ -326,8 +333,10 @@ class CheckSyntax extends Maintenance {
                if ( strpos( $res, 'No syntax errors detected' ) === false ) {
                        $this->mFailures[$file] = $res;
                        $this->output( $res . "\n" );
+
                        return false;
                }
+
                return true;
        }
 
index 6df189f..777c833 100644 (file)
@@ -55,7 +55,7 @@ class CheckUsernames extends Maintenance {
                        );
 
                        foreach ( $res as $row ) {
-                               if ( ! User::isValidUserName( $row->user_name ) ) {
+                               if ( !User::isValidUserName( $row->user_name ) ) {
                                        $this->error( sprintf( "%s: %6d: '%s'\n", wfWikiID(), $row->user_id, $row->user_name ) );
                                        wfDebugLog( 'checkUsernames', $row->user_name );
                                }
index 428484b..2dbf8bc 100644 (file)
@@ -83,7 +83,7 @@ class CleanupAncientTables extends Maintenance {
                        if ( $db->indexExists( 'text', $index, __METHOD__ ) ) {
                                $this->output( "Dropping index $index from the text table..." );
                                $db->query( "DROP INDEX " . $db->addIdentifierQuotes( $index )
-                                               . " ON " . $db->tableName( 'text' ) );
+                                       . " ON " . $db->tableName( 'text' ) );
                                $this->output( "done.\n" );
                        }
                }
@@ -102,7 +102,7 @@ class CleanupAncientTables extends Maintenance {
                        if ( $db->fieldExists( 'text', $field, __METHOD__ ) ) {
                                $this->output( "Dropping the $field field from the text table..." );
                                $db->query( "ALTER TABLE  " . $db->tableName( 'text' )
-                                               . " DROP COLUMN " . $db->addIdentifierQuotes( $field )  );
+                                       . " DROP COLUMN " . $db->addIdentifierQuotes( $field ) );
                                $this->output( "done.\n" );
                        }
                }
index 321f089..9e88c13 100644 (file)
@@ -71,6 +71,7 @@ class CapsCleanup extends TableCleanup {
                $lower = $wgContLang->lcfirst( $row->page_title );
                if ( $upper == $lower ) {
                        $this->output( "\"$display\" already lowercase.\n" );
+
                        return $this->progress( 0 );
                }
 
@@ -78,6 +79,7 @@ class CapsCleanup extends TableCleanup {
                $targetDisplay = $target->getPrefixedText();
                if ( $target->exists() ) {
                        $this->output( "\"$display\" skipped; \"$targetDisplay\" already exists\n" );
+
                        return $this->progress( 0 );
                }
 
@@ -98,6 +100,7 @@ class CapsCleanup extends TableCleanup {
                                }
                        }
                }
+
                return $this->progress( 0 );
        }
 }
index 1b46ab8..915a2c0 100644 (file)
@@ -56,6 +56,7 @@ class ImageCleanup extends TableCleanup {
                if ( $source == '' ) {
                        // Ye olde empty rows. Just kill them.
                        $this->killRow( $source );
+
                        return $this->progress( 1 );
                }
 
@@ -82,6 +83,7 @@ class ImageCleanup extends TableCleanup {
                                return $this->progress( 0 );
                        }
                        $this->pokeFile( $source, $safe );
+
                        return $this->progress( 1 );
                }
 
@@ -89,6 +91,7 @@ class ImageCleanup extends TableCleanup {
                        $munged = $title->getDBkey();
                        $this->output( "page $source ($munged) doesn't match self.\n" );
                        $this->pokeFile( $source, $munged );
+
                        return $this->progress( 1 );
                }
 
@@ -114,6 +117,7 @@ class ImageCleanup extends TableCleanup {
                if ( !isset( $this->repo ) ) {
                        $this->repo = RepoGroup::singleton()->getLocalRepo();
                }
+
                return $this->repo->getRootDirectory() . '/' . $this->repo->getHashPath( $name ) . $name;
        }
 
@@ -135,6 +139,7 @@ class ImageCleanup extends TableCleanup {
                if ( !file_exists( $path ) ) {
                        $this->output( "missing file: $path\n" );
                        $this->killRow( $orig );
+
                        return;
                }
 
@@ -150,7 +155,7 @@ class ImageCleanup extends TableCleanup {
                $version = 0;
                $final = $new;
                $conflict = ( $this->imageExists( $final, $db ) ||
-                               ( $this->pageExists( $orig, $db ) && $this->pageExists( $final, $db ) ) );
+                       ( $this->pageExists( $orig, $db ) && $this->pageExists( $final, $db ) ) );
 
                while ( $conflict ) {
                        $this->output( "Rename conflicts with '$final'...\n" );
@@ -184,6 +189,7 @@ class ImageCleanup extends TableCleanup {
                                if ( !wfMkdirParents( $dir, null, __METHOD__ ) ) {
                                        $this->output( "RENAME FAILED, COULD NOT CREATE $dir" );
                                        $db->rollback( __METHOD__ );
+
                                        return;
                                }
                        }
@@ -210,6 +216,7 @@ class ImageCleanup extends TableCleanup {
                $test = Title::makeTitleSafe( NS_FILE, $x );
                if ( is_null( $test ) || $test->getDBkey() !== $x ) {
                        $this->error( "Unable to generate safe title from '$name', got '$x'" );
+
                        return false;
                }
 
index 8551f8f..f4a5147 100644 (file)
@@ -101,6 +101,7 @@ class CleanupSpam extends Maintenance {
                $title = Title::newFromID( $id );
                if ( !$title ) {
                        $this->error( "Internal error: no page for ID $id" );
+
                        return;
                }
 
@@ -109,7 +110,8 @@ class CleanupSpam extends Maintenance {
                $currentRevId = $rev->getId();
 
                while ( $rev && ( $rev->isDeleted( Revision::DELETED_TEXT )
-                                               || LinkFilter::matchEntry( $rev->getContent( Revision::RAW ), $domain ) ) ) {
+                       || LinkFilter::matchEntry( $rev->getContent( Revision::RAW ), $domain ) )
+               ) {
                        $rev = $rev->getPrevious();
                }
 
index 22fd05f..eb7d7b1 100644 (file)
@@ -69,6 +69,7 @@ class WatchlistCleanup extends TableCleanup {
                                . "({$row->wl_namespace}, \"{$row->wl_title}\")\n" );
                        $updated = $this->removeWatch( $row );
                        $this->progress( $updated );
+
                        return;
                }
                $this->progress( 0 );
@@ -77,12 +78,16 @@ class WatchlistCleanup extends TableCleanup {
        private function removeWatch( $row ) {
                if ( !$this->dryrun && $this->hasOption( 'fix' ) ) {
                        $dbw = wfGetDB( DB_MASTER );
-                       $dbw->delete( 'watchlist', array(
+                       $dbw->delete(
+                               'watchlist', array(
                                'wl_user' => $row->wl_user,
                                'wl_namespace' => $row->wl_namespace,
                                'wl_title' => $row->wl_title ),
-                       __METHOD__ );
+                               __METHOD__
+                       );
+
                        $this->output( "- removed\n" );
+
                        return 1;
                } else {
                        return 0;
index 3929a5b..e67c439 100644 (file)
@@ -116,6 +116,7 @@ class CompareParsers extends DumpIterator {
                if ( !$this->stripParametersEnabled ) {
                        return $text;
                }
+
                return preg_replace( '/(<a) [^>]+>/', '$1>', $text );
        }
 
@@ -179,10 +180,9 @@ class CompareParsers extends DumpIterator {
                /* Look for the parser in a file appropiately named in the current folder */
                if ( !class_exists( $parserName ) && file_exists( "$parserName.php" ) ) {
                        global $wgAutoloadClasses;
-                       $wgAutoloadClasses[ $parserName ] = realpath( '.' ) . "/$parserName.php";
+                       $wgAutoloadClasses[$parserName] = realpath( '.' ) . "/$parserName.php";
                }
        }
-
 }
 
 $maintClass = "CompareParsers";
index 6840a01..11a81eb 100644 (file)
@@ -71,6 +71,7 @@ class ConvertLinks extends Maintenance {
                $type = $dbw->getType();
                if ( $type != 'mysql' ) {
                        $this->output( "Link table conversion not necessary for $type\n" );
+
                        return;
                }
 
@@ -111,12 +112,14 @@ class ConvertLinks extends Maintenance {
 
                if ( $dbw->tableExists( 'pagelinks' ) ) {
                        $this->output( "...have pagelinks; skipping old links table updates\n" );
+
                        return;
                }
 
                $res = $dbw->query( "SELECT l_from FROM $links LIMIT 1" );
                if ( $dbw->fieldType( $res, 0 ) == "int" ) {
                        $this->output( "Schema already converted\n" );
+
                        return;
                }
 
@@ -131,7 +134,7 @@ class ConvertLinks extends Maintenance {
                } else {
                        $fh = false;
                        if ( $this->logPerformance ) {
-                               $fh = fopen ( $perfLogFilename, "w" );
+                               $fh = fopen( $perfLogFilename, "w" );
                                if ( !$fh ) {
                                        $this->error( "Couldn't open $perfLogFilename" );
                                        $this->logPerformance = false;
@@ -140,8 +143,8 @@ class ConvertLinks extends Maintenance {
                        $baseTime = $startTime = $this->getMicroTime();
                        # Create a title -> cur_id map
                        $this->output( "Loading IDs from $cur table...\n" );
-                       $this->performanceLog ( $fh, "Reading $numRows rows from cur table...\n" );
-                       $this->performanceLog ( $fh, "rows read vs seconds elapsed:\n" );
+                       $this->performanceLog( $fh, "Reading $numRows rows from cur table...\n" );
+                       $this->performanceLog( $fh, "rows read vs seconds elapsed:\n" );
 
                        $dbw->bufferResults( false );
                        $res = $dbw->query( "SELECT cur_namespace,cur_title,cur_id FROM $cur" );
@@ -239,7 +242,7 @@ class ConvertLinks extends Maintenance {
                                "Total execution time: " . ( $this->getMicroTime() - $startTime ) . " seconds.\n"
                        );
                        if ( $this->logPerformance ) {
-                               fclose ( $fh );
+                               fclose( $fh );
                        }
                }
                # --------------------------------------------------------------------
@@ -268,6 +271,7 @@ class ConvertLinks extends Maintenance {
 
                if ( !( $dbConn->isOpen() ) ) {
                        $this->output( "Opening connection to database failed.\n" );
+
                        return;
                }
                $links_temp = $dbConn->tableName( 'links_temp' );
@@ -279,14 +283,14 @@ class ConvertLinks extends Maintenance {
                $this->output( "Creating temporary links table..." );
                if ( $this->hasOption( 'noKeys' ) ) {
                        $dbConn->query( "CREATE TABLE $links_temp ( " .
-                       "l_from int(8) unsigned NOT NULL default '0', " .
-                       "l_to int(8) unsigned NOT NULL default '0')" );
+                               "l_from int(8) unsigned NOT NULL default '0', " .
+                               "l_to int(8) unsigned NOT NULL default '0')" );
                } else {
                        $dbConn->query( "CREATE TABLE $links_temp ( " .
-                       "l_from int(8) unsigned NOT NULL default '0', " .
-                       "l_to int(8) unsigned NOT NULL default '0', " .
-                       "UNIQUE KEY l_from(l_from,l_to), " .
-                       "KEY (l_to))" );
+                               "l_from int(8) unsigned NOT NULL default '0', " .
+                               "l_to int(8) unsigned NOT NULL default '0', " .
+                               "UNIQUE KEY l_from(l_from,l_to), " .
+                               "KEY (l_to))" );
                }
                $this->output( " done.\n\n" );
        }
@@ -299,6 +303,7 @@ class ConvertLinks extends Maintenance {
 
        private function getMicroTime() { # return time in seconds, with microsecond accuracy
                list( $usec, $sec ) = explode( " ", microtime() );
+
                return ( (float)$usec + (float)$sec );
        }
 }
index 24be2b4..bf57244 100644 (file)
@@ -46,6 +46,7 @@ class ConvertUserOptions extends Maintenance {
 
                if ( !$dbw->fieldExists( 'user', 'user_options', __METHOD__ ) ) {
                        $this->output( "nothing to migrate. " );
+
                        return;
                }
                while ( $id !== null ) {
index 86e47af..9ed63c3 100644 (file)
@@ -373,6 +373,7 @@ class CopyFileBackend extends Maintenance {
                        $same = ( $src->getFileSha1Base36( array( 'src' => $sPath, 'latest' => 1 ) )
                                === $dst->getFileSha1Base36( array( 'src' => $dPath, 'latest' => 1 ) ) );
                }
+
                return $same;
        }
 }
index c5a7827..a9c9547 100644 (file)
@@ -89,6 +89,7 @@ class CopyJobQueue extends Maintenance {
                        $totalOK += count( $batch );
                        $dst->waitForBackups();
                }
+
                return array( $total, $totalOK );
        }
 }
index a8de640..79f7254 100644 (file)
@@ -76,6 +76,7 @@ class CreateAndPromote extends Maintenance {
 
                if ( $exists && !$password && count( $promotions ) === 0 ) {
                        $this->output( "Account exists and nothing to do.\n" );
+
                        return;
                } elseif ( count( $promotions ) !== 0 ) {
                        $promoText = "User:{$username} into " . implode( ', ', $promotions ) . "...\n";
index d58e9a4..33da666 100644 (file)
@@ -49,9 +49,13 @@ class DeleteArchivedFilesImplementation {
                                $sha1 = LocalRepo::getHashFromKey( $key );
                        }
                        // Check if the file is used anywhere...
-                       $inuse = $dbw->selectField( 'oldimage', '1',
-                               array( 'oi_sha1' => $sha1,
-                               'oi_deleted & ' . File::DELETED_FILE => File::DELETED_FILE ),
+                       $inuse = $dbw->selectField(
+                               'oldimage',
+                               '1',
+                               array(
+                                       'oi_sha1' => $sha1,
+                                       'oi_deleted & ' . File::DELETED_FILE => File::DELETED_FILE
+                               ),
                                __METHOD__,
                                array( 'FOR UPDATE' )
                        );
index ad7b54d..286b1f2 100644 (file)
@@ -47,6 +47,7 @@ class DeleteArchivedFiles extends Maintenance {
        public function execute() {
                if ( !$this->hasOption( 'delete' ) ) {
                        $this->output( "Use --delete to actually confirm this script\n" );
+
                        return;
                }
                $force = $this->hasOption( 'force' );
index 62465ab..ed620ee 100644 (file)
@@ -30,7 +30,6 @@ class DeleteArchivedRevisionsImplementation {
 
        /**
         * Perform the delete on archived revisions.
-
         * @param object $maint An object (typically of class Maintenance)
         * that implements two methods: handleOutput() and
         * purgeRedundantText().  See Maintenance for a description of
index b21d950..a751396 100644 (file)
@@ -3,11 +3,11 @@
  * Deletes a batch of pages.
  * Usage: php deleteBatch.php [-u <user>] [-r <reason>] [-i <interval>] [listfile]
  * where
- *     [listfile] is a file where each line contains the title of a page to be
- *             deleted, standard input is used if listfile is not given.
- *     <user> is the username
- *     <reason> is the delete reason
- *     <interval> is the number of seconds to sleep for after each delete
+ *   [listfile] is a file where each line contains the title of a page to be
+ *     deleted, standard input is used if listfile is not given.
+ *   <user> is the username
+ *   <reason> is the delete reason
+ *   <interval> is the number of seconds to sleep for after each delete
  *
  * This program is free software; you can redistribute it and/or modify
  * it under the terms of the GNU General Public License as published by
index 7d8c80e..5aeeb8e 100644 (file)
@@ -34,7 +34,7 @@ class DeleteDefaultMessages extends Maintenance {
        public function __construct() {
                parent::__construct();
                $this->mDescription = "Deletes all pages in the MediaWiki namespace" .
-                                                               " which were last edited by \"MediaWiki default\"";
+                       " which were last edited by \"MediaWiki default\"";
        }
 
        public function execute() {
@@ -54,6 +54,7 @@ class DeleteDefaultMessages extends Maintenance {
                if ( $dbr->numRows( $res ) == 0 ) {
                        # No more messages left
                        $this->output( "done.\n" );
+
                        return;
                }
 
index 8175891..c30a86e 100644 (file)
@@ -130,6 +130,7 @@ class DeleteEqualMessages extends Maintenance {
                if ( $messageInfo['equalPages'] === 0 ) {
                        // No more equal messages left
                        $this->output( "\ndone.\n" );
+
                        return;
                }
 
@@ -151,6 +152,7 @@ class DeleteEqualMessages extends Maintenance {
                                $this->output( " (include --delete-talk to also delete the talk pages)" );
                        }
                        $this->output( "\n" );
+
                        return;
                }
 
index b44a424..4799e5e 100644 (file)
@@ -80,6 +80,7 @@ class DeleteImageCache extends Maintenance {
 
        private function getImageCount() {
                $dbr = wfGetDB( DB_SLAVE );
+
                return $dbr->selectField( 'image', 'COUNT(*)', array(), __METHOD__ );
        }
 }
index 31f206d..818ee36 100644 (file)
@@ -42,29 +42,31 @@ class DeleteRevision extends Maintenance {
                }
 
                $this->output( "Deleting revision(s) " . implode( ',', $this->mArgs ) .
-                                               " from " . wfWikiID() . "...\n" );
+                       " from " . wfWikiID() . "...\n" );
                $dbw = wfGetDB( DB_MASTER );
 
                $affected = 0;
                foreach ( $this->mArgs as $revID ) {
                        $dbw->insertSelect( 'archive', array( 'page', 'revision' ),
                                array(
-                                       'ar_namespace'  => 'page_namespace',
-                                       'ar_title'      => 'page_title',
-                                       'ar_page_id'    => 'page_id',
-                                       'ar_comment'    => 'rev_comment',
-                                       'ar_user'       => 'rev_user',
-                                       'ar_user_text'  => 'rev_user_text',
-                                       'ar_timestamp'  => 'rev_timestamp',
+                                       'ar_namespace' => 'page_namespace',
+                                       'ar_title' => 'page_title',
+                                       'ar_page_id' => 'page_id',
+                                       'ar_comment' => 'rev_comment',
+                                       'ar_user' => 'rev_user',
+                                       'ar_user_text' => 'rev_user_text',
+                                       'ar_timestamp' => 'rev_timestamp',
                                        'ar_minor_edit' => 'rev_minor_edit',
-                                       'ar_rev_id'     => 'rev_id',
-                                       'ar_text_id'    => 'rev_text_id',
-                                       'ar_deleted'    => 'rev_deleted',
-                                       'ar_len'        => 'rev_len',
-                               ), array(
+                                       'ar_rev_id' => 'rev_id',
+                                       'ar_text_id' => 'rev_text_id',
+                                       'ar_deleted' => 'rev_deleted',
+                                       'ar_len' => 'rev_len',
+                               ),
+                               array(
                                        'rev_id' => $revID,
                                        'page_id = rev_page'
-                               ), __METHOD__
+                               ),
+                               __METHOD__
                        );
                        if ( !$dbw->affectedRows() ) {
                                $this->output( "Revision $revID not found\n" );
index a3cc0ba..246d6fc 100644 (file)
@@ -59,6 +59,7 @@ if ( $ext == 'php' || $ext == 'php5' ) {
        # the php webserver will discard post data and things like login
        # will not function in the dev environment.
        require $file;
+
        return true;
 }
 $mime = false;
@@ -93,6 +94,7 @@ if ( $mime ) {
        header( "Content-Length: " . filesize( $file ) );
        // Stream that out to the browser
        fpassthru( $f );
+
        return true;
 }
 
index 02bfd60..18c78dc 100644 (file)
@@ -127,5 +127,5 @@ Fancy stuff: (Works? Add examples please.)
   --filter=<type>[:<options>] Add a filter on an output branch
 
 ENDS
-);
+       );
 }
index 078c598..4b2ff71 100644 (file)
@@ -123,6 +123,7 @@ abstract class DumpIterator extends Maintenance {
                $title = $rev->getTitle();
                if ( !$title ) {
                        $this->error( "Got bogus revision with null title!" );
+
                        return;
                }
 
index 71895bd..7c17607 100644 (file)
@@ -61,5 +61,5 @@ Options:
   --spawn        Spawn a subprocess for loading text records
   --help      Display this help message
 ENDS
-);
+       );
 }
index d6c70f8..9d53f07 100644 (file)
@@ -64,7 +64,7 @@ By default, outputs relative paths against the parent directory of \$wgUploadDir
                                $this->mSharedSupplement = true;
                        }
                }
-               $this->{ $this->mAction } ( $this->mShared );
+               $this->{$this->mAction} ( $this->mShared );
                if ( $this->mSharedSupplement ) {
                        $this->fetchUsed( true );
                }
index df5a208..fc676b8 100644 (file)
@@ -37,11 +37,11 @@ class FetchText extends Maintenance {
 
        /**
         * returns a string containing the following in order:
-        *       textid
-        *       \n
-        *       length of text (-1 on error = failure to retrieve/unserialize/gunzip/etc)
-        *       \n
-        *       text  (may be empty)
+        *   textid
+        *   \n
+        *   length of text (-1 on error = failure to retrieve/unserialize/gunzip/etc)
+        *   \n
+        *   text  (may be empty)
         *
         * note that that the text string itself is *not* followed by newline
         */
@@ -59,8 +59,7 @@ class FetchText extends Maintenance {
                        if ( $text === false ) {
                                # actual error, not zero-length text
                                $textLen = "-1";
-                       }
-                       else {
+                       } else {
                                $textLen = strlen( $text );
                        }
                        $this->output( $textId . "\n" . $textLen . "\n" . $text );
@@ -83,6 +82,7 @@ class FetchText extends Maintenance {
                if ( $text === false ) {
                        return false;
                }
+
                return $text;
        }
 }
index 7c6c824..86c01f4 100644 (file)
@@ -146,10 +146,11 @@ class FindHooks extends Maintenance {
         * @return array Array of documented hooks
         */
        private function getHooksFromLocalDoc( $doc ) {
-                       $m = array();
-                       $content = file_get_contents( $doc );
-                       preg_match_all( "/\n'(.*?)':/", $content, $m );
-                       return array_unique( $m[1] );
+               $m = array();
+               $content = file_get_contents( $doc );
+               preg_match_all( "/\n'(.*?)':/", $content, $m );
+
+               return array_unique( $m[1] );
        }
 
        /**
@@ -157,35 +158,36 @@ class FindHooks extends Maintenance {
         * @return array of documented hooks
         */
        private function getHooksFromOnlineDoc() {
-                       // All hooks
-                       $allhookdata = Http::get(
-                               'http://www.mediawiki.org/w/api.php?action=query&list=categorymembers&'
-                                       . 'cmtitle=Category:MediaWiki_hooks&cmlimit=500&format=php'
-                       );
-                       $allhookdata = unserialize( $allhookdata );
-                       $allhooks = array();
-                       foreach ( $allhookdata['query']['categorymembers'] as $page ) {
-                               $found = preg_match( '/Manual\:Hooks\/([a-zA-Z0-9- :]+)/', $page['title'], $matches );
-                               if ( $found ) {
-                                       $hook = str_replace( ' ', '_', $matches[1] );
-                                       $allhooks[] = $hook;
-                               }
+               // All hooks
+               $allhookdata = Http::get(
+                       'http://www.mediawiki.org/w/api.php?action=query&list=categorymembers&'
+                       . 'cmtitle=Category:MediaWiki_hooks&cmlimit=500&format=php'
+               );
+               $allhookdata = unserialize( $allhookdata );
+               $allhooks = array();
+               foreach ( $allhookdata['query']['categorymembers'] as $page ) {
+                       $found = preg_match( '/Manual\:Hooks\/([a-zA-Z0-9- :]+)/', $page['title'], $matches );
+                       if ( $found ) {
+                               $hook = str_replace( ' ', '_', $matches[1] );
+                               $allhooks[] = $hook;
                        }
-                       // Removed hooks
-                       $oldhookdata = Http::get(
-                               'http://www.mediawiki.org/w/api.php?action=query&list=categorymembers&'
-                                       . 'cmtitle=Category:Removed_hooks&cmlimit=500&format=php'
-                       );
-                       $oldhookdata = unserialize( $oldhookdata );
-                       $removed = array();
-                       foreach ( $oldhookdata['query']['categorymembers'] as $page ) {
-                               $found = preg_match( '/Manual\:Hooks\/([a-zA-Z0-9- :]+)/', $page['title'], $matches );
-                               if ( $found ) {
-                                       $hook = str_replace( ' ', '_', $matches[1] );
-                                       $removed[] = $hook;
-                               }
+               }
+               // Removed hooks
+               $oldhookdata = Http::get(
+                       'http://www.mediawiki.org/w/api.php?action=query&list=categorymembers&'
+                       . 'cmtitle=Category:Removed_hooks&cmlimit=500&format=php'
+               );
+               $oldhookdata = unserialize( $oldhookdata );
+               $removed = array();
+               foreach ( $oldhookdata['query']['categorymembers'] as $page ) {
+                       $found = preg_match( '/Manual\:Hooks\/([a-zA-Z0-9- :]+)/', $page['title'], $matches );
+                       if ( $found ) {
+                               $hook = str_replace( ' ', '_', $matches[1] );
+                               $removed[] = $hook;
                        }
-                       return array_diff( $allhooks, $removed );
+               }
+
+               return array_diff( $allhooks, $removed );
        }
 
        /**
@@ -221,6 +223,7 @@ class FindHooks extends Maintenance {
                        }
                        closedir( $dh );
                }
+
                return $hooks;
        }
 
@@ -238,6 +241,7 @@ class FindHooks extends Maintenance {
                foreach ( $m[0] as $match ) {
                        $list[] = $match . "(" . $file . ")";
                }
+
                return $list;
        }
 
@@ -258,6 +262,7 @@ class FindHooks extends Maintenance {
                        }
                        closedir( $dh );
                }
+
                return $hooks;
        }
 
index af8a58e..0b3cdba 100644 (file)
@@ -85,6 +85,7 @@ class FixDoubleRedirects extends Maintenance {
 
                if ( !$res->numRows() ) {
                        $this->output( "No double redirects found.\n" );
+
                        return;
                }