From 11337038b38b7b2bc586444ce82215fbef74f787 Mon Sep 17 00:00:00 2001 From: Lupin Date: Tue, 7 Mar 2006 01:10:39 +0000 Subject: [PATCH] removing unused globals and some whitespace cleaning --- includes/Article.php | 20 ++-- includes/ChangesList.php | 8 +- includes/Credits.php | 126 ++++++++++++------------ includes/Database.php | 2 +- includes/DatabaseOracle.php | 14 +-- includes/DatabasePostgreSQL.php | 18 ++-- includes/DefaultSettings.php | 2 +- includes/DifferenceEngine.php | 7 +- includes/EditPage.php | 10 +- includes/ExternalStoreDB.php | 2 - includes/ExternalStoreHttp.php | 6 +- includes/Feed.php | 2 +- includes/GlobalFunctions.php | 48 ++++----- includes/Group.php | 2 +- includes/HistoryBlob.php | 12 +-- includes/HttpFunctions.php | 2 +- includes/Image.php | 18 ++-- includes/ImagePage.php | 2 +- includes/OutputPage.php | 6 +- includes/PageHistory.php | 5 +- includes/Parser.php | 12 +-- includes/ParserCache.php | 2 +- includes/ProfilerStub.php | 10 +- includes/RawPage.php | 2 - includes/SearchTsearch2.php | 22 ++--- includes/Skin.php | 29 +++--- includes/SkinTemplate.php | 9 +- includes/SpecialAllpages.php | 6 +- includes/SpecialBlockip.php | 4 +- includes/SpecialContributions.php | 17 ++-- includes/SpecialDisambiguations.php | 6 +- includes/SpecialEmailuser.php | 2 +- includes/SpecialImport.php | 2 - includes/SpecialIpblocklist.php | 2 +- includes/SpecialListredirects.php | 2 - includes/SpecialLockdb.php | 2 +- includes/SpecialNewimages.php | 3 +- includes/SpecialNewpages.php | 26 ++--- includes/SpecialPage.php | 4 +- includes/SpecialPreferences.php | 28 +++--- includes/SpecialPrefixindex.php | 4 +- includes/SpecialRecentchanges.php | 5 +- includes/SpecialRecentchangeslinked.php | 58 +++++------ includes/SpecialSearch.php | 1 - includes/SpecialUndelete.php | 2 +- includes/SpecialUnlockdb.php | 4 +- includes/SpecialUpload.php | 8 +- includes/SpecialUploadMogile.php | 6 +- includes/SpecialUserlogin.php | 9 +- includes/SpecialWatchlist.php | 58 +++++------ includes/SpecialWhatlinkshere.php | 4 +- includes/Title.php | 22 ++--- includes/User.php | 4 +- includes/WatchedItem.php | 1 - 54 files changed, 322 insertions(+), 366 deletions(-) diff --git a/includes/Article.php b/includes/Article.php index bfdb68ddb6..9fd25e3de8 100644 --- a/includes/Article.php +++ b/includes/Article.php @@ -351,8 +351,6 @@ class Article { * Load the revision (including text) into this object */ function loadContent() { - global $wgOut, $wgRequest; - if ( $this->mContentLoaded ) return; # Query variables :P @@ -621,8 +619,6 @@ class Article { * @access private */ function loadLastEdit() { - global $wgOut; - if ( -1 != $this->mUser ) return; @@ -1139,7 +1135,7 @@ class Article { * @access private */ function insertNewArticle( $text, $summary, $isminor, $watchthis, $suppressRC=false, $comment=false ) { - global $wgOut, $wgUser, $wgUseSquid; + global $wgUser; $fname = 'Article::insertNewArticle'; wfProfileIn( $fname ); @@ -1330,7 +1326,7 @@ class Article { * first set $wgUser, and clean up $wgDeferredUpdates after each edit. */ function updateArticle( $text, $summary, $minor, $watchthis, $forceBot = false, $sectionanchor = '' ) { - global $wgOut, $wgUser, $wgDBtransactions, $wgMwRedir, $wgUseSquid; + global $wgUser, $wgDBtransactions, $wgUseSquid; global $wgPostCommitUpdateList, $wgUseFileCache; $fname = 'Article::updateArticle'; @@ -1476,8 +1472,7 @@ class Article { * the link tables and redirect to the new page. */ function showArticle( $text, $subtitle , $sectionanchor = '', $me2, $now, $summary, $oldid ) { - global $wgOut, $wgUser; - global $wgUseEnotif; + global $wgOut; $fname = 'Article::showArticle'; wfProfileIn( $fname ); @@ -1629,7 +1624,7 @@ class Article { * @return bool true on success */ function updateRestrictions( $limit = array(), $reason = '' ) { - global $wgUser, $wgOut, $wgRequest; + global $wgUser; if ( !$wgUser->isAllowed( 'protect' ) ) { return false; @@ -1905,7 +1900,7 @@ class Article { * Perform a deletion and output success or failure messages */ function doDelete( $reason ) { - global $wgOut, $wgUser, $wgContLang; + global $wgOut, $wgUser; $fname = 'Article::doDelete'; wfDebug( $fname."\n" ); @@ -1934,7 +1929,7 @@ class Article { * Returns success */ function doDeleteArticle( $reason ) { - global $wgUser, $wgUseSquid, $wgDeferredUpdateList; + global $wgUseSquid, $wgDeferredUpdateList; global $wgPostCommitUpdateList, $wgUseTrackbacks; $fname = 'Article::doDeleteArticle'; @@ -2185,7 +2180,7 @@ class Article { # Parse the text $options = new ParserOptions; - $options->setTidy(true); + $options->setTidy(true); $poutput = $wgParser->parse( $text, $this->mTitle, $options, true, true, $newid ); # Save it to the parser cache @@ -2305,7 +2300,6 @@ class Article { $touched = $this->mTouched; $cache = new CacheManager( $this->mTitle ); if($cache->isFileCacheGood( $touched )) { - global $wgOut; wfDebug( " tryFileCache() - about to load\n" ); $cache->loadFromFileCache(); return true; diff --git a/includes/ChangesList.php b/includes/ChangesList.php index d46d5ff67e..0f814f0c3a 100644 --- a/includes/ChangesList.php +++ b/includes/ChangesList.php @@ -175,8 +175,8 @@ class ChangesList { function insertTimestamp(&$s, &$rc) { global $wgLang; - # Timestamp - $s .= '; ' . $wgLang->time( $rc->mAttribs['rc_timestamp'], true, true ) . ' . . '; + # Timestamp + $s .= '; ' . $wgLang->time( $rc->mAttribs['rc_timestamp'], true, true ) . ' . . '; } /** Insert links to user page, user talk page and eventually a blocking link */ @@ -287,7 +287,7 @@ class OldChangesList extends ChangesList { * Format a line using the old system (aka without any javascript). */ function recentChangesLine( &$rc, $watched = false ) { - global $wgLang, $wgContLang, $wgUser, $wgSysopUserBans; + global $wgContLang; $fname = 'ChangesList::recentChangesLineOld'; wfProfileIn( $fname ); @@ -351,7 +351,7 @@ class EnhancedChangesList extends ChangesList { * Format a line for enhanced recentchange (aka with javascript and block of lines). */ function recentChangesLine( &$baseRC, $watched = false ) { - global $wgLang, $wgContLang, $wgUser, $wgSysopUserBans; + global $wgLang, $wgContLang; # Create a specialised object $rc = RCCacheEntry::newFromParent( $baseRC ); diff --git a/includes/Credits.php b/includes/Credits.php index 7131789b0c..67b85ca45c 100644 --- a/includes/Credits.php +++ b/includes/Credits.php @@ -25,56 +25,56 @@ * This is largely cadged from PageHistory::history */ function showCreditsPage($article) { - global $wgOut; + global $wgOut; - $fname = 'showCreditsPage'; + $fname = 'showCreditsPage'; - wfProfileIn( $fname ); - - $wgOut->setPageTitle( $article->mTitle->getPrefixedText() ); - $wgOut->setSubtitle( wfMsg( 'creditspage' ) ); - $wgOut->setArticleFlag( false ); - $wgOut->setArticleRelated( true ); - $wgOut->setRobotpolicy( 'noindex,nofollow' ); - - if( $article->mTitle->getArticleID() == 0 ) { + wfProfileIn( $fname ); + + $wgOut->setPageTitle( $article->mTitle->getPrefixedText() ); + $wgOut->setSubtitle( wfMsg( 'creditspage' ) ); + $wgOut->setArticleFlag( false ); + $wgOut->setArticleRelated( true ); + $wgOut->setRobotpolicy( 'noindex,nofollow' ); + + if( $article->mTitle->getArticleID() == 0 ) { $s = wfMsg( 'nocredits' ); - } else { + } else { $s = getCredits($article, -1); - } + } - $wgOut->addHTML( $s ); + $wgOut->addHTML( $s ); - wfProfileOut( $fname ); + wfProfileOut( $fname ); } function getCredits($article, $cnt, $showIfMax=true) { $fname = 'getCredits'; wfProfileIn( $fname ); - $s = ''; + $s = ''; - if (isset($cnt) && $cnt != 0) { + if (isset($cnt) && $cnt != 0) { $s = getAuthorCredits($article); if ($cnt > 1 || $cnt < 0) { $s .= ' ' . getContributorCredits($article, $cnt - 1, $showIfMax); } - } + } wfProfileOut( $fname ); - return $s; + return $s; } /** * */ function getAuthorCredits($article) { - global $wgLang, $wgAllowRealName; + global $wgLang, $wgAllowRealName; - $last_author = $article->getUser(); + $last_author = $article->getUser(); - if ($last_author == 0) { + if ($last_author == 0) { $author_credit = wfMsg('anonymous'); - } else { + } else { if($wgAllowRealName) { $real_name = User::whoIsReal($last_author); } $user_name = User::whoIs($last_author); @@ -83,15 +83,15 @@ function getAuthorCredits($article) { } else { $author_credit = wfMsg('siteuser', creditLink($user_name)); } - } + } - $timestamp = $article->getTimestamp(); - if ($timestamp) { + $timestamp = $article->getTimestamp(); + if ($timestamp) { $d = $wgLang->timeanddate($article->getTimestamp(), true); - } else { + } else { $d = ''; - } - return wfMsg('lastmodifiedby', $d, $author_credit); + } + return wfMsg('lastmodifiedby', $d, $author_credit); } /** @@ -99,31 +99,31 @@ function getAuthorCredits($article) { */ function getContributorCredits($article, $cnt, $showIfMax) { - global $wgLang, $wgAllowRealName; + global $wgLang, $wgAllowRealName; - $contributors = $article->getContributors(); + $contributors = $article->getContributors(); - $others_link = ''; + $others_link = ''; - # Hmm... too many to fit! + # Hmm... too many to fit! - if ($cnt > 0 && count($contributors) > $cnt) { + if ($cnt > 0 && count($contributors) > $cnt) { $others_link = creditOthersLink($article); if (!$showIfMax) { return wfMsg('othercontribs', $others_link); } else { $contributors = array_slice($contributors, 0, $cnt); } - } + } - $real_names = array(); - $user_names = array(); + $real_names = array(); + $user_names = array(); - $anon = ''; + $anon = ''; - # Sift for real versus user names + # Sift for real versus user names - foreach ($contributors as $user_parts) { + foreach ($contributors as $user_parts) { if ($user_parts[0] != 0) { if ($wgAllowRealName && !empty($user_parts[2])) { $real_names[] = creditLink($user_parts[1], $user_parts[2]); @@ -133,55 +133,55 @@ function getContributorCredits($article, $cnt, $showIfMax) { } else { $anon = wfMsg('anonymous'); } - } + } - # Two strings: real names, and user names + # Two strings: real names, and user names - $real = $wgLang->listToText($real_names); - $user = $wgLang->listToText($user_names); + $real = $wgLang->listToText($real_names); + $user = $wgLang->listToText($user_names); - # "ThisSite user(s) A, B and C" + # "ThisSite user(s) A, B and C" - if (!empty($user)) { - $user = wfMsg('siteusers', $user); - } + if (!empty($user)) { + $user = wfMsg('siteusers', $user); + } - # This is the big list, all mooshed together. We sift for blank strings + # This is the big list, all mooshed together. We sift for blank strings - $fulllist = array(); + $fulllist = array(); - foreach (array($real, $user, $anon, $others_link) as $s) { + foreach (array($real, $user, $anon, $others_link) as $s) { if (!empty($s)) { array_push($fulllist, $s); } - } + } - # Make the list into text... + # Make the list into text... - $creds = $wgLang->listToText($fulllist); + $creds = $wgLang->listToText($fulllist); - # "Based on work by ..." + # "Based on work by ..." - return (empty($creds)) ? '' : wfMsg('othercontribs', $creds); + return (empty($creds)) ? '' : wfMsg('othercontribs', $creds); } /** * */ function creditLink($user_name, $link_text = '') { - global $wgUser, $wgContLang; - $skin = $wgUser->getSkin(); - return $skin->makeLink($wgContLang->getNsText(NS_USER) . ':' . $user_name, - htmlspecialchars( (empty($link_text)) ? $user_name : $link_text )); + global $wgUser, $wgContLang; + $skin = $wgUser->getSkin(); + return $skin->makeLink($wgContLang->getNsText(NS_USER) . ':' . $user_name, + htmlspecialchars( (empty($link_text)) ? $user_name : $link_text )); } /** * */ function creditOthersLink($article) { - global $wgUser, $wgLang; - $skin = $wgUser->getSkin(); - return $skin->makeKnownLink($article->mTitle->getPrefixedText(), wfMsg('others'), 'action=credits'); + global $wgUser; + $skin = $wgUser->getSkin(); + return $skin->makeKnownLink($article->mTitle->getPrefixedText(), wfMsg('others'), 'action=credits'); } ?> diff --git a/includes/Database.php b/includes/Database.php index 1dfe194cf6..35525df738 100644 --- a/includes/Database.php +++ b/includes/Database.php @@ -359,7 +359,7 @@ class Database { * If errors are explicitly ignored, returns success */ function query( $sql, $fname = '', $tempIgnore = false ) { - global $wgProfiling, $wgCommandLineMode; + global $wgProfiling; if ( $wgProfiling ) { # generalizeSQL will probably cut down the query to reasonable diff --git a/includes/DatabaseOracle.php b/includes/DatabaseOracle.php index c984240a1f..e0763c33be 100644 --- a/includes/DatabaseOracle.php +++ b/includes/DatabaseOracle.php @@ -454,12 +454,12 @@ class DatabaseOracle extends Database { # return "TO_TIMESTAMP('" . $this->strencode(wfTimestamp(TS_DB, $ts)) . "', 'RRRR-MM-DD HH24:MI:SS')"; } - /** - * Return aggregated value function call - */ - function aggregateValue ($valuedata,$valuename='value') { - return $valuedata; - } + /** + * Return aggregated value function call + */ + function aggregateValue ($valuedata,$valuename='value') { + return $valuedata; + } function reportQueryError( $error, $errno, $sql, $fname, $tempIgnore = false ) { @@ -497,7 +497,7 @@ class DatabaseOracle extends Database { function immediateCommit( $fname = 'Database::immediateCommit' ) { oci_commit($this->mConn); $this->mTrxLevel = 0; - } + } function rollback( $fname = 'Database::rollback' ) { oci_rollback($this->mConn); $this->mTrxLevel = 0; diff --git a/includes/DatabasePostgreSQL.php b/includes/DatabasePostgreSQL.php index 5dfda70136..130a247a85 100644 --- a/includes/DatabasePostgreSQL.php +++ b/includes/DatabasePostgreSQL.php @@ -121,8 +121,8 @@ class DatabasePgsql extends Database { function fetchRow( $res ) { @$row = pg_fetch_array( $res ); if( pg_last_error($this->mConn) ) { - wfDebugDieBacktrace( 'SQL error: ' . htmlspecialchars( pg_last_error($this->mConn) ) ); - } + wfDebugDieBacktrace( 'SQL error: ' . htmlspecialchars( pg_last_error($this->mConn) ) ); + } return $row; } @@ -365,7 +365,7 @@ class DatabasePgsql extends Database { } function limitResult($sql, $limit,$offset) { - return "$sql LIMIT $limit ".(is_numeric($offset)?" OFFSET {$offset} ":""); + return "$sql LIMIT $limit ".(is_numeric($offset)?" OFFSET {$offset} ":""); } /** @@ -391,12 +391,12 @@ class DatabasePgsql extends Database { return wfTimestamp(TS_DB,$ts); } - /** - * Return aggregated value function call - */ - function aggregateValue ($valuedata,$valuename='value') { - return $valuedata; - } + /** + * Return aggregated value function call + */ + function aggregateValue ($valuedata,$valuename='value') { + return $valuedata; + } function reportQueryError( $error, $errno, $sql, $fname, $tempIgnore = false ) { diff --git a/includes/DefaultSettings.php b/includes/DefaultSettings.php index c99bbd7a5a..1b9757bf37 100644 --- a/includes/DefaultSettings.php +++ b/includes/DefaultSettings.php @@ -63,7 +63,7 @@ $wgServer = $wgProto.'://' . $wgServerName; # If the port is a non-standard one, add it to the URL if( isset( $_SERVER['SERVER_PORT'] ) && ( ( $wgProto == 'http' && $_SERVER['SERVER_PORT'] != 80 ) - || ( $wgProto == 'https' && $_SERVER['SERVER_PORT'] != 443 ) ) ) { + || ( $wgProto == 'https' && $_SERVER['SERVER_PORT'] != 443 ) ) ) { $wgServer .= ":" . $_SERVER['SERVER_PORT']; } diff --git a/includes/DifferenceEngine.php b/includes/DifferenceEngine.php index be3db6e752..492aa4ab15 100644 --- a/includes/DifferenceEngine.php +++ b/includes/DifferenceEngine.php @@ -72,8 +72,8 @@ class DifferenceEngine { } function showDiffPage() { - global $wgUser, $wgOut, $wgContLang, $wgOnlySysopsCanPatrol, - $wgUseExternalEditor, $wgUseRCPatrol; + global $wgUser, $wgOut, $wgContLang, $wgOnlySysopsCanPatrol; + global $wgUseExternalEditor, $wgUseRCPatrol; $fname = 'DifferenceEngine::showDiffPage'; wfProfileIn( $fname ); @@ -317,7 +317,7 @@ CONTROL; * Returns false on error */ function getDiffBody() { - global $wgContLang, $wgMemc, $wgDBname; + global $wgMemc, $wgDBname; $fname = 'DifferenceEngine::getDiffBody'; wfProfileIn( $fname ); @@ -1683,7 +1683,6 @@ class TableDiffFormatter extends DiffFormatter } function _start_block( $header ) { - global $wgOut; echo $header; } diff --git a/includes/EditPage.php b/includes/EditPage.php index e15dc15c12..480533c1b5 100644 --- a/includes/EditPage.php +++ b/includes/EditPage.php @@ -156,8 +156,8 @@ class EditPage { * the newly-edited page. */ function edit() { - global $wgOut, $wgUser, $wgRequest, $wgTitle, - $wgEmailConfirmToEdit; + global $wgOut, $wgUser, $wgRequest, $wgTitle; + global $wgEmailConfirmToEdit; if ( ! wfRunHooks( 'AlternateEdit', array( &$this ) ) ) return; @@ -1218,7 +1218,7 @@ END } else if(preg_match("/\\.js$/", $wgTitle->getText() ) ) { $previewtext = wfMsg('userjspreview'); } - $parserOptions->setTidy(true); + $parserOptions->setTidy(true); $parserOutput = $wgParser->parse( $previewtext , $wgTitle, $parserOptions ); $wgOut->addHTML( $parserOutput->mText ); wfProfileOut( $fname ); @@ -1238,7 +1238,7 @@ END } if ( $this->mMetaData != "" ) $toparse .= "\n" . $this->mMetaData ; - $parserOptions->setTidy(true); + $parserOptions->setTidy(true); $parserOutput = $wgParser->parse( $this->mArticle->preSaveTransform( $toparse ) ."\n\n", $wgTitle, $parserOptions ); @@ -1545,8 +1545,6 @@ END * @return string HTML */ function getDiff() { - global $wgUser; - require_once( 'DifferenceEngine.php' ); $oldtext = $this->mArticle->fetchContent(); $newtext = $this->mArticle->replaceSection( diff --git a/includes/ExternalStoreDB.php b/includes/ExternalStoreDB.php index c0fef52b9e..beb4041a06 100644 --- a/includes/ExternalStoreDB.php +++ b/includes/ExternalStoreDB.php @@ -65,7 +65,6 @@ class ExternalStoreDB { } function fetchFromURL($url) { - global $wgExternalServers; # # URLs have the form DB://cluster/id or DB://cluster/id/itemid for concatenated storage # @@ -127,7 +126,6 @@ class ExternalStoreDB { * @return string URL */ function store( $cluster, $data ) { - global $wgExternalServers; $fname = 'ExternalStoreDB::store'; $dbw =& $this->getMaster( $cluster ); diff --git a/includes/ExternalStoreHttp.php b/includes/ExternalStoreHttp.php index f818de1e21..daf62cc445 100644 --- a/includes/ExternalStoreHttp.php +++ b/includes/ExternalStoreHttp.php @@ -10,9 +10,9 @@ class ExternalStoreHttp { /* Fetch data from given URL */ function fetchFromURL($url) { - ini_set( "allow_url_fopen", true ); - $ret = file_get_contents( $url ); - ini_set( "allow_url_fopen", false ); + ini_set( "allow_url_fopen", true ); + $ret = file_get_contents( $url ); + ini_set( "allow_url_fopen", false ); return $ret; } diff --git a/includes/Feed.php b/includes/Feed.php index e0da06db14..9b4816bbb7 100644 --- a/includes/Feed.php +++ b/includes/Feed.php @@ -237,7 +237,7 @@ class AtomFeed extends ChannelFeed { * @todo document */ function outHeader() { - global $wgVersion, $wgOut; + global $wgVersion; $this->outXmlHeader(); ?> diff --git a/includes/GlobalFunctions.php b/includes/GlobalFunctions.php index 215212ec20..377ee11872 100644 --- a/includes/GlobalFunctions.php +++ b/includes/GlobalFunctions.php @@ -716,7 +716,7 @@ function wfShowingResultsNum( $offset, $limit, $num ) { * @todo document */ function wfViewPrevNext( $offset, $limit, $link, $query = '', $atend = false ) { - global $wgUser, $wgLang; + global $wgLang; $fmtLimit = $wgLang->formatNum( $limit ); $prev = wfMsg( 'prevn', $fmtLimit ); $next = wfMsg( 'nextn', $fmtLimit ); @@ -760,7 +760,7 @@ function wfViewPrevNext( $offset, $limit, $link, $query = '', $atend = false ) { * @todo document */ function wfNumLink( $offset, $limit, &$title, $query = '' ) { - global $wgUser, $wgLang; + global $wgLang; if ( '' == $query ) { $q = ''; } else { $q = $query.'&'; } $q .= 'limit='.$limit.'&offset='.$offset; @@ -1275,8 +1275,8 @@ define('TS_ORACLE', 6); /** * @param mixed $outputtype A timestamp in one of the supported formats, the - * function will autodetect which format is supplied - and act accordingly. + * function will autodetect which format is supplied + and act accordingly. * @return string Time in the format specified in $outputtype */ function wfTimestamp($outputtype=TS_UNIX,$ts=0) { @@ -1620,26 +1620,26 @@ function wfMkdirParents( $fullDir, $mode ) { /** * Increment a statistics counter */ -function wfIncrStats( $key ) { - global $wgDBname, $wgMemc; - /* LIVE HACK AVOID MEMCACHED ACCESSES DURING HIGH LOAD */ - if ($wgDBname != 'enwiki' and $wgDBname != 'dewiki' and $wgDBname != 'commonswiki' and $wgDBname != 'testwiki') - return true; - static $socket; - if (!$socket) { - $socket=socket_create(AF_INET, SOCK_DGRAM, SOL_UDP); - $statline="{$wgDBname} - 1 1 1 1 1 -total\n"; - socket_sendto($socket,$statline,strlen($statline),0,"webster","3811"); - } - $statline="{$wgDBname} - 1 1 1 1 1 {$key}\n"; - socket_sendto($socket,$statline,strlen($statline),0,"webster","3811"); - return true; - - $key = "$wgDBname:stats:$key"; - if ( is_null( $wgMemc->incr( $key ) ) ) { - $wgMemc->add( $key, 1 ); - } -} + function wfIncrStats( $key ) { + global $wgDBname, $wgMemc; + /* LIVE HACK AVOID MEMCACHED ACCESSES DURING HIGH LOAD */ + if ($wgDBname != 'enwiki' and $wgDBname != 'dewiki' and $wgDBname != 'commonswiki' and $wgDBname != 'testwiki') + return true; + static $socket; + if (!$socket) { + $socket=socket_create(AF_INET, SOCK_DGRAM, SOL_UDP); + $statline="{$wgDBname} - 1 1 1 1 1 -total\n"; + socket_sendto($socket,$statline,strlen($statline),0,"webster","3811"); + } + $statline="{$wgDBname} - 1 1 1 1 1 {$key}\n"; + socket_sendto($socket,$statline,strlen($statline),0,"webster","3811"); + return true; + + $key = "$wgDBname:stats:$key"; + if ( is_null( $wgMemc->incr( $key ) ) ) { + $wgMemc->add( $key, 1 ); + } + } /** * @param mixed $nr The number to format diff --git a/includes/Group.php b/includes/Group.php index cc4a05d858..bec94e9efa 100644 --- a/includes/Group.php +++ b/includes/Group.php @@ -167,7 +167,7 @@ class Group { * @param integer $id Group database id */ function newFromId($id) { - global $wgMemc, $wgDBname; + global $wgMemc; $fname = 'Group::newFromId'; $staticGroups =& Group::getStaticGroups(); diff --git a/includes/HistoryBlob.php b/includes/HistoryBlob.php index eb4b7eb5c0..5492ce0340 100644 --- a/includes/HistoryBlob.php +++ b/includes/HistoryBlob.php @@ -200,16 +200,16 @@ class HistoryBlobStub { /** * Sets the location (old_id) of the referring object */ - function setReferrer( $id ) { - $this->mRef = $id; - } + function setReferrer( $id ) { + $this->mRef = $id; + } /** * Gets the location of the referring object */ - function getReferrer() { - return $this->mRef; - } + function getReferrer() { + return $this->mRef; + } /** @todo document */ function getText() { diff --git a/includes/HttpFunctions.php b/includes/HttpFunctions.php index 2c2fd4c0cb..f23a14519f 100644 --- a/includes/HttpFunctions.php +++ b/includes/HttpFunctions.php @@ -9,7 +9,7 @@ * if $timeout is 'default', $wgHTTPTimeout is used */ function wfGetHTTP( $url, $timeout = 'default' ) { - global $wgHTTPTimeout, $wgHTTPProxy, $wgVersion, $wgTitle, $wgCommandLineMode; + global $wgHTTPTimeout, $wgHTTPProxy, $wgVersion, $wgTitle; # Use curl if available if ( function_exists( 'curl_init' ) ) { diff --git a/includes/Image.php b/includes/Image.php index 0afad6817f..70965263f6 100644 --- a/includes/Image.php +++ b/includes/Image.php @@ -212,8 +212,7 @@ class Image * Load metadata from the file itself */ function loadFromFile() { - global $wgUseSharedUploads, $wgSharedUploadDirectory, $wgContLang, - $wgShowEXIF; + global $wgUseSharedUploads, $wgSharedUploadDirectory, $wgContLang, $wgShowEXIF; $fname = 'Image::loadFromFile'; wfProfileIn( $fname ); $this->imagePath = $this->getFullPath(); @@ -742,8 +741,8 @@ class Image $base = $wgUploadBaseUrl; $path = $wgUploadPath; } - $url = "{$base}{$path}" . wfGetHashPath($name, $fromSharedDirectory) . "{$name}"; - return wfUrlencode( $url ); + $url = "{$base}{$path}" . wfGetHashPath($name, $fromSharedDirectory) . "{$name}"; + return wfUrlencode( $url ); } /** @@ -909,7 +908,6 @@ class Image */ function renderThumb( $width, $useScript = true ) { global $wgUseSquid, $wgInternalServer; - global $wgThumbnailScriptPath, $wgSharedThumbnailScriptPath; global $wgSVGMaxSize, $wgMaxImageArea, $wgThumbnailEpoch; $fname = 'Image::renderThumb'; @@ -1047,8 +1045,8 @@ class Image * @access private */ function reallyRenderThumb( $thumbPath, $width, $height ) { - global $wgSVGConverters, $wgSVGConverter, - $wgUseImageMagick, $wgImageMagickConvertCommand; + global $wgSVGConverters, $wgSVGConverter; + global $wgUseImageMagick, $wgImageMagickConvertCommand; $this->load(); @@ -1246,7 +1244,7 @@ class Image } function checkDBSchema(&$db) { - global $wgCheckDBSchema; + global $wgCheckDBSchema; if (!$wgCheckDBSchema) { return; } @@ -1711,8 +1709,8 @@ function wfDeprecatedThumbDir( $thumbName , $subdir='thumb', $shared=false) { * @access public */ function wfImageArchiveDir( $fname , $subdir='archive', $shared=false ) { - global $wgUploadDirectory, $wgHashedUploadDirectory, - $wgSharedUploadDirectory, $wgHashedSharedUploadDirectory; + global $wgUploadDirectory, $wgHashedUploadDirectory; + global $wgSharedUploadDirectory, $wgHashedSharedUploadDirectory; $dir = $shared ? $wgSharedUploadDirectory : $wgUploadDirectory; $hashdir = $shared ? $wgHashedSharedUploadDirectory : $wgHashedUploadDirectory; if (!$hashdir) { return $dir.'/'.$subdir; } diff --git a/includes/ImagePage.php b/includes/ImagePage.php index dd5f4f7755..0e55156405 100644 --- a/includes/ImagePage.php +++ b/includes/ImagePage.php @@ -473,7 +473,7 @@ END } function doDelete() { - global $wgOut, $wgUser, $wgRequest, $wgUseSquid, $wgInternalServer; + global $wgOut, $wgRequest, $wgUseSquid, $wgInternalServer; global $wgPostCommitUpdateList; $fname = 'ImagePage::doDelete'; diff --git a/includes/OutputPage.php b/includes/OutputPage.php index 510b9eb0a1..3517e45d4d 100644 --- a/includes/OutputPage.php +++ b/includes/OutputPage.php @@ -668,8 +668,6 @@ class OutputPage { * @param mixed $version The version of MediaWiki needed to use the page */ function versionRequired( $version ) { - global $wgUser; - $this->setPageTitle( wfMsg( 'versionrequired', $version ) ); $this->setHTMLTitle( wfMsg( 'versionrequired', $version ) ); $this->setRobotpolicy( 'noindex,nofollow' ); @@ -911,7 +909,7 @@ class OutputPage { */ function headElement() { global $wgDocType, $wgDTD, $wgContLanguageCode, $wgOutputEncoding, $wgMimeType; - global $wgUser, $wgContLang, $wgRequest, $wgUseTrackbacks, $wgTitle; + global $wgUser, $wgContLang, $wgUseTrackbacks, $wgTitle; if( $wgMimeType == 'text/xml' || $wgMimeType == 'application/xhtml+xml' || $wgMimeType == 'application/xml' ) { $ret = "\n"; @@ -953,7 +951,7 @@ class OutputPage { } function getHeadLinks() { - global $wgRequest, $wgStylePath; + global $wgRequest; $ret = ''; foreach ( $this->mMetatags as $tag ) { if ( 0 == strcasecmp( 'http:', substr( $tag[0], 0, 5 ) ) ) { diff --git a/includes/PageHistory.php b/includes/PageHistory.php index e8a6c07a12..ddfe444c81 100644 --- a/includes/PageHistory.php +++ b/includes/PageHistory.php @@ -50,7 +50,7 @@ class PageHistory { * @returns nothing */ function history() { - global $wgUser, $wgOut, $wgRequest, $wgTitle; + global $wgOut, $wgRequest, $wgTitle; /* * Allow client caching. @@ -429,7 +429,6 @@ class PageHistory { /** @todo document */ function fetchRevisions($limit, $offset, $direction) { - global $wgUser, $wgShowUpdatedMarker; $fname = 'PageHistory::fetchRevisions'; $dbr =& wfGetDB( DB_SLAVE ); @@ -490,7 +489,7 @@ class PageHistory { /** @todo document */ function makeNavbar($revisions, $offset, $limit, $direction) { - global $wgTitle, $wgLang; + global $wgLang; $revisions = array_slice($revisions, 0, $limit); diff --git a/includes/Parser.php b/includes/Parser.php index 8165de79cf..3281865fea 100644 --- a/includes/Parser.php +++ b/includes/Parser.php @@ -815,7 +815,6 @@ class Parser * @access private */ function internalParse( $text ) { - global $wgContLang; $args = array(); $isMain = true; $fname = 'Parser::internalParse'; @@ -3332,8 +3331,6 @@ class Parser * @access private */ function getUserSig( &$user ) { - global $wgContLang; - $username = $user->getName(); $nickname = $user->getOption( 'nickname' ); $nickname = $nickname === '' ? $username : $nickname; @@ -3623,9 +3620,6 @@ class Parser * @return string */ function replaceLinkHoldersText( $text ) { - global $wgUser; - global $wgOutputReplace; - $fname = 'Parser::replaceLinkHoldersText'; wfProfileIn( $fname ); @@ -3709,7 +3703,7 @@ class Parser * Parse image options text and use it to make an image */ function makeImage( &$nt, $options ) { - global $wgContLang, $wgUseImageResize, $wgUser; + global $wgUseImageResize; $align = ''; @@ -3991,8 +3985,8 @@ class ParserOptions /** Get user options */ function initialiseFromUser( &$userInput ) { - global $wgUseTeX, $wgUseDynamicDates, $wgInterwikiMagic, $wgAllowExternalImages, - $wgAllowExternalImagesFrom, $wgAllowSpecialInclusion; + global $wgUseTeX, $wgUseDynamicDates, $wgInterwikiMagic, $wgAllowExternalImages; + global $wgAllowExternalImagesFrom, $wgAllowSpecialInclusion; $fname = 'ParserOptions::initialiseFromUser'; wfProfileIn( $fname ); if ( !$userInput ) { diff --git a/includes/ParserCache.php b/includes/ParserCache.php index aa3194ee8c..d9a7c849b6 100644 --- a/includes/ParserCache.php +++ b/includes/ParserCache.php @@ -93,7 +93,7 @@ class ParserCache { } function save( $parserOutput, &$article, &$user ){ - global $wgParserCacheExpireTime; + global $wgParserCacheExpireTime; $key = $this->getKey( $article, $user ); $now = wfTimestampNow(); $parserOutput->setCacheTime( $now ); diff --git a/includes/ProfilerStub.php b/includes/ProfilerStub.php index edadd5e3d3..3bcdaab2af 100644 --- a/includes/ProfilerStub.php +++ b/includes/ProfilerStub.php @@ -6,15 +6,15 @@ $haveProctitle=function_exists("setproctitle"); function wfProfileIn( $fn = '' ) { global $hackwhere, $wgDBname, $haveProctitle; if ($haveProctitle) { - $hackwhere[] = $fn; + $hackwhere[] = $fn; setproctitle($fn . " [$wgDBname]"); - } + } } function wfProfileOut( $fn = '' ) { global $hackwhere, $wgDBname, $haveProctitle; - if (!$haveProctitle) - return; - if (count($hackwhere)) + if (!$haveProctitle) + return; + if (count($hackwhere)) array_pop($hackwhere); if (count($hackwhere)) setproctitle($hackwhere[count($hackwhere)-1] . " [$wgDBname]"); diff --git a/includes/RawPage.php b/includes/RawPage.php index 0e46df5bde..780ec7c56f 100644 --- a/includes/RawPage.php +++ b/includes/RawPage.php @@ -151,8 +151,6 @@ class RawPage { } function getArticleText() { - global $wgParser; - if( $this->mTitle ) { $text = ''; diff --git a/includes/SearchTsearch2.php b/includes/SearchTsearch2.php index 2cff2cb62a..d04312f6e7 100644 --- a/includes/SearchTsearch2.php +++ b/includes/SearchTsearch2.php @@ -99,8 +99,8 @@ class SearchTsearch2 extends SearchEngine { " $field @@ to_tsquery ('$match') " ; } - function update( $id, $title, $text ) { - $dbw=& wfGetDB(DB_MASTER); + function update( $id, $title, $text ) { + $dbw=& wfGetDB(DB_MASTER); $searchindex = $dbw->tableName( 'searchindex' ); $sql = "DELETE FROM $searchindex WHERE si_page={$id}"; $dbw->query($sql,"SearchTsearch2:update"); @@ -110,17 +110,17 @@ class SearchTsearch2 extends SearchEngine { "'),to_tsvector('". $dbw->strencode( $text)."')) "; $dbw->query($sql,"SearchTsearch2:update"); - } + } - function updateTitle($id,$title) { - $dbw=& wfGetDB(DB_MASTER); - $searchindex = $dbw->tableName( 'searchindex' ); - $sql = "UPDATE $searchindex SET si_title=to_tsvector('" . - $db->strencode( $title ) . - "') WHERE si_page={$id}"; + function updateTitle($id,$title) { + $dbw=& wfGetDB(DB_MASTER); + $searchindex = $dbw->tableName( 'searchindex' ); + $sql = "UPDATE $searchindex SET si_title=to_tsvector('" . + $db->strencode( $title ) . + "') WHERE si_page={$id}"; - $dbw->query( $sql, "SearchMySQL4::updateTitle" ); - } + $dbw->query( $sql, "SearchMySQL4::updateTitle" ); + } } diff --git a/includes/Skin.php b/includes/Skin.php index 4b506fe245..5dafd69cb4 100644 --- a/includes/Skin.php +++ b/includes/Skin.php @@ -275,7 +275,7 @@ class Skin extends Linker { # get the user/site-specific stylesheet, SkinTemplate loads via RawPage.php (settings are cached that way) function getUserStylesheet() { - global $wgOut, $wgStylePath, $wgRequest, $wgContLang, $wgSquidMaxage; + global $wgStylePath, $wgRequest, $wgContLang, $wgSquidMaxage; $sheet = $this->getStylesheet(); $action = $wgRequest->getText('action'); $s = "@import \"$wgStylePath/$sheet\";\n"; @@ -298,7 +298,6 @@ class Skin extends Linker { * Return html code that include User stylesheets */ function getUserStyles() { - global $wgOut, $wgStylePath; $s = "