For the maintenance/ directory files:
authorNick Jenkins <nickj@users.mediawiki.org>
Fri, 12 Jan 2007 05:50:03 +0000 (05:50 +0000)
committerNick Jenkins <nickj@users.mediawiki.org>
Fri, 12 Jan 2007 05:50:03 +0000 (05:50 +0000)
* Removing unused local vars.
* Removing unused global declarations.
* removing one or two pass-by-refs parameter declarations where not required by PHP5.
* Adding some local variable declarations / initializations (initialized to either to array(), null) to keep static code analyzer happy.
* Changing lines like this: "extract( $dbw->tableNames( 'page', 'archive' ) );" to be like this: "list ($page, $archive) = $dbw->tableNamesN( 'page', 'archive' );".
* Add one or two braces to if-else blocks.

36 files changed:
maintenance/FiveUpgrade.inc
maintenance/addwiki.php
maintenance/backup.inc
maintenance/cleanupCaps.php
maintenance/cleanupSpam.php
maintenance/cleanupTable.inc
maintenance/cleanupTitles.php
maintenance/cleanupWatchlist.php
maintenance/convertLinks.inc
maintenance/dumpHTML.inc
maintenance/dumpInterwiki.inc
maintenance/findhooks.php
maintenance/fixSlaveDesync.php
maintenance/importDump.php
maintenance/importImages.inc.php
maintenance/importLogs.inc
maintenance/importPhase2.php
maintenance/importUseModWiki.php
maintenance/installExtension.php
maintenance/language/checkExtensioni18n.php
maintenance/language/checkLanguage.inc
maintenance/language/date-formats.php
maintenance/language/diffLanguage.php
maintenance/language/rebuildLanguage.php
maintenance/language/writeMessagesArray.inc
maintenance/parserTests.inc
maintenance/rebuildImages.php
maintenance/rebuildInterwiki.inc
maintenance/rebuildrecentchanges.inc
maintenance/rebuildtextindex.inc
maintenance/storage/checkStorage.php
maintenance/storage/compressOld.inc
maintenance/storage/resolveStubs.php
maintenance/updateArticleCount.inc.php
maintenance/updaters.inc
maintenance/userDupes.inc

