From a78478c449cc53d9459ed669423e1e4d7d206f6f Mon Sep 17 00:00:00 2001 From: Nick Jenkins Date: Fri, 12 Jan 2007 05:50:03 +0000 Subject: [PATCH] For the maintenance/ directory files: * 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. --- maintenance/FiveUpgrade.inc | 9 ++-- maintenance/addwiki.php | 1 + maintenance/backup.inc | 3 +- maintenance/cleanupCaps.php | 3 +- maintenance/cleanupSpam.php | 1 - maintenance/cleanupTable.inc | 2 +- maintenance/cleanupTitles.php | 2 - maintenance/cleanupWatchlist.php | 4 +- maintenance/convertLinks.inc | 4 +- maintenance/dumpHTML.inc | 13 +++--- maintenance/dumpInterwiki.inc | 8 ++-- maintenance/findhooks.php | 2 + maintenance/fixSlaveDesync.php | 3 -- maintenance/importDump.php | 4 +- maintenance/importImages.inc.php | 2 +- maintenance/importLogs.inc | 3 ++ maintenance/importPhase2.php | 1 + maintenance/importUseModWiki.php | 9 ++-- maintenance/installExtension.php | 46 ++++++++++++++------- maintenance/language/checkExtensioni18n.php | 2 +- maintenance/language/checkLanguage.inc | 2 +- maintenance/language/date-formats.php | 1 + maintenance/language/diffLanguage.php | 5 ++- maintenance/language/rebuildLanguage.php | 2 +- maintenance/language/writeMessagesArray.inc | 2 +- maintenance/parserTests.inc | 4 ++ maintenance/rebuildImages.php | 4 +- maintenance/rebuildInterwiki.inc | 1 + maintenance/rebuildrecentchanges.inc | 5 +-- maintenance/rebuildtextindex.inc | 2 +- maintenance/storage/checkStorage.php | 1 + maintenance/storage/compressOld.inc | 6 +-- maintenance/storage/resolveStubs.php | 4 -- maintenance/updateArticleCount.inc.php | 2 +- maintenance/updaters.inc | 5 +-- maintenance/userDupes.inc | 6 +-- 36 files changed, 89 insertions(+), 85 deletions(-) diff --git a/maintenance/FiveUpgrade.inc b/maintenance/FiveUpgrade.inc index 531f1755d6..8b7e613daa 100644 --- a/maintenance/FiveUpgrade.inc +++ b/maintenance/FiveUpgrade.inc @@ -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 ), diff --git a/maintenance/addwiki.php b/maintenance/addwiki.php index b7843632b2..5a556bbb21 100644 --- a/maintenance/addwiki.php +++ b/maintenance/addwiki.php @@ -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; } diff --git a/maintenance/backup.inc b/maintenance/backup.inc index 1a8ff4febb..c5a917c12e 100644 --- a/maintenance/backup.inc +++ b/maintenance/backup.inc @@ -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 ); diff --git a/maintenance/cleanupCaps.php b/maintenance/cleanupCaps.php index afcd1b33fc..8864377fa3 100644 --- a/maintenance/cleanupCaps.php +++ b/maintenance/cleanupCaps.php @@ -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 ); diff --git a/maintenance/cleanupSpam.php b/maintenance/cleanupSpam.php index 65d6bc4d34..2ad0a9c3b7 100644 --- a/maintenance/cleanupSpam.php +++ b/maintenance/cleanupSpam.php @@ -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 ); diff --git a/maintenance/cleanupTable.inc b/maintenance/cleanupTable.inc index cc551bce9c..cf33e8f081 100644 --- a/maintenance/cleanupTable.inc +++ b/maintenance/cleanupTable.inc @@ -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 ); diff --git a/maintenance/cleanupTitles.php b/maintenance/cleanupTitles.php index 12e07b67ad..a98ecf2021 100644 --- a/maintenance/cleanupTitles.php +++ b/maintenance/cleanupTitles.php @@ -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(); diff --git a/maintenance/cleanupWatchlist.php b/maintenance/cleanupWatchlist.php index 027859a435..259b25eafd 100644 --- a/maintenance/cleanupWatchlist.php +++ b/maintenance/cleanupWatchlist.php @@ -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(); diff --git a/maintenance/convertLinks.inc b/maintenance/convertLinks.inc index 5f8c27a542..b63a9cfdb2 100644 --- a/maintenance/convertLinks.inc +++ b/maintenance/convertLinks.inc @@ -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" ) { diff --git a/maintenance/dumpHTML.inc b/maintenance/dumpHTML.inc index 702c7df901..15d6871785 100644 --- a/maintenance/dumpHTML.inc +++ b/maintenance/dumpHTML.inc @@ -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]; diff --git a/maintenance/dumpInterwiki.inc b/maintenance/dumpInterwiki.inc index 2039f2df4b..26805f4cdf 100644 --- a/maintenance/dumpInterwiki.inc +++ b/maintenance/dumpInterwiki.inc @@ -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 diff --git a/maintenance/findhooks.php b/maintenance/findhooks.php index 4f446f2b2a..97e6c57d04 100644 --- a/maintenance/findhooks.php +++ b/maintenance/findhooks.php @@ -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]; } diff --git a/maintenance/fixSlaveDesync.php b/maintenance/fixSlaveDesync.php index d2dffe543f..e62126acfa 100644 --- a/maintenance/fixSlaveDesync.php +++ b/maintenance/fixSlaveDesync.php @@ -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 { diff --git a/maintenance/importDump.php b/maintenance/importDump.php index 22709f6461..b6778b732e 100644 --- a/maintenance/importDump.php +++ b/maintenance/importDump.php @@ -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++; diff --git a/maintenance/importImages.inc.php b/maintenance/importImages.inc.php index bf48c0c7c1..e3ff69ade4 100644 --- a/maintenance/importImages.inc.php +++ b/maintenance/importImages.inc.php @@ -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; } diff --git a/maintenance/importLogs.inc b/maintenance/importLogs.inc index 154657c887..a5b94cb93d 100644 --- a/maintenance/importLogs.inc +++ b/maintenance/importLogs.inc @@ -77,6 +77,7 @@ class LogImporter { } $lines = explode( '
  • ', $text ); foreach( $lines as $line ) { + $matches = array(); if( preg_match( '!^(.*)
  • !', $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 ); diff --git a/maintenance/importPhase2.php b/maintenance/importPhase2.php index a73657b536..1f33850b68 100644 --- a/maintenance/importPhase2.php +++ b/maintenance/importPhase2.php @@ -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]; } diff --git a/maintenance/importUseModWiki.php b/maintenance/importUseModWiki.php index 15f5e4442e..b1c862d4b3 100644 --- a/maintenance/importUseModWiki.php +++ b/maintenance/importUseModWiki.php @@ -90,6 +90,7 @@ function importPageDirectory( $dir, $prefix = "" ) echo "\n\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 ? '' : ''); - 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 ) ); diff --git a/maintenance/installExtension.php b/maintenance/installExtension.php index f6b2dff4ab..c5bb5480cc 100644 --- a/maintenance/installExtension.php +++ b/maintenance/installExtension.php @@ -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( '!]*href\s*=\s*['."'".'"]([^/'."'".'"]+)\.tgz['."'".'"][^>]*>.*?!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"); diff --git a/maintenance/language/checkExtensioni18n.php b/maintenance/language/checkExtensioni18n.php index b0511f8e32..26ae5e16f0 100644 --- a/maintenance/language/checkExtensioni18n.php +++ b/maintenance/language/checkExtensioni18n.php @@ -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'; diff --git a/maintenance/language/checkLanguage.inc b/maintenance/language/checkLanguage.inc index cd77791d65..bb61754041 100644 --- a/maintenance/language/checkLanguage.inc +++ b/maintenance/language/checkLanguage.inc @@ -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 ); diff --git a/maintenance/language/date-formats.php b/maintenance/language/date-formats.php index 962c2f8ccb..a0d46f0278 100644 --- a/maintenance/language/date-formats.php +++ b/maintenance/language/date-formats.php @@ -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; } diff --git a/maintenance/language/diffLanguage.php b/maintenance/language/diffLanguage.php index 2aaa5902a8..b8d5e71703 100644 --- a/maintenance/language/diffLanguage.php +++ b/maintenance/language/diffLanguage.php @@ -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"); } diff --git a/maintenance/language/rebuildLanguage.php b/maintenance/language/rebuildLanguage.php index 1643d30b0d..e14c5ca0e5 100644 --- a/maintenance/language/rebuildLanguage.php +++ b/maintenance/language/rebuildLanguage.php @@ -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 ); diff --git a/maintenance/language/writeMessagesArray.inc b/maintenance/language/writeMessagesArray.inc index 184e4d6581..07925538b3 100644 --- a/maintenance/language/writeMessagesArray.inc +++ b/maintenance/language/writeMessagesArray.inc @@ -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; diff --git a/maintenance/parserTests.inc b/maintenance/parserTests.inc index 94b0982f3c..fca76969bd 100644 --- a/maintenance/parserTests.inc +++ b/maintenance/parserTests.inc @@ -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 { diff --git a/maintenance/rebuildImages.php b/maintenance/rebuildImages.php index 38b89a4805..4b896f825d 100644 --- a/maintenance/rebuildImages.php +++ b/maintenance/rebuildImages.php @@ -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(); } diff --git a/maintenance/rebuildInterwiki.inc b/maintenance/rebuildInterwiki.inc index d719fd4010..458693d3bc 100644 --- a/maintenance/rebuildInterwiki.inc +++ b/maintenance/rebuildInterwiki.inc @@ -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]; diff --git a/maintenance/rebuildrecentchanges.inc b/maintenance/rebuildrecentchanges.inc index e077da5221..1f3cca70ba 100644 --- a/maintenance/rebuildrecentchanges.inc +++ b/maintenance/rebuildrecentchanges.inc @@ -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" ); diff --git a/maintenance/rebuildtextindex.inc b/maintenance/rebuildtextindex.inc index 5035b5641f..f72bf55852 100644 --- a/maintenance/rebuildtextindex.inc +++ b/maintenance/rebuildtextindex.inc @@ -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" ); diff --git a/maintenance/storage/checkStorage.php b/maintenance/storage/checkStorage.php index 579954d50e..3d193b4ddc 100644 --- a/maintenance/storage/checkStorage.php +++ b/maintenance/storage/checkStorage.php @@ -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; diff --git a/maintenance/storage/compressOld.inc b/maintenance/storage/compressOld.inc index 3c42684104..30a294dad8 100644 --- a/maintenance/storage/compressOld.inc +++ b/maintenance/storage/compressOld.inc @@ -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, diff --git a/maintenance/storage/resolveStubs.php b/maintenance/storage/resolveStubs.php index e93d5c972f..343222adb8 100644 --- a/maintenance/storage/resolveStubs.php +++ b/maintenance/storage/resolveStubs.php @@ -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 " . diff --git a/maintenance/updateArticleCount.inc.php b/maintenance/updateArticleCount.inc.php index 7eaea74912..328b11192b 100644 --- a/maintenance/updateArticleCount.inc.php +++ b/maintenance/updateArticleCount.inc.php @@ -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 ) " . diff --git a/maintenance/updaters.inc b/maintenance/updaters.inc index e781df0d54..79ec08cb84 100644 --- a/maintenance/updaters.inc +++ b/maintenance/updaters.inc @@ -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; } diff --git a/maintenance/userDupes.inc b/maintenance/userDupes.inc index 9af66f116d..00c4e3456a 100644 --- a/maintenance/userDupes.inc +++ b/maintenance/userDupes.inc @@ -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 ); -- 2.20.1