index 531f175..8b7e613 100644 (file)
@@ -11,7 +11,6 @@ define( 'MW_UPGRADE_CALLBACK', null  ); // for self-documentation only
 
 class FiveUpgrade {
        function FiveUpgrade() {
-               global $wgDatabase;
                $this->conversionTables = $this->prepareWindows1252();
 
                $this->dbw =& $this->newConnection();
@@ -275,7 +274,6 @@ class FiveUpgrade {
                $name_temp = $name . '_temp';
                $this->log( "Migrating $name table to $name_temp..." );
 
-               $table      = $this->dbw->tableName( $name );
                $table_temp = $this->dbw->tableName( $name_temp );
 
                // Create temporary table; we're going to copy everything in there,
@@ -335,7 +333,7 @@ class FiveUpgrade {
 
                $this->log( "...converting from cur/old to page/revision/text DB structure." );
 
-               extract( $this->dbw->tableNames( 'cur', 'old', 'page', 'revision', 'text' ) );
+               list ($cur, $old, $page, $revision, $text) = $this->dbw->tableNamesN( 'cur', 'old', 'page', 'revision', 'text' );
 
                $this->log( "Creating page and revision tables..." );
                $this->dbw->query("CREATE TABLE $page (
@@ -497,7 +495,7 @@ class FiveUpgrade {
        function upgradeLinks() {
                $fname = 'FiveUpgrade::upgradeLinks';
                $chunksize = 200;
-               extract( $this->dbw->tableNames( 'links', 'brokenlinks', 'pagelinks', 'cur' ) );
+               list ($links, $brokenlinks, $pagelinks, $cur) = $this->dbw->tableNamesN( 'links', 'brokenlinks', 'pagelinks', 'cur' );
 
                $this->log( 'Checking for interwiki table change in case of bogus items...' );
                if( $this->dbw->fieldExists( 'interwiki', 'iw_trans' ) ) {
@@ -836,7 +834,7 @@ END;
                $fname = 'FiveUpgrade::upgradeWatchlist';
                $chunksize = 100;
 
-               extract( $this->dbw->tableNames( 'watchlist', 'watchlist_temp' ) );
+               list ($watchlist, $watchlist_temp) = $this->dbw->tableNamesN( 'watchlist', 'watchlist_temp' );
 
                $this->log( 'Migrating watchlist table to watchlist_temp...' );
                $this->dbw->query(
@@ -875,7 +873,6 @@ END;
 
                $add = array();
                while( $row = $this->dbr->fetchObject( $result ) ) {
-                       $now = $this->dbw->timestamp();
                        $add[] = array(
                                'wl_user'      =>                        $row->wl_user,
                                'wl_namespace' => Namespace::getSubject( $row->wl_namespace ),
index b784363..5a556bb 100644 (file)
@@ -49,6 +49,7 @@ function addWiki( $lang, $site, $dbName )
                print "Initialising external storage $store...\n";
                global $wgDBuser, $wgDBpassword, $wgExternalServers;
                foreach ( $stores as $storeURL ) {
+                       $m = array();
                        if ( !preg_match( '!^DB://(.*)$!', $storeURL, $m ) ) {
                                continue;
                        }
index 1a8ff4f..c5a917c 100644 (file)
@@ -98,8 +98,9 @@ class BackupDumper {
                $sink = null;
                $sinks = array();
                foreach( $args as $arg ) {
+                       $matches = array();
                        if( preg_match( '/^--(.+?)(?:=(.+?)(?::(.+?))?)?$/', $arg, $matches ) ) {
-                               @list( $full, $opt, $val, $param ) = $matches;
+                               @list( /* $full */ , $opt, $val, $param ) = $matches;
                                switch( $opt ) {
                                case "plugin":
                                        $this->loadPlugin( $val, $param );
index afcd1b3..8864377 100644 (file)
@@ -100,7 +100,7 @@ class CapsCleanup extends FiveUpgrade {
                $result = $this->dbr->query( $sql, $fname );
 
                while( $row = $this->dbr->fetchObject( $result ) ) {
-                       $updated = call_user_func( $callback, $row );
+                       call_user_func( $callback, $row );
                }
                $this->log( "Finished $table... $this->updated of $this->processed rows updated" );
                $this->dbr->freeResult( $result );
@@ -137,7 +137,6 @@ class CapsCleanup extends FiveUpgrade {
 
                        if( $row->page_namespace == $this->namespace ) {
                                $talk = $target->getTalkPage();
-                               $xrow = $row;
                                $row->page_namespace = $talk->getNamespace();
                                if( $talk->exists() ) {
                                        return $this->processPage( $row );
index 65d6bc4..2ad0a9c 100644 (file)
@@ -12,7 +12,6 @@ function cleanupArticle( $id, $domain ) {
 
        print $title->getPrefixedDBkey() . " ...";
        $rev = Revision::newFromTitle( $title );
-       $reverted = false;
        $revId = $rev->getId();
        $currentRevId = $revId;
        $regex = LinkFilter::makeRegex( $domain );
index cc551bc..cf33e8f 100644 (file)
@@ -69,7 +69,7 @@ abstract class TableCleanup extends FiveUpgrade {
                $result = $this->dbr->query( $sql, $fname );
 
                while( $row = $this->dbr->fetchObject( $result ) ) {
-                       $updated = call_user_func( $callback, $row );
+                       call_user_func( $callback, $row );
                }
                $this->log( "Finished $table... $this->updated of $this->processed rows updated" );
                $this->dbr->freeResult( $result );
index 12e07b6..a98ecf2 100644 (file)
@@ -38,8 +38,6 @@ class TitleCleanup extends TableCleanup {
        }
 
        function processPage( $row ) {
-               global $wgContLang;
-
                $current = Title::makeTitle( $row->page_namespace, $row->page_title );
                $display = $current->getPrefixedText();
 
index 027859a..259b25e 100644 (file)
@@ -95,15 +95,13 @@ class WatchlistCleanup extends FiveUpgrade {
                $result = $this->dbr->query( $sql, $fname );
 
                while( $row = $this->dbr->fetchObject( $result ) ) {
-                       $updated = call_user_func( $callback, $row );
+                       call_user_func( $callback, $row );
                }
                $this->log( "Finished $table... $this->updated of $this->processed rows updated" );
                $this->dbr->freeResult( $result );
        }
 
        function processEntry( $row ) {
-               global $wgContLang;
-
                $current = Title::makeTitle( $row->wl_namespace, $row->wl_title );
                $display = $current->getPrefixedText();
 
index 5f8c27a..b63a9cf 100644 (file)
@@ -18,7 +18,7 @@ function convertLinks() {
        global $wgLang, $wgDBserver, $wgDBadminuser, $wgDBadminpassword, $wgDBname;
        global $noKeys, $logPerformance, $fh;
 
-       $numRows = $tuplesAdded = $numBadLinks = $curRowsRead = 0; #counters etc
+       $tuplesAdded = $numBadLinks = $curRowsRead = 0; #counters etc
        $totalTuplesInserted = 0; # total tuples INSERTed into links_temp
 
        $reportCurReadProgress = true; #whether or not to give progress reports while reading IDs from cur table
@@ -44,7 +44,7 @@ function convertLinks() {
        #--------------------------------------------------------------------
 
        $dbw =& wfGetDB( DB_MASTER );
-       extract( $dbw->tableNames( 'cur', 'links', 'links_temp', 'links_backup' ) );
+       list ($cur, $links, $links_temp, $links_backup) = $dbw->tableNamesN( 'cur', 'links', 'links_temp', 'links_backup' );
 
        $res = $dbw->query( "SELECT l_from FROM $links LIMIT 1" );
        if ( $dbw->fieldType( $res, 0 ) == "int" ) {
index 702c7df..15d6871 100644 (file)
@@ -244,7 +244,6 @@ class DumpHTML {
         * have a local image
         */
        function doLocalImageDescriptions() {
-               global $wgSharedUploadDirectory;
                $chunkSize = 1000;
 
                $dbr =& wfGetDB( DB_SLAVE );
@@ -443,9 +442,6 @@ class DumpHTML {
 
        /** Write an article specified by title */
        function doArticle( $title ) {
-               global $wgTitle, $wgSharedUploadPath, $wgSharedUploadDirectory;
-               global $wgUploadDirectory;
-
                if ( $this->noOverwrite ) {
                        $fileName = $this->dest.'/'.$this->getHashedFilename( $title );
                        if ( file_exists( $fileName ) ) {
@@ -496,7 +492,7 @@ class DumpHTML {
        }
 
        /** Write the given text to the file identified by the given title object */
-       function writeArticle( &$title, $text ) {
+       function writeArticle( $title, $text ) {
                $filename = $this->getHashedFilename( $title );
 
                # Temporary hack for current dump, this should be moved to 
@@ -536,7 +532,7 @@ class DumpHTML {
 
        /** Set up globals required for parsing */
        function setupGlobals( $currentDepth = NULL ) {
-               global $wgUser, $wgTitle, $wgStylePath, $wgArticlePath, $wgMathPath;
+               global $wgUser, $wgStylePath, $wgArticlePath, $wgMathPath;
                global $wgUploadPath, $wgLogo, $wgMaxCredits, $wgSharedUploadPath;
                global $wgHideInterlanguageLinks, $wgUploadDirectory, $wgThumbnailScriptPath;
                global $wgSharedThumbnailScriptPath, $wgEnableParserCache, $wgHooks, $wgServer;
@@ -623,7 +619,7 @@ class DumpHTML {
        }
 
        /** Reads the content of a title object, executes the skin and captures the result */
-       function getArticleHTML( &$title ) {
+       function getArticleHTML( $title ) {
                global $wgOut, $wgTitle, $wgArticle, $wgUser;
 
                $linkCache =& LinkCache::singleton();
@@ -800,6 +796,7 @@ ENDTEXT;
 
                $url = false;
                if ( $query != '' ) {
+                       $params = array();
                        parse_str( $query, $params );
                        if ( isset($params['action']) && $params['action'] == 'raw' ) {
                                if ( $params['gen'] == 'css' || $params['gen'] == 'js' ) {
@@ -807,6 +804,7 @@ ENDTEXT;
                                } else {
                                        $file = $this->getFriendlyName( $title->getPrefixedDBkey() );
                                        // Clean up Monobook.css etc.
+                                       $matches = array();
                                        if ( preg_match( '/^(.*)\.(css|js)_[0-9a-f]{4}$/', $file, $matches ) ) {
                                                $file = $matches[1] . '.' . $matches[2];
                                        }
@@ -882,6 +880,7 @@ ENDTEXT;
                }
 
                # Split into characters
+               $m = array();
                preg_match_all( '/./us', $dbk, $m );
 
                $chars = $m[0];
index 2039f2d..26805f4 100644 (file)
@@ -106,8 +106,7 @@ function getRebuildInterwikiDump() {
                wfDie( "m:Interwiki_map not found" );
        }
 
-       $iwArray = array();
-        # Global iterwiki map
+       # Global iterwiki map
        foreach ( $lines as $line ) {
                if ( preg_match( '/^\|\s*(.*?)\s*\|\|\s*(.*?)\s*$/', $line, $matches ) ) {
                        $prefix = strtolower( $matches[1] );
@@ -130,7 +129,7 @@ function getRebuildInterwikiDump() {
         
         #Multilanguage sites
         foreach ($sites as $site) 
-            $sql .= makeLanguageLinks ( $site, "_".$site->suffix );
+            makeLanguageLinks ( $site, "_".$site->suffix );
 
 
         foreach ( $dblist as $db ) {
@@ -162,7 +161,6 @@ function getRebuildInterwikiDump() {
                                continue;
                        }
                        $lang = $matches[1];
-                       $host = "$lang." . $site->url;
 
                        # Lateral links
                        foreach ( $sites as $targetSite ) {
@@ -187,7 +185,7 @@ function getRebuildInterwikiDump() {
 
 # ------------------------------------------------------------------------------------------
 
-# Returns part of an INSERT statement, corresponding to all interlanguage links to a particular site
+# Executes part of an INSERT statement, corresponding to all interlanguage links to a particular site
 function makeLanguageLinks( &$site, $source ) {
        global $langlist, $languageAliases;
        # Actual languages with their own databases
index 4f446f2..97e6c57 100644 (file)
@@ -33,6 +33,7 @@ $pathinc = $IP . '/includes/';
 function getHooksFromDoc() {
        global $doc;
        $content = file_get_contents( $doc );
+       $m = array();
        preg_match_all( "/\n'(.*?)'/", $content, $m);
        return $m[1];
 }
@@ -44,6 +45,7 @@ function getHooksFromDoc() {
  */
 function getHooksFromFile( $file ) {
        $content = file_get_contents( $file );
+       $m = array();
        preg_match_all( "/wfRunHooks\(\s*\'(.*?)\'/", $content, $m);
        return $m[1];
 }
index d2dffe5..e62126a 100644 (file)
@@ -53,7 +53,6 @@ function findPageLatestCorruption() {
        
        global $slaveIndexes;
        foreach ( $slaveIndexes as $i ) {
-               $slaveIDs = array();
                $db =& wfGetDB( $i );
                $res = $db->select( 'page', array( 'page_id', 'page_latest' ), array( 'page_id<6054123' ), __METHOD__ );
                while ( $row = $db->fetchObject( $res ) ) {
@@ -122,7 +121,6 @@ function desyncFixPage( $pageID ) {
                if ( count( $missingIDs ) ) {
                        print "Found " . count( $missingIDs ) . " lost in master, copying from slave... ";
                        $dbFrom = $db;
-                       $dbTo = $dbw;
                        $found = true;
                        $toMaster = true;
                } else {
@@ -133,7 +131,6 @@ function desyncFixPage( $pageID ) {
                if ( count( $missingIDs ) ) {
                        print "Found " . count( $missingIDs ) . " missing revision(s), copying from master... ";
                        $dbFrom = $dbw;
-                       $dbTo = $db;
                        $found = true;
                        $toMaster = false;
                } else {
index 22709f6..b6778b7 100644 (file)
@@ -48,8 +48,8 @@ class BackupReader {
                        $this->progress( "Got bogus revision with null title!" );
                        return;
                }
-               $display = $title->getPrefixedText();
-               $timestamp = $rev->getTimestamp();
+               #$timestamp = $rev->getTimestamp();
+               #$display = $title->getPrefixedText();
                #echo "$display $timestamp\n";
 
                $this->revCount++;
index bf48c0c..e3ff69a 100644 (file)
@@ -20,7 +20,7 @@ function findFiles( $dir, $exts ) {
                if( $dhl = opendir( $dir ) ) {
                        while( ( $file = readdir( $dhl ) ) !== false ) {
                                if( is_file( $dir . '/' . $file ) ) {
-                                       list( $name, $ext ) = splitFilename( $dir . '/' . $file );
+                                       list( /* $name */, $ext ) = splitFilename( $dir . '/' . $file );
                                        if( array_search( strtolower( $ext ), $exts ) !== false )
                                                $files[] = $dir . '/' . $file;
                                }
index 154657c..a5b94cb 100644 (file)
@@ -77,6 +77,7 @@ class LogImporter {
                }
                $lines = explode( '<li>', $text );
                foreach( $lines as $line ) {
+                       $matches = array();
                        if( preg_match( '!^(.*)</li>!', $line, $matches ) ) {
                                $this->importLine( $matches[1] );
                        }
@@ -88,6 +89,7 @@ class LogImporter {
                # 01:55, 23 Aug 2004 - won't take in strtotimr
                # "Aug 23 2004 01:55" - seems ok
                # TODO: multilingual attempt to extract from the data in Language
+               $matches = array();
                if( preg_match( '/^(\d+:\d+(?::\d+)?), (.*)$/', $date, $matches ) ) {
                        $date = $matches[2] . ' ' . $matches[1];
                }
@@ -99,6 +101,7 @@ class LogImporter {
 
        function importLine( $line ) {
                foreach( $this->actions as $action => $regexp ) {
+                       $matches = array();
                        if( preg_match( $regexp, $line, $matches ) ) {
                                if( $this->dummy ) {
                                        #var_dump( $matches );
index a73657b..1f33850 100644 (file)
@@ -240,6 +240,7 @@ class Phase2Importer {
                $a = explode( "\n", $s );
 
                foreach ( $a as $l ) {
+                       $m = array();
                        if ( preg_match( "/^([A-Za-z0-9_]+)=(.*)/", $l, $m ) ) {
                                $ops[$m[1]] = $m[2];
                        }
index 15f5e44..b1c862d 100644 (file)
@@ -90,6 +90,7 @@ function importPageDirectory( $dir, $prefix = "" )
        echo "\n<!-- Checking page directory " . xmlCommentSafe( $dir ) . " -->\n";
        $mydir = opendir( $dir );
        while( $entry = readdir( $mydir ) ) {
+               $m = array();
                if( preg_match( '/^(.+)\.db$/', $entry, $m ) ) {
                        echo importPage( $prefix . $m[1] );
                } else {
@@ -121,7 +122,7 @@ function useModFilename( $title ) {
 
 function fetchPage( $title )
 {
-       global $FS,$FS1,$FS2,$FS3, $wgRootDirectory;
+       global $FS1,$FS2,$FS3, $wgRootDirectory;
 
        $fname = $wgRootDirectory . "/page/" . useModFilename( $title ) . ".db";
        if( !file_exists( $fname ) ) {
@@ -140,7 +141,7 @@ function fetchPage( $title )
 
 function fetchKeptPages( $title )
 {
-       global $FS,$FS1,$FS2,$FS3, $wgRootDirectory, $wgTimezoneCorrection;
+       global $FS1,$FS2,$FS3, $wgRootDirectory;
 
        $fname = $wgRootDirectory . "/keep/" . useModFilename( $title ) . ".kp";
        if( !file_exists( $fname ) ) return array();
@@ -235,13 +236,13 @@ END;
        # History
        $revisions = array_merge( $revisions, fetchKeptPages( $title ) );
        if(count( $revisions ) == 0 ) {
-               return $sql;
+               return NULL; // Was "$sql", which does not appear to be defined.
        }
 
        foreach( $revisions as $rev ) {
                $text      = xmlsafe( recodeText( $rev->text ) );
                $minor     = ($rev->minor ? '<minor/>' : '');
-               list( $userid, $username ) = checkUserCache( $rev->username, $rev->host );
+               list( /* $userid */ , $username ) = checkUserCache( $rev->username, $rev->host );
                $username  = xmlsafe( recodeText( $username ) );
                $timestamp = xmlsafe( timestamp2ISO8601( $rev->ts ) );
                $comment   = xmlsafe( recodeText( $rev->summary ) );
index f6b2dff..c5bb548 100644 (file)
@@ -46,18 +46,22 @@ class InstallerRepository {
        
        /*static*/ function makeRepository( $path, $type = NULL ) {
                if ( !$type ) {
+                       $m = array();
                        preg_match( '!(([-+\w]+)://)?.*?(\.[-\w\d.]+)?$!', $path, $m );
                        $proto = @$m[2];
                        
-                       if( !$proto ) $type = 'dir';
-                       else if ( ( $proto == 'http' || $proto == 'https' ) 
-                                  && preg_match( '!([^\w]svn|svn[^\w])!i', $path) ) $type = 'svn'; #HACK!
-                       else $type = $proto;
+                       if ( !$proto ) {
+                               $type = 'dir';
+                       } else if ( ( $proto == 'http' || $proto == 'https' ) && preg_match( '!([^\w]svn|svn[^\w])!i', $path) ) {
+                               $type = 'svn'; #HACK!
+                       } else  {
+                               $type = $proto;
+                       }
                }
                
-               if ( $type == 'dir' || $type == 'file' ) return new LocalInstallerRepository( $path );
-               else if ( $type == 'http' || $type == 'http' ) return new WebInstallerRepository( $path );
-               else return new SVNInstallerRepository( $path );
+               if ( $type == 'dir' || $type == 'file' ) { return new LocalInstallerRepository( $path ); }
+               else if ( $type == 'http' || $type == 'http' ) { return new WebInstallerRepository( $path ); }
+               else { return new SVNInstallerRepository( $path ); }
        }
 }
 
@@ -78,6 +82,7 @@ class LocalInstallerRepository extends InstallerRepository {
                        $n = basename($f);
                        
                        if ( !is_dir( $f ) ) {
+                               $m = array();
                                if ( !preg_match( '/(.*)\.(tgz|tar\.gz|zip)/', $n, $m ) ) continue;
                                $n = $m[1];
                        }
@@ -118,7 +123,8 @@ class WebInstallerRepository extends InstallerRepository {
                                print ( $txt );
                                return false;
                        }
-                       
+
+                       $m = array();
                        $ok = preg_match_all( '!<a\s[^>]*href\s*=\s*['."'".'"]([^/'."'".'"]+)\.tgz['."'".'"][^>]*>.*?</a>!si', $txt, $m, PREG_SET_ORDER ); 
                        if ( !$ok ) {
                                ExtensionInstaller::error( "listing index from {$this->path} does not match!" );
@@ -147,6 +153,7 @@ class SVNInstallerRepository extends InstallerRepository {
 
        function printListing( ) {
                ExtensionInstaller::note( "SVN list {$this->path}..." );
+               $code = null; // Shell Exec return value.
                $txt = wfShellExec( 'svn ls ' . escapeshellarg( $this->path ), $code );
                if ( $code !== 0 ) {
                        ExtensionInstaller::error( "svn list for {$this->path} failed!" );
@@ -156,6 +163,7 @@ class SVNInstallerRepository extends InstallerRepository {
                $ll = preg_split('/(\s*[\r\n]\s*)+/', $txt);
                
                foreach ( $ll as $line ) {
+                       $m = array();
                        if ( !preg_match('!^(.*)/$!', $line, $m) ) continue;
                        $n = $m[1];
                                  
@@ -180,6 +188,7 @@ class InstallerResource {
                $this->isdir= $isdir;
                $this->islocal = $islocal;
 
+               $m = array();
                preg_match( '!([-+\w]+://)?.*?(\.[-\w\d.]+)?$!', $path, $m );
 
                $this->protocol = @$m[1];
@@ -196,6 +205,7 @@ class InstallerResource {
                
                if ( $this->extensions == '.tgz' || $this->extensions == '.tar.gz' ) { #tgz file
                        ExtensionInstaller::note( "extracting $file..." );
+                       $code = null; // shell Exec return value.
                        wfShellExec( 'tar zxvf ' . escapeshellarg( $file ) . ' -C ' . escapeshellarg( $target ), $code );
                        
                        if ( $code !== 0 ) {
@@ -205,6 +215,7 @@ class InstallerResource {
                }
                else if ( $this->extensions == '.zip' ) { #zip file
                        ExtensionInstaller::note( "extracting $file..." );
+                       $code = null; // shell Exec return value.
                        wfShellExec( 'unzip ' . escapeshellarg( $file ) . ' -d ' . escapeshellarg( $target ) , $code );
                        
                        if ( $code !== 0 ) {
@@ -221,14 +232,15 @@ class InstallerResource {
        }        
 
        /*static*/ function makeResource( $url ) {
+               $m = array();
                preg_match( '!(([-+\w]+)://)?.*?(\.[-\w\d.]+)?$!', $url, $m );
                $proto = @$m[2];
                $ext = @$m[3];
                if ( $ext ) $ext = strtolower( $ext );
                
-               if ( !$proto ) return new LocalInstallerResource( $url, $ext ? false : true );
-               else if ( $ext && ( $proto == 'http' || $proto == 'http' || $proto == 'ftp' ) ) return new WebInstallerResource( $url );
-               else return new SVNInstallerResource( $url );
+               if ( !$proto ) { return new LocalInstallerResource( $url, $ext ? false : true ); }
+               else if ( $ext && ( $proto == 'http' || $proto == 'http' || $proto == 'ftp' ) ) { return new WebInstallerResource( $url ); }
+               else { return new SVNInstallerResource( $url ); }
        }
 }
 
@@ -274,6 +286,7 @@ class SVNInstallerResource extends InstallerResource {
         
        function fetch( $target ) {
                ExtensionInstaller::note( "SVN checkout of {$this->path}..." );
+               $code = null; // shell exec return val.
                wfShellExec( 'svn co ' . escapeshellarg( $this->path ) . ' ' . escapeshellarg( $target ), $code );
 
                if ( $code !== 0 ) {
@@ -342,9 +355,9 @@ class ExtensionInstaller {
                        $s = $this->prompt( $msg . " [yes/no]: ");
                        $s = strtolower( trim($s) );
                        
-                       if ( $s == 'yes' || $s == 'y' ) return true;
-                       else if ( $s == 'no' || $s == 'n' ) return false;
-                       else print "bad response: $s\n";                        
+                       if ( $s == 'yes' || $s == 'y' ) { return true; }
+                       else if ( $s == 'no' || $s == 'n' ) { return false; }
+                       else { print "bad response: $s\n"; }
                }
        }
 
@@ -566,6 +579,7 @@ if ( !$repos ) $repos = @$wgExtensionInstallerRepository;
 if ( !$repos && file_exists("$tgt/.svn") && is_dir("$tgt/.svn") ) {
        $svn = file_get_contents( "$tgt/.svn/entries" );
        
+       $m = array();
        if ( preg_match( '!url="(.*?)"!', $svn, $m ) ) {
                $repos = dirname( $m[1] ) . '/extensions';
        }
@@ -602,8 +616,8 @@ $src = isset( $args[1] ) ? $args[1] : $repository->getResource( $name );
 #TODO: detect $source mismatching $name !!
 
 $mode = EXTINST_WRITEPATCH;
-if ( isset( $options['nopatch'] ) || @$wgExtensionInstallerNoPatch ) $mode = EXTINST_NOPATCH;
-else if ( isset( $options['hotpatch'] ) || @$wgExtensionInstallerHotPatch ) $mode = EXTINST_HOTPATCH;
+if ( isset( $options['nopatch'] ) || @$wgExtensionInstallerNoPatch ) { $mode = EXTINST_NOPATCH; }
+else if ( isset( $options['hotpatch'] ) || @$wgExtensionInstallerHotPatch ) { $mode = EXTINST_HOTPATCH; }
 
 if ( !file_exists( "$tgt/LocalSettings.php" ) ) {
        die("can't find $tgt/LocalSettings.php\n");
index b0511f8..26ae5e1 100644 (file)
@@ -55,7 +55,6 @@ class extensionLanguages extends languages {
        private $mExtArray;
 
        function __construct( $ext18nFilename, $extArrayName ) {
-               $exif = false;
                $this->mExt18nFilename = $ext18nFilename;
                $this->mExtArrayName = $extArrayName;
 
@@ -74,6 +73,7 @@ class extensionLanguages extends languages {
                                // Provided array could not be found we try to guess it.
 
                                # Using the extension path ($m[1]) and filename ($m[2]):
+                               $m = array();
                                preg_match( '%.*/(.*)/(.*).i18n\.php%', $this->mExt18nFilename, $m);
                                $arPathCandidate = 'wg' . $m[1].'Messages';
                                $arFileCandidate = 'wg' . $m[2].'Messages';
index cd77791..bb61754 100644 (file)
@@ -6,7 +6,7 @@
  * @param $code The language code.
  */
 function checkLanguage( $wgLanguages, $code ) {
-       global $wgGeneralMessages, $wgRequiredMessagesNumber, $wgDisplayLevel, $wgLinks, $wgWikiLanguage, $wgChecks;
+       global $wgRequiredMessagesNumber, $wgDisplayLevel, $wgLinks, $wgWikiLanguage, $wgChecks;
 
        # Get messages
        $messages = $wgLanguages->getMessages( $code );
index 962c2f8..a0d46f0 100644 (file)
@@ -8,6 +8,7 @@ require_once( "$IP/maintenance/commandLine.inc" );
 
 foreach ( glob( "$IP/languages/messages/Messages*.php" ) as $filename ) {
        $base = basename( $filename );
+       $m = array();
        if ( !preg_match( '/Messages(.*)\.php$/', $base, $m ) ) {
                continue;
        }
index 2aaa590..b8d5e71 100644 (file)
@@ -75,7 +75,8 @@ function ucfirstlcrest($string) {
 function getMediawikiMessages($languageCode = 'En') {
 
        $foo = "wgAllMessages$languageCode";
-       global $$foo, $wgSkinNamesEn;
+       global $$foo;
+       global $wgSkinNamesEn; // potentially unused global declaration?
 
        // it might already be loaded in LocalSettings.php
        if(!isset($$foo)) {
@@ -83,7 +84,7 @@ function getMediawikiMessages($languageCode = 'En') {
                $langFile = $IP.'/languages/classes/Language'.$languageCode.'.php';
                if (file_exists( $langFile ) ) {
                        print "Including $langFile\n";
-                       global $wgNamespaceNamesEn;
+                       global $wgNamespaceNamesEn;  // potentially unused global declaration?
                        include($langFile);
                } else wfDie("ERROR: The file $langFile does not exist !\n");
        }
index 1643d30..e14c5ca 100644 (file)
@@ -17,7 +17,7 @@ require_once( 'writeMessagesArray.inc' );
  * @param $write Write to the messages file?
  */
 function rebuildLanguage( $code, $write ) {
-       global $wgLanguages, $wg;
+       global $wgLanguages;
 
        # Get messages
        $messages = $wgLanguages->getMessages( $code );
index 184e4d6..0792553 100644 (file)
@@ -18,7 +18,7 @@ require_once( 'messageTypes.inc' );
  * @return The PHP text.
  */
 function writeMessagesArray( $messages, $ignoredComments = false ) {
-       global $wgMessageStrucutre, $wgBlockComments, $wgMessageComments;
+       global $wgMessageStrucutre, $wgBlockComments;
 
        # Sort messages to blocks
        $sortedMessages['unknown'] = $messages;
index 94b0982..fca7696 100644 (file)
@@ -170,6 +170,7 @@ class ParserTest {
                $ok = true;
                while( false !== ($line = fgets( $infile ) ) ) {
                        $n++;
+                       $matches = array();
                        if( preg_match( '/^!!\s*(\w+)/', $line, $matches ) ) {
                                $section = strtolower( $matches[1] );
                                if( $section == 'endarticle') {
@@ -284,6 +285,7 @@ class ParserTest {
                        $options->setUseTex(true);
                }
 
+               $m = array();
                if (preg_match('/title=\[\[(.*)\]\]/', $opts, $m)) {
                        $titleText = $m[1];
                }
@@ -304,6 +306,7 @@ class ParserTest {
 
                $title =& Title::makeTitle( NS_MAIN, $titleText );
 
+               $matches = array();
                if (preg_match('/\\bpst\\b/i', $opts)) {
                        $out = $parser->preSaveTransform( $input, $title, $user, $options );
                } elseif (preg_match('/\\bmsg\\b/i', $opts)) {
@@ -356,6 +359,7 @@ class ParserTest {
                        $this->uploadDir = $this->setupUploadDir();
                }
 
+               $m = array();
                if( preg_match( '/language=([a-z]+(?:_[a-z]+)?)/', $opts, $m ) ) {
                        $lang = $m[1];
                } else {
index 38b89a4..4b896f8 100644 (file)
@@ -75,9 +75,9 @@ class ImageBuilder extends FiveUpgrade {
                        $portion * 100.0,
                        $this->table,
                        wfTimestamp( TS_DB, intval( $eta ) ),
-                       $completed,
+                       $completed,   // $completed does not appear to be defined.
                        $this->count,
-                       $rate,
+                       $rate,        // $rate does not appear to be defined.
                        $updateRate * 100.0 );
                flush();
        }
index d719fd4..458693d 100644 (file)
@@ -108,6 +108,7 @@ function getRebuildInterwikiSQL() {
        $iwArray = array();
 
        foreach ( $lines as $line ) {
+               $matches = array();
                if ( preg_match( '/^\|\s*(.*?)\s*\|\|\s*(https?:\/\/.*?)\s*$/', $line, $matches ) ) {
                        $prefix = strtolower( $matches[1] );
                        $url = $matches[2];
index e077da5..1f3cca7 100644 (file)
@@ -48,10 +48,7 @@ function rebuildRecentChangesTablePass1()
 function rebuildRecentChangesTablePass2()
 {
        $dbw =& wfGetDB( DB_MASTER );
-       extract( $dbw->tableNames( 'recentchanges', 'revision' ) );
-
-       $ns = $id = $count = 0;
-       $title = $ct =  "";
+       list ($recentchanges, $revision) = $dbw->tableNamesN( 'recentchanges', 'revision' );
 
        print( "Updating links...\n" );
 
index 5035b56..f72bf55 100644 (file)
@@ -36,7 +36,7 @@ function createTextIndex( &$database )
 
 function rebuildTextIndex( &$database )
 {
-       extract( $database->tableNames( 'page', 'revision', 'text', 'searchindex' ) );
+       list ($page, $revision, $text, $searchindex) = $database->tableNamesN( 'page', 'revision', 'text', 'searchindex' );
 
        $sql = "SELECT MAX(page_id) AS count FROM $page";
        $res = $database->query($sql, "rebuildTextIndex" );
index 579954d..3d193b4 100644 (file)
@@ -197,6 +197,7 @@ class CheckStorage
                                        array( 'old_id IN (' . implode( ',', $objectRevs ) . ')' ), $fname );
                                while ( $row = $dbr->fetchObject( $res ) ) {
                                        $oldId = $row->old_id;
+                                       $matches = array();
                                        if ( !preg_match( '/^O:(\d+):"(\w+)"/', $row->header, $matches ) ) {
                                                $this->error( 'restore text', "Error: invalid object header", $oldId );
                                                continue;
index 3c42684..30a294d 100644 (file)
@@ -16,7 +16,6 @@ function compressOldPages( $start = 0, $extdb = '' ) {
        print "Starting from old_id $start...\n";
        $dbw =& wfGetDB( DB_MASTER );
        do {
-               $end = $start + $chunksize;
                $res = $dbw->select( 'text', array( 'old_id','old_flags','old_namespace','old_title','old_text' ),
                        "old_id>=$start", $fname, array( 'ORDER BY' => 'old_id', 'LIMIT' => $chunksize, 'FOR UPDATE' ) );
                if( $dbw->numRows( $res ) == 0 ) {
@@ -133,9 +132,6 @@ function compressWithConcat( $startId, $maxChunkSize, $maxChunkFactor, $factorTh
        #$tables[] = 'page';
        #$conds[] = 'page_id=rev_page AND rev_id != page_latest';
 
-       $oldReadsSinceLastSlaveWait = 0;        #check slave lag periodically
-       $totalMatchingRevisions = 0;
-       $masterPos = false;
        for ( $pageId = $startId; $pageId <= $maxPageId; $pageId++ ) {
                wfWaitForSlaves( 5 );
 
@@ -164,7 +160,7 @@ function compressWithConcat( $startId, $maxChunkSize, $maxChunkFactor, $factorTh
                                'rev_id < ' . $pageRow->page_latest
                        ) + $conds
                );
-               exit;
+               exit; // FIXME: is this "exit" supposed to be here? If no, delete, else delete dead code below.
 
                # Load revisions
                $revRes = $dbw->select( $tables, $fields,
index e93d5c9..343222a 100644 (file)
@@ -19,7 +19,6 @@ function resolveStubs() {
        $fname = 'resolveStubs';
 
        $dbr =& wfGetDB( DB_SLAVE );
-       $dbw =& wfGetDB( DB_MASTER );
        $maxID = $dbr->selectField( 'text', 'MAX(old_id)', false, $fname );
        $blockSize = 10000;
        $numBlocks = intval( $maxID / $blockSize ) + 1;
@@ -30,9 +29,6 @@ function resolveStubs() {
                printf( "%5.2f%%\n", $b / $numBlocks * 100 );
                $start = intval($maxID / $numBlocks) * $b + 1;
                $end = intval($maxID / $numBlocks) * ($b + 1);
-               $stubs = array();
-               $flagsArray = array();
-
                
                $res = $dbr->select( 'text', array( 'old_id', 'old_text', 'old_flags' ),
                        "old_id>=$start AND old_id<=$end " .
index 7eaea74..328b111 100644 (file)
@@ -37,7 +37,7 @@ class ArticleCounter {
         * @return string
         */
        function makeSql() {
-               extract( $this->dbr->tableNames( 'page', 'pagelinks' ) );
+               list( $page, $pagelinks ) = $this->dbr->tableNamesN( 'page', 'pagelinks' );
                $nsset = $this->makeNsSet();
                return "SELECT DISTINCT page_namespace,page_title FROM $page,$pagelinks " .
                        "WHERE pl_from=page_id and page_namespace IN ( $nsset ) " .
index e781df0..79ec08c 100644 (file)
@@ -325,7 +325,7 @@ function do_schema_restructuring() {
                echo wfTimestamp();
                echo "......checking for duplicate entries.\n"; flush();
 
-               extract( $wgDatabase->tableNames( 'cur', 'old', 'page', 'revision', 'text' ) );
+               list ($cur, $old, $page, $revision, $text) = $wgDatabase->tableNamesN( 'cur', 'old', 'page', 'revision', 'text' );
 
                $rows = $wgDatabase->query( "SELECT cur_title, cur_namespace, COUNT(cur_namespace) AS c
                                FROM $cur GROUP BY cur_title, cur_namespace HAVING c>1", $fname );
@@ -482,7 +482,6 @@ function do_schema_restructuring() {
 
 function do_inverse_timestamp() {
        global $wgDatabase;
-       $fname="do_schema_restructuring";
        if( $wgDatabase->fieldExists( 'revision', 'inverse_timestamp' ) ) {
                echo "Removing revision.inverse_timestamp and fixing indexes... ";
                dbsource( archive( 'patch-inverse_timestamp.sql' ), $wgDatabase );
@@ -1203,7 +1202,7 @@ PGEND;
        $upgrade = str_replace( 'MWVERSION', $wgVersion, $upgrade );
        $upgrade = str_replace( 'THISVERSION', $oldversion, $upgrade );
        $upgrade = str_replace( 'SVERSION', $version, $upgrade );
-       $res = $wgDatabase->query("BEGIN;\n\n $upgrade\n\nCOMMIT;\n");
+       $wgDatabase->query("BEGIN;\n\n $upgrade\n\nCOMMIT;\n");
 
        return;
 }
index 9af66f1..00c4e34 100644 (file)
@@ -146,7 +146,7 @@ class UserDupes {
                $names = array_map( array( $this, 'lockTable' ), $set );
                $tables = implode( ',', $names );
 
-               $result = $this->db->query( "LOCK TABLES $tables", $fname );
+               $this->db->query( "LOCK TABLES $tables", $fname );
        }
 
        function lockTable( $table ) {
@@ -166,7 +166,7 @@ class UserDupes {
         */
        function unlock() {
                $fname = 'UserDupes::unlock';
-               $result = $this->db->query( "UNLOCK TABLES", $fname );
+               $this->db->query( "UNLOCK TABLES", $fname );
        }
 
        /**
@@ -301,7 +301,7 @@ class UserDupes {
        function reassignEditsOn( $table, $field, $from, $to ) {
                $fname = 'UserDupes::reassignEditsOn';
                echo "reassigning on $table... ";
-               $result = $this->db->update( $table,
+               $this->db->update( $table,
                        array( $field => $to ),
                        array( $field => $from ),
                        $fname );