Use AutoLoader to load classes:
authorDomas Mituzas <midom@users.mediawiki.org>
Thu, 1 Jun 2006 07:22:49 +0000 (07:22 +0000)
committerDomas Mituzas <midom@users.mediawiki.org>
Thu, 1 Jun 2006 07:22:49 +0000 (07:22 +0000)
* remove require_once() throughout whole code, yet left in few places
* move global functions in HttpUtils, ProxyTools, Credits to class methods
* php5 only: __autoload() now used, combined with class->file map and require()
* move initialization of $wgValidSkinNames to Skin::getSkinNames()
* few more changes that will surely break stuff.

57 files changed:
includes/AjaxDispatcher.php
includes/AjaxFunctions.php
includes/Article.php
includes/AutoLoader.php [new file with mode: 0644]
includes/Block.php
includes/CacheManager.php
includes/CategoryPage.php
includes/ChangesList.php
includes/Credits.php
includes/Database.php
includes/DatabaseOracle.php
includes/DatabasePostgreSQL.php
includes/DifferenceEngine.php
includes/EditPage.php
includes/Export.php
includes/ExternalStoreDB.php
includes/GlobalFunctions.php
includes/HistoryBlob.php
includes/HttpFunctions.php
includes/Image.php
includes/ImagePage.php
includes/LinksUpdate.php
includes/LoadBalancer.php
includes/LogPage.php
includes/Math.php
includes/MessageCache.php
includes/ObjectCache.php
includes/OutputPage.php
includes/PageHistory.php
includes/Parser.php
includes/ParserXML.php
includes/Profiling.php
includes/ProxyTools.php
includes/QueryPage.php
includes/RawPage.php
includes/RecentChange.php
includes/Revision.php
includes/SearchEngine.php
includes/SearchMySQL.php
includes/SearchMySQL4.php
includes/SearchTsearch2.php
includes/SearchUpdate.php
includes/Setup.php
includes/Skin.php
includes/SkinTemplate.php
includes/SpecialBlockme.php
includes/SpecialPage.php
includes/SpecialPreferences.php
includes/SpecialRecentchanges.php
includes/SpecialUpload.php
includes/SpecialUserlogin.php
includes/SpecialVersion.php
includes/Title.php
includes/UpdateClasses.php
includes/User.php
includes/WebRequest.php
includes/Wiki.php

index ae0d3e3..f5af30b 100644 (file)
@@ -1,18 +1,5 @@
 <?php
 
-//$wgRequestTime = microtime();
-
-// unset( $IP );
-// @ini_set( 'allow_url_fopen', 0 ); # For security...
-
-# Valid web server entry point, enable includes.
-# Please don't move this line to includes/Defines.php. This line essentially defines
-# a valid entry point. If you put it in includes/Defines.php, then any script that includes
-# it becomes an entry point, thereby defeating its purpose.
-// define( 'MEDIAWIKI', true );
-// require_once( './includes/Defines.php' );
-// require_once( './LocalSettings.php' );
-// require_once( 'includes/Setup.php' );
 require_once( 'AjaxFunctions.php' );
 
 if ( ! $wgUseAjax ) {
index 3580a29..94388b0 100644 (file)
@@ -3,8 +3,6 @@
 if( !defined( 'MEDIAWIKI' ) )
         die( -1 );
 
-require_once('WebRequest.php');
-
 /**
  * Function converts an Javascript escaped string back into a string with
  * specified charset (default is UTF-8).
index d4a3cde..0c6046f 100644 (file)
@@ -4,12 +4,6 @@
  * @package MediaWiki
  */
 
-/**
- * Need the CacheManager to be loaded
- */
-require_once( 'CacheManager.php' );
-require_once( 'Revision.php' );
-
 $wgArticleCurContentFields = false;
 $wgArticleOldContentFields = false;
 
@@ -762,7 +756,6 @@ class Article {
                # diff page instead of the article.
 
                if ( !is_null( $diff ) ) {
-                       require_once( 'DifferenceEngine.php' );
                        $wgOut->setPageTitle( $this->mTitle->getPrefixedText() );
 
                        $de = new DifferenceEngine( $this->mTitle, $oldid, $diff, $rcid );
@@ -1233,7 +1226,6 @@ class Article {
 
                Article::onArticleCreate( $this->mTitle );
                if(!$suppressRC) {
-                       require_once( 'RecentChange.php' );
                        $rcid = RecentChange::notifyNew( $now, $this->mTitle, $isminor, $wgUser, $summary, 'default',
                          '', strlen( $text ), $revisionId );
                        # Mark as patrolled if the user can and has the option set
@@ -1440,7 +1432,6 @@ class Article {
                                $dbw->rollback();
                        } else {
                                # Update recentchanges and purge cache and whatnot
-                               require_once( 'RecentChange.php' );
                                $bot = (int)($wgUser->isBot() || $forceBot);
                                $rcid = RecentChange::notifyEdit( $now, $this->mTitle, $isminor, $wgUser, $summary,
                                        $lastRevision, $this->getTimestamp(), $bot, '', $oldsize, $newsize,
@@ -1564,7 +1555,6 @@ class Article {
                $rcid = $wgRequest->getVal( 'rcid' );
                if ( !is_null ( $rcid ) ) {
                        if( wfRunHooks( 'MarkPatrolled', array( &$rcid, &$wgUser, false ) ) ) {
-                               require_once( 'RecentChange.php' );
                                RecentChange::markPatrolled( $rcid );
                                wfRunHooks( 'MarkPatrolledComplete', array( &$rcid, &$wgUser, false ) );
                                $wgOut->setPagetitle( wfMsg( 'markedaspatrolled' ) );
@@ -1679,7 +1669,6 @@ class Article {
         * action=protect handler
         */
        function protect() {
-               require_once 'ProtectionForm.php';
                $form = new ProtectionForm( $this );
                $form->show();
        }
diff --git a/includes/AutoLoader.php b/includes/AutoLoader.php
new file mode 100644 (file)
index 0000000..8c372f7
--- /dev/null
@@ -0,0 +1,219 @@
+<?php
+
+/* This defines autoloading handler for whole MediaWiki framework */
+function __autoload($class_name) {
+       $classes = array(
+               'AjaxDispatcher' => 'AjaxDispatcher.php',
+               'AjaxCachePolicy' => 'AjaxFunctions.php',
+               'Article' => 'Article.php',
+               'AuthPlugin' => 'AuthPlugin.php',
+               'BagOStuff' => 'BagOStuff.php',
+               'HashBagOStuff' => 'BagOStuff.php',
+               'SqlBagOStuff' => 'BagOStuff.php',
+               'MediaWikiBagOStuff' => 'BagOStuff.php',
+               'TurckBagOStuff' => 'BagOStuff.php',
+               'APCBagOStuff' => 'BagOStuff.php',
+               'eAccelBagOStuff' => 'BagOStuff.php',
+               'Block' => 'Block.php',
+               'CacheManager' => 'CacheManager.php',
+               'CategoryPage' => 'CategoryPage.php',
+               'Categoryfinder' => 'Categoryfinder.php',
+               'RCCacheEntry' => 'ChangesList.php',
+               'ChangesList' => 'ChangesList.php',
+               'OldChangesList' => 'ChangesList.php',
+               'EnhancedChangesList' => 'ChangesList.php',
+               'DBObject' => 'Database.php',
+               'Database' => 'Database.php',
+               'DatabaseMysql' => 'Database.php',
+               'ResultWrapper' => 'Database.php',
+               'OracleBlob' => 'DatabaseOracle.php',
+               'DatabaseOracle' => 'DatabaseOracle.php',
+               'DatabasePgsql' => 'DatabasePostgreSQL.php',
+               'DatabasePostgreSQL' => 'DatabasePostgreSQL.php',
+               'DateFormatter' => 'DateFormatter.php',
+               'DifferenceEngine' => 'DifferenceEngine.php',
+               '_DiffOp' => 'DifferenceEngine.php',
+               '_DiffOp_Copy' => 'DifferenceEngine.php',
+               '_DiffOp_Delete' => 'DifferenceEngine.php',
+               '_DiffOp_Add' => 'DifferenceEngine.php',
+               '_DiffOp_Change' => 'DifferenceEngine.php',
+               '_DiffEngine' => 'DifferenceEngine.php',
+               'Diff' => 'DifferenceEngine.php',
+               'MappedDiff' => 'DifferenceEngine.php',
+               'DiffFormatter' => 'DifferenceEngine.php',
+               '_HWLDF_WordAccumulator' => 'DifferenceEngine.php',
+               'WordLevelDiff' => 'DifferenceEngine.php',
+               'TableDiffFormatter' => 'DifferenceEngine.php',
+               'EditPage' => 'EditPage.php',
+               'Exif' => 'Exif.php',
+               'FormatExif' => 'Exif.php',
+               'WikiExporter' => 'Export.php',
+               'XmlDumpWriter' => 'Export.php',
+               'DumpOutput' => 'Export.php',
+               'DumpFileOutput' => 'Export.php',
+               'DumpPipeOutput' => 'Export.php',
+               'DumpGZipOutput' => 'Export.php',
+               'DumpBZip2Output' => 'Export.php',
+               'Dump7ZipOutput' => 'Export.php',
+               'DumpFilter' => 'Export.php',
+               'DumpNotalkFilter' => 'Export.php',
+               'DumpNamespaceFilter' => 'Export.php',
+               'DumpLatestFilter' => 'Export.php',
+               'DumpMultiWriter' => 'Export.php',
+               'ExternalEdit' => 'ExternalEdit.php',
+               'ExternalStore' => 'ExternalStore.php',
+               'ExternalStoreDB' => 'ExternalStoreDB.php',
+               'ExternalStoreHttp' => 'ExternalStoreHttp.php',
+               'FakeTitle' => 'FakeTitle.php',
+               'FeedItem' => 'Feed.php',
+               'ChannelFeed' => 'Feed.php',
+               'RSSFeed' => 'Feed.php',
+               'AtomFeed' => 'Feed.php',
+               'ReplacerCallback' => 'GlobalFunctions.php',
+               'Group' => 'Group.php',
+               'HTMLForm' => 'HTMLForm.php',
+               'HistoryBlob' => 'HistoryBlob.php',
+               'ConcatenatedGzipHistoryBlob' => 'HistoryBlob.php',
+               'HistoryBlobStub' => 'HistoryBlob.php',
+               'HistoryBlobCurStub' => 'HistoryBlob.php',
+               'Image' => 'Image.php',
+               'ThumbnailImage' => 'Image.php',
+               'ImageGallery' => 'ImageGallery.php',
+               'ImagePage' => 'ImagePage.php',
+               'ImageHistoryList' => 'ImagePage.php',
+               'ImageRemote' => 'ImageRemote.php',
+               'Job' => 'JobQueue.php',
+               'Licenses' => 'Licenses.php',
+               'License' => 'Licenses.php',
+               'LinkBatch' => 'LinkBatch.php',
+               'LinkCache' => 'LinkCache.php',
+               'LinkFilter' => 'LinkFilter.php',
+               'Linker' => 'Linker.php',
+               'LinksUpdate' => 'LinksUpdate.php',
+               'LoadBalancer' => 'LoadBalancer.php',
+               'LogPage' => 'LogPage.php',
+               'MacBinary' => 'MacBinary.php',
+               'MagicWord' => 'MagicWord.php',
+               'MathRenderer' => 'Math.php',
+               'MessageCache' => 'MessageCache.php',
+               'MimeMagic' => 'MimeMagic.php',
+               'Namespace' => 'Namespace.php',
+               'FakeMemCachedClient' => 'ObjectCache.php',
+               'ObjectCacheManager' => 'ObjectCache.php',
+               'MemCachedClientforWiki' => 'ObjectCache.php',
+               'OutputPage' => 'OutputPage.php',
+               'PageHistory' => 'PageHistory.php',
+               'Parser' => 'Parser.php',
+               'ParserOutput' => 'Parser.php',
+               'ParserOptions' => 'Parser.php',
+               'ParserCache' => 'ParserCache.php',
+               'element' => 'ParserXML.php',
+               'xml2php' => 'ParserXML.php',
+               'ParserXML' => 'ParserXML.php',
+               'ProfilerSimple' => 'ProfilerSimple.php',
+               'ProfilerSimpleUDP' => 'ProfilerSimpleUDP.php',
+               'Profiler' => 'Profiling.php',
+               'ProxyTools' => 'ProxyTools.php',
+               'ProtectionForm' => 'ProtectionForm.php',
+               'QueryPage' => 'QueryPage.php',
+               'PageQueryPage' => 'QueryPage.php',
+               'RawPage' => 'RawPage.php',
+               'RecentChange' => 'RecentChange.php',
+               'Revision' => 'Revision.php',
+               'Sanitizer' => 'Sanitizer.php',
+               'SearchEngine' => 'SearchEngine.php',
+               'SearchResultSet' => 'SearchEngine.php',
+               'SearchResult' => 'SearchEngine.php',
+               'SearchEngineDummy' => 'SearchEngine.php',
+               'SearchMySQL' => 'SearchMySQL.php',
+               'MySQLSearchResultSet' => 'SearchMySQL.php',
+               'SearchMySQL4' => 'SearchMySQL4.php',
+               'SearchTsearch2' => 'SearchTsearch2.php',
+               'SearchUpdate' => 'SearchUpdate.php',
+               'SearchUpdateMyISAM' => 'SearchUpdate.php',
+               'SiteConfiguration' => 'SiteConfiguration.php',
+               'SiteStatsUpdate' => 'SiteStatsUpdate.php',
+               'Skin' => 'Skin.php',
+               'MediaWiki_I18N' => 'SkinTemplate.php',
+               'SkinTemplate' => 'SkinTemplate.php',
+               'QuickTemplate' => 'SkinTemplate.php',
+               'SpecialAllpages' => 'SpecialAllpages.php',
+               'AncientPagesPage' => 'SpecialAncientpages.php',
+               'IPBlockForm' => 'SpecialBlockip.php',
+               'BookSourceList' => 'SpecialBooksources.php',
+               'BrokenRedirectsPage' => 'SpecialBrokenRedirects.php',
+               'CategoriesPage' => 'SpecialCategories.php',
+               'EmailConfirmation' => 'SpecialConfirmemail.php',
+               'contribs_finder' => 'SpecialContributions.php',
+               'DeadendPagesPage' => 'SpecialDeadendpages.php',
+               'DisambiguationsPage' => 'SpecialDisambiguations.php',
+               'DoubleRedirectsPage' => 'SpecialDoubleRedirects.php',
+               'EmailUserForm' => 'SpecialEmailuser.php',
+               'GroupsForm' => 'SpecialGroups.php',
+               'WikiRevision' => 'SpecialImport.php',
+               'WikiImporter' => 'SpecialImport.php',
+               'ImportStringSource' => 'SpecialImport.php',
+               'ImportStreamSource' => 'SpecialImport.php',
+               'IPUnblockForm' => 'SpecialIpblocklist.php',
+               'ListredirectsPage' => 'SpecialListredirects.php',
+               'ListUsersPage' => 'SpecialListusers.php',
+               'DBLockForm' => 'SpecialLockdb.php',
+               'LogReader' => 'SpecialLog.php',
+               'LogViewer' => 'SpecialLog.php',
+               'LonelyPagesPage' => 'SpecialLonelypages.php',
+               'LongPagesPage' => 'SpecialLongpages.php',
+               'MIMEsearchPage' => 'SpecialMIMEsearch.php',
+               'MostcategoriesPage' => 'SpecialMostcategories.php',
+               'MostimagesPage' => 'SpecialMostimages.php',
+               'MostlinkedPage' => 'SpecialMostlinked.php',
+               'MostlinkedCategoriesPage' => 'SpecialMostlinkedcategories.php',
+               'MostrevisionsPage' => 'SpecialMostrevisions.php',
+               'MovePageForm' => 'SpecialMovepage.php',
+               'NewPagesPage' => 'SpecialNewpages.php',
+               'SpecialPage' => 'SpecialPage.php',
+               'UnlistedSpecialPage' => 'SpecialPage.php',
+               'IncludableSpecialPage' => 'SpecialPage.php',
+               'PopularPagesPage' => 'SpecialPopularpages.php',
+               'PreferencesForm' => 'SpecialPreferences.php',
+               'SpecialPrefixindex' => 'SpecialPrefixindex.php',
+               'RevisionDeleteForm' => 'SpecialRevisiondelete.php',
+               'RevisionDeleter' => 'SpecialRevisiondelete.php',
+               'SpecialSearch' => 'SpecialSearch.php',
+               'ShortPagesPage' => 'SpecialShortpages.php',
+               'UncategorizedCategoriesPage' => 'SpecialUncategorizedcategories.php',
+               'UncategorizedPagesPage' => 'SpecialUncategorizedpages.php',
+               'PageArchive' => 'SpecialUndelete.php',
+               'UndeleteForm' => 'SpecialUndelete.php',
+               'DBUnlockForm' => 'SpecialUnlockdb.php',
+               'UnusedCategoriesPage' => 'SpecialUnusedcategories.php',
+               'UnusedimagesPage' => 'SpecialUnusedimages.php',
+               'UnusedtemplatesPage' => 'SpecialUnusedtemplates.php',
+               'UnwatchedpagesPage' => 'SpecialUnwatchedpages.php',
+               'UploadForm' => 'SpecialUpload.php',
+               'UploadFormMogile' => 'SpecialUploadMogile.php',
+               'LoginForm' => 'SpecialUserlogin.php',
+               'UserrightsForm' => 'SpecialUserrights.php',
+               'SpecialVersion' => 'SpecialVersion.php',
+               'WantedCategoriesPage' => 'SpecialWantedcategories.php',
+               'WantedPagesPage' => 'SpecialWantedpages.php',
+               'WhatLinksHerePage' => 'SpecialWhatlinkshere.php',
+               'SquidUpdate' => 'SquidUpdate.php',
+               'Title' => 'Title.php',
+               'User' => 'User.php',
+               'MailAddress' => 'UserMailer.php',
+               'EmailNotification' => 'UserMailer.php',
+               'WatchedItem' => 'WatchedItem.php',
+               'WebRequest' => 'WebRequest.php',
+               'FauxRequest' => 'WebRequest.php',
+               'MediaWiki' => 'Wiki.php',
+               'WikiError' => 'WikiError.php',
+               'WikiErrorMsg' => 'WikiError.php',
+               'WikiXmlError' => 'WikiError.php',
+               'ZhClient' => 'ZhClient.php',
+               'memcached' => 'memcached-client.php',
+               'UtfNormal' => 'normal/UtfNormal.php'
+       );
+       require($classes[$class_name]);
+}
+
+?>
\ No newline at end of file
index 42969b6..c2f8ea3 100644 (file)
@@ -169,7 +169,7 @@ class Block
        {
                $fname = 'Block::loadRange';
 
-               $iaddr = wfIP2Hex( $address );
+               $iaddr = ProxyTools::IP2Hex( $address );
                if ( $iaddr === false ) {
                        # Invalid address
                        return false;
@@ -207,7 +207,7 @@ class Block
         * Determine if a given integer IPv4 address is in a given CIDR network
         */
        function isAddressInRange( $addr, $range ) {
-               list( $network, $bits ) = wfParseCIDR( $range );
+               list( $network, $bits ) = ProxyTools::parseCIDR( $range );
                if ( $network !== false && $addr >> ( 32 - $bits ) == $network >> ( 32 - $bits ) ) {
                        return true;
                } else {
@@ -241,7 +241,7 @@ class Block
                $this->mRangeStart = '';
                $this->mRangeEnd = '';
                if ( $this->mUser == 0 ) {
-                       list( $network, $bits ) = wfParseCIDR( $this->mAddress );
+                       list( $network, $bits ) = ProxyTools::parseCIDR( $this->mAddress );
                        if ( $network !== false ) {
                                $this->mRangeStart = sprintf( '%08X', $network );
                                $this->mRangeEnd = sprintf( '%08X', $network + (1 << (32 - $bits)) - 1 );
@@ -431,7 +431,7 @@ class Block
                $parts = explode( '/', $range );
                if ( count( $parts ) == 2 ) {
                        $shift = 32 - $parts[1];
-                       $ipint = wfIP2Unsigned( $parts[0] );
+                       $ipint = ProxyTools::IP2Unsigned( $parts[0] );
                        $ipint = $ipint >> $shift << $shift;
                        $newip = long2ip( $ipint );
                        $range = "$newip/{$parts[1]}";
index 0d116f7..b9e307f 100644 (file)
@@ -5,11 +5,6 @@
  * @subpackage Cache
  */
 
-/**
- * We need the title class
- */
-require_once( 'Title.php' );
-
 /**
  * Handles talking to the file cache, putting stuff in and taking it back out.
  * Mostly called from Article.php, also from DatabaseFunctions.php for the
index d574dda..6d85e37 100644 (file)
@@ -10,9 +10,6 @@ if( !defined( 'MEDIAWIKI' ) )
        die( -1 );
 
 global $wgCategoryMagicGallery;
-if( $wgCategoryMagicGallery )
-       /** */
-       require_once('ImageGallery.php');
 
 /**
  * @package MediaWiki
index 59c410f..a34b496 100644 (file)
@@ -7,7 +7,6 @@
  * - recent changes
  */
 
-require_once("RecentChange.php");
 /**
  * @todo document
  * @package MediaWiki
index ff33de7..6721687 100644 (file)
 /**
  * This is largely cadged from PageHistory::history
  */
-function showCreditsPage($article) {
-       global $wgOut;
+class Credits {
+       function showCreditsPage($article) {
+               global $wgOut;
 
-       $fname = 'showCreditsPage';
+               $fname = 'Credits::showCreditsPage';
 
-       wfProfileIn( $fname );
+               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 {
-               $s = getCredits($article, -1);
-       }
+               $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 {
+                       $s = Credits::getCredits($article, -1);
+               }
 
-       $wgOut->addHTML( $s );
+               $wgOut->addHTML( $s );
 
-       wfProfileOut( $fname );
-}
+               wfProfileOut( $fname );
+       }
 
-function getCredits($article, $cnt, $showIfMax=true) {
-       $fname = 'getCredits';
-       wfProfileIn( $fname );
-       $s = '';
+       function getCredits($article, $cnt, $showIfMax=true) {
+               $fname = 'Credits::getCredits';
+               wfProfileIn( $fname );
+               $s = '';
 
-       if (isset($cnt) && $cnt != 0) {
-               $s = getAuthorCredits($article);
-               if ($cnt > 1 || $cnt < 0) {
-                       $s .= ' ' . getContributorCredits($article, $cnt - 1, $showIfMax);
+               if (isset($cnt) && $cnt != 0) {
+                       $s = Credits::getAuthorCredits($article);
+                       if ($cnt > 1 || $cnt < 0) {
+                               $s .= ' ' . Credits::getContributorCredits($article, $cnt - 1, $showIfMax);
+                       }
                }
+
+               wfProfileOut( $fname );
+               return $s;
        }
 
-       wfProfileOut( $fname );
-       return $s;
-}
+       /**
+        *
+        */
+       function getAuthorCredits($article) {
+               global $wgLang, $wgAllowRealName;
 
-/**
- *
- */
-function getAuthorCredits($article) {
-       global $wgLang, $wgAllowRealName;
+               $last_author = $article->getUser();
 
-       $last_author = $article->getUser();
+               if ($last_author == 0) {
+                       $author_credit = wfMsg('anonymous');
+               } else {
+                       if($wgAllowRealName) { $real_name = User::whoIsReal($last_author); }
+                       $user_name = User::whoIs($last_author);
 
-       if ($last_author == 0) {
-               $author_credit = wfMsg('anonymous');
-       } else {
-               if($wgAllowRealName) { $real_name = User::whoIsReal($last_author); }
-               $user_name = User::whoIs($last_author);
+                       if (!empty($real_name)) {
+                               $author_credit = Credits::creditLink($user_name, $real_name);
+                       } else {
+                               $author_credit = wfMsg('siteuser', Credits::creditLink($user_name));
+                       }
+               }
 
-               if (!empty($real_name)) {
-                       $author_credit = creditLink($user_name, $real_name);
+               $timestamp = $article->getTimestamp();
+               if ($timestamp) {
+                       $d = $wgLang->timeanddate($article->getTimestamp(), true);
                } else {
-                       $author_credit = wfMsg('siteuser', creditLink($user_name));
+                       $d = '';
                }
+               return wfMsg('lastmodifiedby', $d, $author_credit);
        }
 
-       $timestamp = $article->getTimestamp();
-       if ($timestamp) {
-               $d = $wgLang->timeanddate($article->getTimestamp(), true);
-       } else {
-               $d = '';
-       }
-       return wfMsg('lastmodifiedby', $d, $author_credit);
-}
+       /**
+        *
+        */
+       function getContributorCredits($article, $cnt, $showIfMax) {
 
-/**
- *
- */
-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) {
-               $others_link = creditOthersLink($article);
-               if (!$showIfMax) {
-                       return wfMsg('othercontribs', $others_link);
-               } else {
-                       $contributors = array_slice($contributors, 0, $cnt);
+               if ($cnt > 0 && count($contributors) > $cnt) {
+                       $others_link = Credits::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) {
-               if ($user_parts[0] != 0) {
-                       if ($wgAllowRealName && !empty($user_parts[2])) {
-                               $real_names[] = creditLink($user_parts[1], $user_parts[2]);
+               foreach ($contributors as $user_parts) {
+                       if ($user_parts[0] != 0) {
+                               if ($wgAllowRealName && !empty($user_parts[2])) {
+                                       $real_names[] = Credits::creditLink($user_parts[1], $user_parts[2]);
+                               } else {
+                                       $user_names[] = Credits::creditLink($user_parts[1]);
+                               }
                        } else {
-                               $user_names[] = creditLink($user_parts[1]);
+                               $anon = wfMsg('anonymous');
                        }
-               } 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) {
-               if (!empty($s)) {
-                       array_push($fulllist, $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 ));
-}
+       /**
       *
       */
+       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 ));
+       }
 
-/**
- *
- */
-function creditOthersLink($article) {
-       global $wgUser;
-       $skin = $wgUser->getSkin();
-       return $skin->makeKnownLink($article->mTitle->getPrefixedText(), wfMsg('others'), 'action=credits');
+       /**
+        *
+        */
+       function creditOthersLink($article) {
+               global $wgUser;
+               $skin = $wgUser->getSkin();
+               return $skin->makeKnownLink($article->mTitle->getPrefixedText(), wfMsg('others'), 'action=credits');
+       }
 }
-
 ?>
index 2bdf610..904e2bd 100644 (file)
@@ -5,11 +5,6 @@
  * @package MediaWiki
  */
 
-/**
- * Depends on the CacheManager
- */
-require_once( 'CacheManager.php' );
-
 /** See Database::makeList() */
 define( 'LIST_COMMA', 0 );
 define( 'LIST_AND', 1 );
index 226bb4d..396b1c1 100644 (file)
@@ -6,11 +6,6 @@
  * @package MediaWiki
  */
 
-/**
- * Depends on database
- */
-require_once( 'Database.php' );
-
 class OracleBlob extends DBObject {
        function isLOB() {
                return true;
index 130a247..442ec35 100644 (file)
  * @package MediaWiki
  */
 
-/**
- * Depends on database
- */
-require_once( 'Database.php' );
-
 /**
  *
  * @package MediaWiki
index 58fdc76..900d503 100644 (file)
@@ -5,9 +5,6 @@
  * @subpackage DifferenceEngine
  */
 
-/** */
-require_once( 'Revision.php' );
-
 define( 'MAX_DIFF_LINE', 10000 );
 define( 'MAX_DIFF_XREF_LENGTH', 10000 );
 
index 341427b..28b4084 100644 (file)
@@ -725,7 +725,7 @@ class EditPage {
                $this->summary = '';
                if ( !$this->mArticle->exists() && $this->mArticle->mTitle->getNamespace() == NS_MEDIAWIKI )
                        $this->textbox1 = wfMsgWeirdKey ( $this->mArticle->mTitle->getText() ) ;
-               wfProxyCheck();
+               ProxyTools::proxyCheck();
        }
 
        /**
@@ -1118,7 +1118,6 @@ END
                $wgOut->addHTML( "<input type=\"hidden\" name=\"wpAutoSummary\" value=\"$autosumm\" />\n" );
 
                if ( $this->isConflict ) {
-                       require_once( "DifferenceEngine.php" );
                        $wgOut->addWikiText( '==' . wfMsg( "yourdiff" ) . '==' );
 
                        $de = new DifferenceEngine( $this->mTitle );
@@ -1618,7 +1617,6 @@ END
         * @return string HTML
         */
        function getDiff() {
-               require_once( 'DifferenceEngine.php' );
                $oldtext = $this->mArticle->fetchContent();
                $newtext = $this->mArticle->replaceSection(
                        $this->section, $this->textbox1, $this->summary, $this->edittime );
index d0253eb..244bbd3 100644 (file)
@@ -22,9 +22,6 @@
  * @subpackage SpecialPage
  */
 
-/** */
-require_once( 'Revision.php' );
-
 define( 'MW_EXPORT_FULL',     0 );
 define( 'MW_EXPORT_CURRENT',  1 );
 
index f610df8..70713d0 100644 (file)
@@ -6,8 +6,6 @@
  * DB accessable external objects
  *
  */
-require_once( 'LoadBalancer.php' );
-
 
 /** @package MediaWiki */
 
index f8ef126..ee48231 100644 (file)
@@ -27,8 +27,6 @@ $wgTotalEdits = -1;
 
 
 require_once( 'DatabaseFunctions.php' );
-require_once( 'UpdateClasses.php' );
-require_once( 'LogPage.php' );
 require_once( 'normal/UtfNormalUtil.php' );
 require_once( 'XmlFunctions.php' );
 
@@ -1508,11 +1506,6 @@ function &wfGetMimeMagic() {
                return $wgMimeMagic;
        }
 
-       if (!class_exists("MimeMagic")) {
-               #include on demand
-               require_once("MimeMagic.php");
-       }
-
        $wgMimeMagic= new MimeMagic();
 
        return $wgMimeMagic;
@@ -1861,4 +1854,27 @@ class ReplacerCallback {
        }
 }
 
+/***** DEPRECATED INTERFACES *******/
+function wfGetForwardedFor() { return ProxyTools::getForwardedFor(); }
+function wfGetIP() { return ProxyTools::getIP(); }
+function wfIP2Unsigned($ip) { return ProxyTools::IP2Unsigned($ip); }
+function wfIP2Hex($ip) { return ProxyTools::IP2Hex($ip); }
+function wfIsIPPublic($ip) { return ProxyTools::isIPPublic($ip); }
+function wfProxyCheck() { return ProxyTools::proxyCheck(); }
+function wfParseCIDR($range) { return ProxyTools::parseCIDR($range); }
+function wfIsLocallyBlockedProxy($ip) { return ProxyTools::isLocallyBlockedProxy($ip); }
+
+function wfGetCache($type) { return ObjectCacheManager::getCache($type); }
+function wfGetMainCache() { return ObjectCacheManager::getMainCache(); }
+function wfGetMessageCacheStorage() { return ObjectCacheManager::getMessageCache(); }
+function wfGetParserCacheStorage() { return ObjectCacheManager::getParserCache(); }
+
+function renderMath($tex) { return MathRenderer::renderMath($tex); }
+
+function showCreditsPage($article) { return Credits::showCreditsPage($article); }
+function getCredits($article, $cnt, $showIfMax=true) { return Credits::getCredits($article,$cnt,$showIfMax); }
+
+function wfGetHTTP( $url, $timeout = 'default' ) { return HttpFunctions::getHTTP($url,$timeout); }
+function wfIsLocalURL( $url ) { return HttpFunctions::isLocalURL($url); }
+
 ?>
index 4dee4da..8679660 100644 (file)
@@ -167,17 +167,6 @@ class ConcatenatedGzipHistoryBlob extends HistoryBlob
        }
 }
 
-
-/**
- * One-step cache variable to hold base blobs; operations that
- * pull multiple revisions may often pull multiple times from
- * the same blob. By keeping the last-used one open, we avoid
- * redundant unserialization and decompression overhead.
- */
-global $wgBlobCache;
-$wgBlobCache = array();
-
-
 /**
  * @package MediaWiki
  */
@@ -215,6 +204,15 @@ class HistoryBlobStub {
        function getText() {
                $fname = 'HistoryBlob::getText';
                global $wgBlobCache;
+               /**
+                * One-step cache variable to hold base blobs; operations that
+                * pull multiple revisions may often pull multiple times from
+                * the same blob. By keeping the last-used one open, we avoid
+                * redundant unserialization and decompression overhead.
+                */
+               if (!is_array($wgBlobCache)) {
+                       $wgBlobCache = array();
+               }
                if( isset( $wgBlobCache[$this->mOldId] ) ) {
                        $obj = $wgBlobCache[$this->mOldId];
                } else {
@@ -231,7 +229,6 @@ class HistoryBlobStub {
                                        wfProfileOut( $fname );
                                        return false;
                                }
-                               require_once('ExternalStore.php');
                                $row->old_text=ExternalStore::fetchFromUrl($url);
 
                        }
index fd2e87e..f748640 100644 (file)
@@ -3,88 +3,89 @@
  * Various HTTP related functions
  */
 
-/**
- * Get the contents of a file by HTTP
- *
- * if $timeout is 'default', $wgHTTPTimeout is used
- */
-function wfGetHTTP( $url, $timeout = 'default' ) {
-       global $wgHTTPTimeout, $wgHTTPProxy, $wgVersion, $wgTitle;
+class HttpFunctions {
+       /**
+        * Get the contents of a file by HTTP
+        *
+        * if $timeout is 'default', $wgHTTPTimeout is used
+        */
+       function getHTTP( $url, $timeout = 'default' ) {
+               global $wgHTTPTimeout, $wgHTTPProxy, $wgVersion, $wgTitle;
 
-       # Use curl if available
-       if ( function_exists( 'curl_init' ) ) {
-               $c = curl_init( $url );
-               if ( wfIsLocalURL( $url ) ) {
-                       curl_setopt( $c, CURLOPT_PROXY, 'localhost:80' );
-               } else if ($wgHTTPProxy) {
-                       curl_setopt($c, CURLOPT_PROXY, $wgHTTPProxy);
-               }
+               # Use curl if available
+               if ( function_exists( 'curl_init' ) ) {
+                       $c = curl_init( $url );
+                       if ( HttpFunctions::isLocalURL( $url ) ) {
+                               curl_setopt( $c, CURLOPT_PROXY, 'localhost:80' );
+                       } else if ($wgHTTPProxy) {
+                               curl_setopt($c, CURLOPT_PROXY, $wgHTTPProxy);
+                       }
 
-               if ( $timeout == 'default' ) {
-                       $timeout = $wgHTTPTimeout;
-               }
-               curl_setopt( $c, CURLOPT_TIMEOUT, $timeout );
-               curl_setopt( $c, CURLOPT_USERAGENT, "MediaWiki/$wgVersion" );
+                       if ( $timeout == 'default' ) {
+                               $timeout = $wgHTTPTimeout;
+                       }
+                       curl_setopt( $c, CURLOPT_TIMEOUT, $timeout );
+                       curl_setopt( $c, CURLOPT_USERAGENT, "MediaWiki/$wgVersion" );
 
-               # Set the referer to $wgTitle, even in command-line mode
-               # This is useful for interwiki transclusion, where the foreign
-               # server wants to know what the referring page is.
-               # $_SERVER['REQUEST_URI'] gives a less reliable indication of the
-               # referring page.
-               if ( is_object( $wgTitle ) ) {
-                       curl_setopt( $c, CURLOPT_REFERER, $wgTitle->getFullURL() );
-               }
+                       # Set the referer to $wgTitle, even in command-line mode
+                       # This is useful for interwiki transclusion, where the foreign
+                       # server wants to know what the referring page is.
+                       # $_SERVER['REQUEST_URI'] gives a less reliable indication of the
+                       # referring page.
+                       if ( is_object( $wgTitle ) ) {
+                               curl_setopt( $c, CURLOPT_REFERER, $wgTitle->getFullURL() );
+                       }
 
-               ob_start();
-               curl_exec( $c );
-               $text = ob_get_contents();
-               ob_end_clean();
+                       ob_start();
+                       curl_exec( $c );
+                       $text = ob_get_contents();
+                       ob_end_clean();
 
-               # Don't return the text of error messages, return false on error
-               if ( curl_getinfo( $c, CURLINFO_HTTP_CODE ) != 200 ) {
-                       $text = false;
+                       # Don't return the text of error messages, return false on error
+                       if ( curl_getinfo( $c, CURLINFO_HTTP_CODE ) != 200 ) {
+                               $text = false;
+                       }
+                       curl_close( $c );
+               } else {
+                       # Otherwise use file_get_contents, or its compatibility function from GlobalFunctions.php
+                       # This may take 3 minutes to time out, and doesn't have local fetch capabilities
+                       $url_fopen = ini_set( 'allow_url_fopen', 1 );
+                       $text = file_get_contents( $url );
+                       ini_set( 'allow_url_fopen', $url_fopen );
                }
-               curl_close( $c );
-       } else {
-               # Otherwise use file_get_contents, or its compatibility function from GlobalFunctions.php
-               # This may take 3 minutes to time out, and doesn't have local fetch capabilities
-               $url_fopen = ini_set( 'allow_url_fopen', 1 );
-               $text = file_get_contents( $url );
-               ini_set( 'allow_url_fopen', $url_fopen );
+               return $text;
        }
-       return $text;
-}
 
-/**
- * Check if the URL can be served by localhost
- */
-function wfIsLocalURL( $url ) {
-       global $wgCommandLineMode, $wgConf;
-       if ( $wgCommandLineMode ) {
-               return false;
-       }
+       /**
       * Check if the URL can be served by localhost
       */
+       function isLocalURL( $url ) {
+               global $wgCommandLineMode, $wgConf;
+               if ( $wgCommandLineMode ) {
+                       return false;
+               }
 
-       // Extract host part
-       $matches = array();
-       if ( preg_match( '!^http://([\w.-]+)[/:].*$!', $url, $matches ) ) {
-               $host = $matches[1];
-               // Split up dotwise
-               $domainParts = explode( '.', $host );
-               // Check if this domain or any superdomain is listed in $wgConf as a local virtual host
-               $domainParts = array_reverse( $domainParts );
-               for ( $i = 0; $i < count( $domainParts ); $i++ ) {
-                       $domainPart = $domainParts[$i];
-                       if ( $i == 0 ) {
-                               $domain = $domainPart;
-                       } else {
-                               $domain = $domainPart . '.' . $domain;
-                       }
-                       if ( $wgConf->isLocalVHost( $domain ) ) {
-                               return true;
+               // Extract host part
+               $matches = array();
+               if ( preg_match( '!^http://([\w.-]+)[/:].*$!', $url, $matches ) ) {
+                       $host = $matches[1];
+                       // Split up dotwise
+                       $domainParts = explode( '.', $host );
+                       // Check if this domain or any superdomain is listed in $wgConf as a local virtual host
+                       $domainParts = array_reverse( $domainParts );
+                       for ( $i = 0; $i < count( $domainParts ); $i++ ) {
+                               $domainPart = $domainParts[$i];
+                               if ( $i == 0 ) {
+                                       $domain = $domainPart;
+                               } else {
+                                       $domain = $domainPart . '.' . $domain;
+                               }
+                               if ( $wgConf->isLocalVHost( $domain ) ) {
+                                       return true;
+                               }
                        }
                }
+               return false;
        }
-       return false;
 }
-
 ?>
index b219642..8e6cf43 100644 (file)
@@ -12,9 +12,6 @@
  * extension=extensions/php_exif.dll
  */
 
-if ($wgShowEXIF)
-       require_once('Exif.php');
-
 /**
  * Bump this number when serialized cache records may be incompatible.
  */
index 9b91c87..e9ed191 100644 (file)
@@ -9,8 +9,6 @@
 if( !defined( 'MEDIAWIKI' ) )
        die( -1 );
 
-require_once( 'Image.php' );
-
 /**
  * Special handling for image description pages
  * @package MediaWiki
@@ -309,9 +307,8 @@ END
                $wgOut->addHTML($sharedtext);
 
                if ($wgRepositoryBaseUrl && $wgFetchCommonsDescriptions) {
-                       require_once("HttpFunctions.php");
                        $ur = ini_set('allow_url_fopen', true);
-                       $text = wfGetHTTP($url . '?action=render');
+                       $text = HttpFunctions::getHTTP($url . '?action=render');
                        ini_set('allow_url_fopen', $ur);
                        if ($text)
                                $this->mExtraDescription = $text;
@@ -674,7 +671,6 @@ END
        }
 
        function blockedIPpage() {
-               require_once( 'EditPage.php' );
                $edit = new EditPage( $this );
                return $edit->blockedIPpage();
        }
index bd09502..5472858 100644 (file)
@@ -119,7 +119,6 @@ class LinksUpdate {
                if ( $this->mRecursive ) {
                        $tlto = $this->mTitle->getTemplateLinksTo();
                        if ( count( $tlto ) ) {
-                               require_once( 'JobQueue.php' );
                                Job::queueLinksJobs( $tlto );
                        }
                }
@@ -155,7 +154,6 @@ class LinksUpdate {
                if ( $this->mRecursive ) {
                        $tlto = $this->mTitle->getTemplateLinksTo();
                        if ( count( $tlto ) ) {
-                               require_once( 'JobQueue.php' );
                                Job::queueLinksJobs( $tlto );
                        }
                }
index 6cf743b..3e6cd7e 100644 (file)
@@ -7,7 +7,6 @@
 /**
  * Depends on the database object
  */
-require_once( 'Database.php' );
 
 # Valid database indexes
 # Operation-based indexes
@@ -440,12 +439,14 @@ class LoadBalancer {
                }
 
                extract( $server );
+
                # Get class for this database type
-               $class = 'Database' . ucfirst( $type );
-               if ( !class_exists( $class ) ) {
-                       require_once( "$class.php" );
+               if ($type != 'mysql' ) {
+                       $class = 'Database' . ucfirst( $type );
+               } else {
+                       $class = 'Database';
                }
-
+               
                # Create object
                $db = new $class( $host, $user, $password, $dbname, 1, $flags );
                $db->setLBInfo( $server );
index c3b2367..753c1dc 100644 (file)
@@ -83,7 +83,6 @@ class LogPage {
                                        $rcComment .= ': ' . $this->comment;
                        }
 
-                       require_once( 'RecentChange.php' );
                        RecentChange::notifyLog( $now, $titleObj, $wgUser, $rcComment, '',
                                $this->type, $this->action, $this->target, $this->comment, $this->params );
                }
index e40abdf..d47a429 100644 (file)
@@ -248,15 +248,13 @@ class MathRenderer {
                wfDebug( "TeX: getHashPath, hash is: $this->hash, path is: $path\n" );
                return $path;
        }
-
-
-}
-
-function renderMath( $tex ) {
-       global $wgUser;
-       $math = new MathRenderer( $tex );
-       $math->setOutputMode( $wgUser->getOption('math'));
-       return $math->render();
+       
+       static function renderMath ( $tex ) {
+               global $wgUser;
+               $math = new MathRenderer( $tex );
+               $math->setOutputMode( $wgUser->getOption('math'));
+               return $math->render();
+       }
 }
 
 ?>
index 8e54af9..083e220 100644 (file)
@@ -5,9 +5,6 @@
  * @subpackage Cache
  */
 
-/** */
-require_once( 'Revision.php' );
-
 /**
  *
  */
index fe7417d..d851f3a 100644 (file)
@@ -33,93 +33,91 @@ class FakeMemCachedClient {
 global $wgCaches;
 $wgCaches = array();
 
-/** @todo document */
-function &wfGetCache( $inputType ) {
-       global $wgCaches, $wgMemCachedServers, $wgMemCachedDebug, $wgMemCachedPersistent;
-       $cache = false;
+class ObjectCacheManager {
+       /* @static */
+       function getCache( $inputType ) {
+               global $wgCaches, $wgMemCachedServers, $wgMemCachedDebug, $wgMemCachedPersistent;
+               $cache = false;
 
-       if ( $inputType == CACHE_ANYTHING ) {
-               reset( $wgCaches );
-               $type = key( $wgCaches );
-               if ( $type === false || $type === CACHE_NONE ) {
-                       $type = CACHE_DB;
+               if ( $inputType == CACHE_ANYTHING ) {
+                       reset( $wgCaches );
+                       $type = key( $wgCaches );
+                       if ( $type === false || $type === CACHE_NONE ) {
+                               $type = CACHE_DB;
+                       }
+               } else {
+                       $type = $inputType;
                }
-       } else {
-               $type = $inputType;
-       }
-
-       if ( $type == CACHE_MEMCACHED ) {
-               if ( !array_key_exists( CACHE_MEMCACHED, $wgCaches ) ){
-                       require_once( 'memcached-client.php' );
 
-                       if (!class_exists("MemcachedClientforWiki")) {
-                               class MemCachedClientforWiki extends memcached {
-                                       function _debugprint( $text ) {
-                                               wfDebug( "memcached: $text\n" );
-                                       }
+               if ( $type == CACHE_MEMCACHED ) {
+                       if ( !array_key_exists( CACHE_MEMCACHED, $wgCaches ) ){
+                               $wgCaches[CACHE_DB] = new MemCachedClientforWiki(
+                                       array('persistant' => $wgMemCachedPersistent, 'compress_threshold' => 1500 ) );
+                               $cache =& $wgCaches[CACHE_DB];
+                               $cache->set_servers( $wgMemCachedServers );
+                               $cache->set_debug( $wgMemCachedDebug );
+                       }
+               } elseif ( $type == CACHE_ACCEL ) {
+                       if ( !array_key_exists( CACHE_ACCEL, $wgCaches ) ) {
+                               if ( function_exists( 'eaccelerator_get' ) ) {
+                                       $wgCaches[CACHE_ACCEL] = new eAccelBagOStuff;
+                               } elseif ( function_exists( 'apc_fetch') ) {
+                                       $wgCaches[CACHE_ACCEL] = new APCBagOStuff;
+                               } elseif ( function_exists( 'mmcache_get' ) ) {
+                                       $wgCaches[CACHE_ACCEL] = new TurckBagOStuff;
+                               } else {
+                                       $wgCaches[CACHE_ACCEL] = false;
                                }
                        }
+                       if ( $wgCaches[CACHE_ACCEL] !== false ) {
+                               $cache =& $wgCaches[CACHE_ACCEL];
+                       }
+               }
 
-                       $wgCaches[CACHE_DB] = new MemCachedClientforWiki(
-                               array('persistant' => $wgMemCachedPersistent, 'compress_threshold' => 1500 ) );
+               if ( $type == CACHE_DB || ( $inputType == CACHE_ANYTHING && $cache === false ) ) {
+                       if ( !array_key_exists( CACHE_DB, $wgCaches ) ) {
+                               $wgCaches[CACHE_DB] = new MediaWikiBagOStuff('objectcache');
+                       }
                        $cache =& $wgCaches[CACHE_DB];
-                       $cache->set_servers( $wgMemCachedServers );
-                       $cache->set_debug( $wgMemCachedDebug );
                }
-       } elseif ( $type == CACHE_ACCEL ) {
-               if ( !array_key_exists( CACHE_ACCEL, $wgCaches ) ) {
-                       if ( function_exists( 'eaccelerator_get' ) ) {
-                               require_once( 'BagOStuff.php' );
-                               $wgCaches[CACHE_ACCEL] = new eAccelBagOStuff;
-                       } elseif ( function_exists( 'apc_fetch') ) {
-                               require_once( 'BagOStuff.php' );
-                               $wgCaches[CACHE_ACCEL] = new APCBagOStuff;
-                       } elseif ( function_exists( 'mmcache_get' ) ) {
-                               require_once( 'BagOStuff.php' );
-                               $wgCaches[CACHE_ACCEL] = new TurckBagOStuff;
-                       } else {
-                               $wgCaches[CACHE_ACCEL] = false;
+
+               if ( $cache === false ) {
+                       if ( !array_key_exists( CACHE_NONE, $wgCaches ) ) {
+                               $wgCaches[CACHE_NONE] = new FakeMemCachedClient;
                        }
+                       $cache =& $wgCaches[CACHE_NONE];
                }
-               if ( $wgCaches[CACHE_ACCEL] !== false ) {
-                       $cache =& $wgCaches[CACHE_ACCEL];
-               }
-       }
 
-       if ( $type == CACHE_DB || ( $inputType == CACHE_ANYTHING && $cache === false ) ) {
-               if ( !array_key_exists( CACHE_DB, $wgCaches ) ) {
-                       require_once( 'BagOStuff.php' );
-                       $wgCaches[CACHE_DB] = new MediaWikiBagOStuff('objectcache');
-               }
-               $cache =& $wgCaches[CACHE_DB];
+               return $cache;
        }
-
-       if ( $cache === false ) {
-               if ( !array_key_exists( CACHE_NONE, $wgCaches ) ) {
-                       $wgCaches[CACHE_NONE] = new FakeMemCachedClient;
-               }
-               $cache =& $wgCaches[CACHE_NONE];
+       
+       /** @static */
+       function &getMainCache() {
+               global $wgMainCacheType;
+               $ret =& ObjectCacheManager::getCache( $wgMainCacheType );
+               return $ret;
        }
 
-       return $cache;
-}
-
-function &wfGetMainCache() {
-       global $wgMainCacheType;
-       $ret =& wfGetCache( $wgMainCacheType );
-       return $ret;
-}
-
-function &wfGetMessageCacheStorage() {
-       global $wgMessageCacheType;
-       $ret =& wfGetCache( $wgMessageCacheType );
-       return $ret;
+       /** @static */
+       function &getMessageCache() {
+               global $wgMessageCacheType;
+               $ret =& ObjectCacheManager::getCache( $wgMessageCacheType );
+               return $ret;
+       }
+       
+       /** @static */
+       function &getParserCache() {
+               global $wgParserCacheType;
+               $ret =& ObjectCacheManager::getCache( $wgParserCacheType );
+               return $ret;
+       }
+       
 }
 
-function &wfGetParserCacheStorage() {
-       global $wgParserCacheType;
-       $ret =& wfGetCache( $wgParserCacheType );
-       return $ret;
+class MemCachedClientforWiki extends memcached {
+       function _debugprint( $text ) {
+               wfDebug( "memcached: $text\n" );
+       }
 }
 
 ?>
index c155d38..451acb2 100644 (file)
@@ -5,9 +5,6 @@ if ( ! defined( 'MEDIAWIKI' ) )
  * @package MediaWiki
  */
 
-if ( $wgUseTeX )
-       require_once 'Math.php';
-
 /**
  * @todo document
  * @package MediaWiki
@@ -650,7 +647,7 @@ class OutputPage {
 
                $id = $wgUser->blockedBy();
                $reason = $wgUser->blockedFor();
-               $ip = wfGetIP();
+               $ip = ProxyTools::getIP();
 
                if ( is_numeric( $id ) ) {
                        $name = User::whoIs( $id );
index 2e70e4d..2c69a3e 100644 (file)
@@ -576,9 +576,6 @@ class PageHistory {
         * @param string $type
         */
        function feed( $type ) {
-               require_once 'Feed.php';
-               require_once 'SpecialRecentchanges.php';
-               
                global $wgFeedClasses;
                if( !isset( $wgFeedClasses[$type] ) ) {
                        global $wgOut;
index 2bfa482..8e6fd96 100644 (file)
@@ -6,11 +6,6 @@
  * @subpackage Parser
  */
 
-/** */
-require_once( 'Sanitizer.php' );
-require_once( 'HttpFunctions.php' );
-require_once( 'ImageGallery.php' );
-
 /**
  * Update this version number when the ParserOutput format
  * changes in an incompatible way, so the parser cache
@@ -452,7 +447,7 @@ class Parser
                                        $output = wfEscapeHTMLTagsOnly( $content );
                                        break;
                                case 'math':
-                                       $output = renderMath( $content );
+                                       $output = MathRenderer::renderMath( $content );
                                        break;
                                case 'pre':
                                        // Backwards-compatibility hack
@@ -2972,7 +2967,7 @@ class Parser
                        }
                }
 
-               $text = wfGetHTTP($url);
+               $text = HttpFunctions::getHTTP($url);
                if (!$text)
                        return wfMsg('scarytranscludefailed', $url);
 
index e7b64f6..b5dae85 100644 (file)
@@ -5,9 +5,6 @@
  * @subpackage Experimental
  */
 
-/** */
-require_once ('Parser.php');
-
 /**
  * This should one day become the XML->(X)HTML parser
  * Based on work by Jan Hidders and Magnus Manske
index edecc4f..531e336 100644 (file)
@@ -278,7 +278,6 @@ class Profiler {
                        }
                }
                $prof .= "\nTotal: $total\n\n";
-
                return $prof;
        }
 
@@ -322,7 +321,6 @@ class Profiler {
                } else {
                        $pfhost = '';
                }
-
                $sql = "UPDATE $profiling "."SET pf_count=pf_count+{$eventCount}, "."pf_time=pf_time + {$timeSum} ".
                        "WHERE pf_name='{$encname}' AND pf_server='{$pfhost}'";
                $dbw->query($sql);
index bed79c1..350078d 100644 (file)
  * @package MediaWiki
  */
 
-function wfGetForwardedFor() {
-       if( function_exists( 'apache_request_headers' ) ) {
-               // More reliable than $_SERVER due to case and -/_ folding
-               $set = apache_request_headers();
-               $index = 'X-Forwarded-For';
-       } else {
-               // Subject to spoofing with headers like X_Forwarded_For
-               $set = $_SERVER;
-               $index = 'HTTP_X_FORWARDED_FOR';
-       }
-       if( isset( $set[$index] ) ) {
-               return $set[$index];
-       } else {
-               return null;
+class ProxyTools {
+       function getForwardedFor() {
+               if( function_exists( 'apache_request_headers' ) ) {
+                       // More reliable than $_SERVER due to case and -/_ folding
+                       $set = apache_request_headers();
+                       $index = 'X-Forwarded-For';
+               } else {
+                       // Subject to spoofing with headers like X_Forwarded_For
+                       $set = $_SERVER;
+                       $index = 'HTTP_X_FORWARDED_FOR';
+               }
+               if( isset( $set[$index] ) ) {
+                       return $set[$index];
+               } else {
+                       return null;
+               }
        }
-}
 
-/** Work out the IP address based on various globals */
-function wfGetIP() {
-       global $wgSquidServers, $wgSquidServersNoPurge, $wgIP;
+       /** Work out the IP address based on various globals */
+       function getIP() {
+               global $wgSquidServers, $wgSquidServersNoPurge, $wgIP;
 
-       # Return cached result
-       if ( !empty( $wgIP ) ) {
-               return $wgIP;
-       }
+               # Return cached result
+               if ( !empty( $wgIP ) ) {
+                       return $wgIP;
+               }
 
-       /* collect the originating ips */
-       # Client connecting to this webserver
-       if ( isset( $_SERVER['REMOTE_ADDR'] ) ) {
-               $ipchain = array( $_SERVER['REMOTE_ADDR'] );
-       } else {
-               # Running on CLI?
-               $ipchain = array( '127.0.0.1' );
-       }
-       $ip = $ipchain[0];
-
-       # Get list of trusted proxies
-       # Flipped for quicker access
-       $trustedProxies = array_flip( array_merge( $wgSquidServers, $wgSquidServersNoPurge ) );
-       if ( count( $trustedProxies ) ) {
-               # Append XFF on to $ipchain
-               $forwardedFor = wfGetForwardedFor();
-               if ( isset( $forwardedFor ) ) {
-                       $xff = array_map( 'trim', explode( ',', $forwardedFor ) );
-                       $xff = array_reverse( $xff );
-                       $ipchain = array_merge( $ipchain, $xff );
-               }
-               # Step through XFF list and find the last address in the list which is a trusted server
-               # Set $ip to the IP address given by that trusted server, unless the address is not sensible (e.g. private)
-               foreach ( $ipchain as $i => $curIP ) {
-                       if ( array_key_exists( $curIP, $trustedProxies ) ) {
-                               if ( isset( $ipchain[$i + 1] ) && wfIsIPPublic( $ipchain[$i + 1] ) ) {
-                                       $ip = $ipchain[$i + 1];
+               /* collect the originating ips */
+               # Client connecting to this webserver
+               if ( isset( $_SERVER['REMOTE_ADDR'] ) ) {
+                       $ipchain = array( $_SERVER['REMOTE_ADDR'] );
+               } else {
+                       # Running on CLI?
+                       $ipchain = array( '127.0.0.1' );
+               }
+               $ip = $ipchain[0];
+
+               # Get list of trusted proxies
+               # Flipped for quicker access
+               $trustedProxies = array_flip( array_merge( $wgSquidServers, $wgSquidServersNoPurge ) );
+               if ( count( $trustedProxies ) ) {
+                       # Append XFF on to $ipchain
+                       $forwardedFor = ProxyTools::getForwardedFor();
+                       if ( isset( $forwardedFor ) ) {
+                               $xff = array_map( 'trim', explode( ',', $forwardedFor ) );
+                               $xff = array_reverse( $xff );
+                               $ipchain = array_merge( $ipchain, $xff );
+                       }
+                       # Step through XFF list and find the last address in the list which is a trusted server
+                       # Set $ip to the IP address given by that trusted server, unless the address is not sensible (e.g. private)
+                       foreach ( $ipchain as $i => $curIP ) {
+                               if ( array_key_exists( $curIP, $trustedProxies ) ) {
+                                       if ( isset( $ipchain[$i + 1] ) && ProxyTools::isIPPublic( $ipchain[$i + 1] ) ) {
+                                               $ip = $ipchain[$i + 1];
+                                       }
+                               } else {
+                                       break;
                                }
-                       } else {
-                               break;
                        }
                }
-       }
-
-       wfDebug( "IP: $ip\n" );
-       $wgIP = $ip;
-       return $ip;
-}
 
-/**
- * Given an IP address in dotted-quad notation, returns an unsigned integer.
- * Like ip2long() except that it actually works and has a consistent error return value.
- */
-function wfIP2Unsigned( $ip ) {
-       $n = ip2long( $ip );
-       if ( $n == -1 || $n === false ) { # Return value on error depends on PHP version
-               $n = false;
-       } elseif ( $n < 0 ) {
-               $n += pow( 2, 32 );
+               wfDebug( "IP: $ip\n" );
+               $wgIP = $ip;
+               return $ip;
+       }
+
+       /**
+        * Given an IP address in dotted-quad notation, returns an unsigned integer.
+        * Like ip2long() except that it actually works and has a consistent error return value.
+        */
+       function IP2Unsigned( $ip ) {
+               $n = ip2long( $ip );
+               if ( $n == -1 || $n === false ) { # Return value on error depends on PHP version
+                       $n = false;
+               } elseif ( $n < 0 ) {
+                       $n += pow( 2, 32 );
+               }
+               return $n;
        }
-       return $n;
-}
 
-/**
- * Return a zero-padded hexadecimal representation of an IP address
- */
-function wfIP2Hex( $ip ) {
-       $n = wfIP2Unsigned( $ip );
-       if ( $n !== false ) {
-               $n = sprintf( '%08X', $n );
+       /**
+        * Return a zero-padded hexadecimal representation of an IP address
+        */
+       function IP2Hex( $ip ) {
+               $n = ProxyTools::IP2Unsigned( $ip );
+               if ( $n !== false ) {
+                       $n = sprintf( '%08X', $n );
+               }
+               return $n;
        }
-       return $n;
-}
 
-/**
- * Determine if an IP address really is an IP address, and if it is public,
- * i.e. not RFC 1918 or similar
- */
-function wfIsIPPublic( $ip ) {
-       $n = wfIP2Unsigned( $ip );
-       if ( !$n ) {
-               return false;
-       }
+       /**
       * Determine if an IP address really is an IP address, and if it is public,
       * i.e. not RFC 1918 or similar
       */
+       function isIPPublic( $ip ) {
+               $n = ProxyTools::IP2Unsigned( $ip );
+               if ( !$n ) {
+                       return false;
+               }
        
-       // ip2long accepts incomplete addresses, as well as some addresses
-       // followed by garbage characters. Check that it's really valid.
-       if( $ip != long2ip( $n ) ) {
-               return false;
-       }
-
-       static $privateRanges = false;
-       if ( !$privateRanges ) {
-               $privateRanges = array(
-                       array( '10.0.0.0',    '10.255.255.255' ),   # RFC 1918 (private)
-                       array( '172.16.0.0',  '172.31.255.255' ),   #     "
-                       array( '192.168.0.0', '192.168.255.255' ),  #     "
-                       array( '0.0.0.0',     '0.255.255.255' ),    # this network
-                       array( '127.0.0.0',   '127.255.255.255' ),  # loopback
-               );
-       }
-
-       foreach ( $privateRanges as $r ) {
-               $start = wfIP2Unsigned( $r[0] );
-               $end = wfIP2Unsigned( $r[1] );
-               if ( $n >= $start && $n <= $end ) {
+               // ip2long accepts incomplete addresses, as well as some addresses
+               // followed by garbage characters. Check that it's really valid.
+               if( $ip != long2ip( $n ) ) {
                        return false;
                }
-       }
-       return true;
-}
 
-/**
- * Forks processes to scan the originating IP for an open proxy server
- * MemCached can be used to skip IPs that have already been scanned
- */
-function wfProxyCheck() {
-       global $wgBlockOpenProxies, $wgProxyPorts, $wgProxyScriptPath;
-       global $wgUseMemCached, $wgMemc, $wgDBname, $wgProxyMemcExpiry;
-       global $wgProxyKey;
+               static $privateRanges = false;
+               if ( !$privateRanges ) {
+                       $privateRanges = array(
+                               array( '10.0.0.0',    '10.255.255.255' ),   # RFC 1918 (private)
+                               array( '172.16.0.0',  '172.31.255.255' ),   #     "
+                               array( '192.168.0.0', '192.168.255.255' ),  #     "
+                               array( '0.0.0.0',     '0.255.255.255' ),    # this network
+                               array( '127.0.0.0',   '127.255.255.255' ),  # loopback
+                       );
+               }
 
-       if ( !$wgBlockOpenProxies ) {
-               return;
+               foreach ( $privateRanges as $r ) {
+                       $start = ProxyTools::IP2Unsigned( $r[0] );
+                       $end = ProxyTools::IP2Unsigned( $r[1] );
+                       if ( $n >= $start && $n <= $end ) {
+                               return false;
+                       }
+               }
+               return true;
        }
 
-       $ip = wfGetIP();
+       /**
+        * Forks processes to scan the originating IP for an open proxy server
+        * MemCached can be used to skip IPs that have already been scanned
+        */
+       function proxyCheck() {
+               global $wgBlockOpenProxies, $wgProxyPorts, $wgProxyScriptPath;
+               global $wgUseMemCached, $wgMemc, $wgDBname, $wgProxyMemcExpiry;
+               global $wgProxyKey;
 
-       # Get MemCached key
-       $skip = false;
-       if ( $wgUseMemCached ) {
-               $mcKey = "$wgDBname:proxy:ip:$ip";
-               $mcValue = $wgMemc->get( $mcKey );
-               if ( $mcValue ) {
-                       $skip = true;
+               if ( !$wgBlockOpenProxies ) {
+                       return;
                }
-       }
 
-       # Fork the processes
-       if ( !$skip ) {
-               $title = Title::makeTitle( NS_SPECIAL, 'Blockme' );
-               $iphash = md5( $ip . $wgProxyKey );
-               $url = $title->getFullURL( 'ip='.$iphash );
-
-               foreach ( $wgProxyPorts as $port ) {
-                       $params = implode( ' ', array(
-                                               escapeshellarg( $wgProxyScriptPath ),
-                                               escapeshellarg( $ip ),
-                                               escapeshellarg( $port ),
-                                               escapeshellarg( $url )
-                                               ));
-                       exec( "php $params &>/dev/null &" );
-               }
-               # Set MemCached key
+               $ip = ProxyTools::getIP();
+
+               # Get MemCached key
+               $skip = false;
                if ( $wgUseMemCached ) {
-                       $wgMemc->set( $mcKey, 1, $wgProxyMemcExpiry );
+                       $mcKey = "$wgDBname:proxy:ip:$ip";
+                       $mcValue = $wgMemc->get( $mcKey );
+                       if ( $mcValue ) {
+                               $skip = true;
+                       }
                }
-       }
-}
 
-/**
- * Convert a network specification in CIDR notation to an integer network and a number of bits
- */
-function wfParseCIDR( $range ) {
-       $parts = explode( '/', $range, 2 );
-       if ( count( $parts ) != 2 ) {
-               return array( false, false );
+               # Fork the processes
+               if ( !$skip ) {
+                       $title = Title::makeTitle( NS_SPECIAL, 'Blockme' );
+                       $iphash = md5( $ip . $wgProxyKey );
+                       $url = $title->getFullURL( 'ip='.$iphash );
+
+                       foreach ( $wgProxyPorts as $port ) {
+                               $params = implode( ' ', array(
+                                                       escapeshellarg( $wgProxyScriptPath ),
+                                                       escapeshellarg( $ip ),
+                                                       escapeshellarg( $port ),
+                                                       escapeshellarg( $url )
+                                                       ));
+                               exec( "php $params &>/dev/null &" );
+                       }
+                       # Set MemCached key
+                       if ( $wgUseMemCached ) {
+                               $wgMemc->set( $mcKey, 1, $wgProxyMemcExpiry );
+                       }
+               }
        }
-       $network = wfIP2Unsigned( $parts[0] );
-       if ( $network !== false && is_numeric( $parts[1] ) && $parts[1] >= 0 && $parts[1] <= 32 ) {
-               $bits = $parts[1];
-       } else {
-               $network = false;
-               $bits = false;
+
+       /**
+        * Convert a network specification in CIDR notation to an integer network and a number of bits
+        */
+       function parseCIDR( $range ) {
+               $parts = explode( '/', $range, 2 );
+               if ( count( $parts ) != 2 ) {
+                       return array( false, false );
+               }
+               $network = ProxyTools::IP2Unsigned( $parts[0] );
+               if ( $network !== false && is_numeric( $parts[1] ) && $parts[1] >= 0 && $parts[1] <= 32 ) {
+                       $bits = $parts[1];
+               } else {
+                       $network = false;
+                       $bits = false;
+               }
+               return array( $network, $bits );
        }
-       return array( $network, $bits );
-}
 
-/**
- * Check if an IP address is in the local proxy list
- */
-function wfIsLocallyBlockedProxy( $ip ) {
-       global $wgProxyList;
-       $fname = 'wfIsLocallyBlockedProxy';
+       /**
       * Check if an IP address is in the local proxy list
       */
+       function isLocallyBlockedProxy( $ip ) {
+               global $wgProxyList;
+               $fname = 'ProxyTools::isLocallyBlockedProxy';
 
-       if ( !$wgProxyList ) {
-               return false;
-       }
-       wfProfileIn( $fname );
+               if ( !$wgProxyList ) {
+                       return false;
+               }
+               wfProfileIn( $fname );
 
-       if ( !is_array( $wgProxyList ) ) {
-               # Load from the specified file
-               $wgProxyList = array_map( 'trim', file( $wgProxyList ) );
-       }
+               if ( !is_array( $wgProxyList ) ) {
+                       # Load from the specified file
+                       $wgProxyList = array_map( 'trim', file( $wgProxyList ) );
+               }
 
-       if ( !is_array( $wgProxyList ) ) {
-               $ret = false;
-       } elseif ( array_search( $ip, $wgProxyList ) !== false ) {
-               $ret = true;
-       } elseif ( array_key_exists( $ip, $wgProxyList ) ) {
-               # Old-style flipped proxy list
-               $ret = true;
-       } else {
-               $ret = false;
+               if ( !is_array( $wgProxyList ) ) {
+                       $ret = false;
+               } elseif ( array_search( $ip, $wgProxyList ) !== false ) {
+                       $ret = true;
+               } elseif ( array_key_exists( $ip, $wgProxyList ) ) {
+                       # Old-style flipped proxy list
+                       $ret = true;
+               } else {
+                       $ret = false;
+               }
+               wfProfileOut( $fname );
+               return $ret;
        }
-       wfProfileOut( $fname );
-       return $ret;
 }
-
-
-
-
 ?>
index 7848c53..515e458 100644 (file)
@@ -4,11 +4,6 @@
  * @package MediaWiki
  */
 
-/**
- *
- */
-require_once 'Feed.php';
-
 /**
  * List of query page classes and their associated special pages, for periodic update purposes
  */
index 5685385..252ab32 100644 (file)
@@ -10,9 +10,6 @@
  * @package MediaWiki
  */
 
-/** */
-require_once( 'Revision.php' );
-
 /**
  * @todo document
  * @package MediaWiki
index cae6d76..d550513 100644 (file)
@@ -205,7 +205,7 @@ class RecentChange
                }
 
                if ( !$ip ) {
-                       $ip = wfGetIP();
+                       $ip = ProxyTools::getIP();
                        if ( !$ip ) {
                                $ip = '';
                        }
@@ -249,7 +249,7 @@ class RecentChange
          $ip='', $size = 0, $newId = 0 )
        {
                if ( !$ip ) {
-                       $ip = wfGetIP();
+                       $ip = ProxyTools::getIP();
                        if ( !$ip ) {
                                $ip = '';
                        }
@@ -294,7 +294,7 @@ class RecentChange
        /*static*/ function notifyMove( $timestamp, &$oldTitle, &$newTitle, &$user, $comment, $ip='', $overRedir = false )
        {
                if ( !$ip ) {
-                       $ip = wfGetIP();
+                       $ip = ProxyTools::getIP();
                        if ( !$ip ) {
                                $ip = '';
                        }
@@ -344,7 +344,7 @@ class RecentChange
           $type, $action, $target, $logComment, $params )
        {
                if ( !$ip ) {
-                       $ip = wfGetIP();
+                       $ip = ProxyTools::getIP();
                        if ( !$ip ) {
                                $ip = '';
                        }
index e9083a7..9aaa93c 100644 (file)
@@ -4,10 +4,6 @@
  * @todo document
  */
 
-/** */
-require_once( 'Database.php' );
-require_once( 'Article.php' );
-
 /** @+ */
 define( 'MW_REV_DELETED_TEXT',       1 );
 define( 'MW_REV_DELETED_COMMENT',    2 );
@@ -514,7 +510,6 @@ class Revision {
                                wfProfileOut( $fname );
                                return false;
                        }
-                       require_once('ExternalStore.php');
                        $text=ExternalStore::fetchFromURL($url);
                }
 
@@ -604,7 +599,6 @@ class Revision {
                        } else {
                                $store = $wgDefaultExternalStore;
                        }
-                       require_once('ExternalStore.php');
                        // Store and get the URL
                        $data = ExternalStore::insert( $store, $data );
                        if ( !$data ) {
index 2ef7045..0175210 100644 (file)
@@ -195,10 +195,8 @@ class SearchEngine {
                        $class = $wgSearchType;
                } elseif( $wgDBtype == 'mysql' ) {
                        $class = 'SearchMySQL4';
-                       require_once( 'SearchMySQL4.php' );
                } else if ( $wgDBtype == 'PostgreSQL' ) {
                        $class = 'SearchTsearch2';
-                       require_once( 'SearchTsearch2.php' );
                } else {
                        $class = 'SearchEngineDummy';
                }
index 6683cbe..80bddbd 100644 (file)
@@ -24,9 +24,6 @@
  * @subpackage Search
  */
 
-/** */
-require_once( 'SearchEngine.php' );
-
 /** @package MediaWiki */
 class SearchMySQL extends SearchEngine {
        /**
index 59f1bbe..dcc1f68 100644 (file)
@@ -23,8 +23,6 @@
  * @subpackage Search
  */
 
-require_once( 'SearchMySQL.php' );
-
 /**
  * @package MediaWiki
  * @subpackage Search
index 3c0f132..767979c 100644 (file)
@@ -23,9 +23,6 @@
  * @subpackage Search
  */
 
-/** */
-require_once( 'SearchEngine.php' );
-
 /**
  * @todo document
  * @package MediaWiki
index 1f222b3..37981a6 100644 (file)
@@ -37,7 +37,6 @@ class SearchUpdate {
                $fname = 'SearchUpdate::doUpdate';
                wfProfileIn( $fname );
 
-               require_once( 'SearchEngine.php' );
                $search = SearchEngine::create();
                $lc = $search->legalSearchChars() . '&#;';
 
index 4c4328d..dedf6a4 100644 (file)
@@ -22,13 +22,14 @@ if ( !isset( $wgVersion ) ) {
        die( -1 );
 }
 
+require('AutoLoader.php');
+
 if( !isset( $wgProfiling ) )
        $wgProfiling = false;
 
 if ( function_exists( 'wfProfileIn' ) ) {
        /* nada, everything should be done already */
 } elseif ( $wgProfiling and (0 == rand() % $wgProfileSampleRate ) ) {
-       require_once( 'Profiling.php' );
        $wgProfiling = true;
        if ($wgProfilerType == "") {
                $wgProfiler = new Profiler();
@@ -48,29 +49,8 @@ wfProfileIn( $fname.'-includes' );
 require_once( 'GlobalFunctions.php' );
 require_once( 'Hooks.php' );
 require_once( 'Namespace.php' );
-require_once( 'User.php' );
-require_once( 'Skin.php' );
-require_once( 'OutputPage.php' );
-require_once( 'LinkCache.php' );
-require_once( 'LinkBatch.php' );
-require_once( 'Title.php' );
-require_once( 'Article.php' );
 require_once( 'MagicWord.php' );
-require_once( 'Block.php' );
-require_once( 'MessageCache.php' );
-require_once( 'Parser.php' );
-require_once( 'ParserCache.php' );
-require_once( 'WebRequest.php' );
-require_once( 'LoadBalancer.php' );
-require_once( 'HistoryBlob.php' );
-require_once( 'ProxyTools.php' );
-require_once( 'ObjectCache.php' );
-require_once( 'WikiError.php' );
-require_once( 'SpecialPage.php' );
-
-if ( $wgUseDynamicDates ) {
-       require_once( 'DateFormatter.php' );
-}
+
 
 wfProfileOut( $fname.'-includes' );
 wfProfileIn( $fname.'-misc1' );
@@ -108,9 +88,9 @@ $wgUseEnotif = $wgEnotifUserTalk || $wgEnotifWatchlist;
 wfProfileOut( $fname.'-misc1' );
 wfProfileIn( $fname.'-memcached' );
 
-$wgMemc =& wfGetMainCache();
-$messageMemc =& wfGetMessageCacheStorage();
-$parserMemc =& wfGetParserCacheStorage();
+$wgMemc =& ObjectCacheManager::getMainCache();
+$messageMemc =& ObjectCacheManager::getMessageCache();
+$parserMemc =& ObjectCacheManager::getParserCache();
 
 wfDebug( 'Main cache: ' . get_class( $wgMemc ) .
        "\nMessage cache: " . get_class( $messageMemc ) .
@@ -208,7 +188,6 @@ foreach ( $wgSkinExtensionFunctions as $func ) {
 }
 
 if( !is_object( $wgAuth ) ) {
-       require_once( 'AuthPlugin.php' );
        $wgAuth = new AuthPlugin();
 }
 
@@ -296,7 +275,6 @@ $wgMagicWords = array();
 $wgMwRedir =& MagicWord::get( MAG_REDIRECT );
 
 if ( $wgUseXMLparser ) {
-       require_once( 'ParserXML.php' );
        $wgParser = new ParserXML();
 } else {
        $wgParser = new Parser();
index 5bf36ab..dc0a998 100644 (file)
@@ -8,28 +8,11 @@ if ( ! defined( 'MEDIAWIKI' ) )
  * @subpackage Skins
  */
 
-# See skin.txt
-require_once( 'Linker.php' );
-require_once( 'Image.php' );
-
 # Get a list of available skins
 # Build using the regular expression '^(.*).php$'
 # Array keys are all lower case, array value keep the case used by filename
 #
 
-$skinDir = dir( $wgStyleDirectory );
-
-# while code from www.php.net
-while (false !== ($file = $skinDir->read())) {
-       // Skip non-PHP files, hidden files, and '.dep' includes
-       if(preg_match('/^([^.]*)\.php$/',$file, $matches)) {
-               $aSkin = $matches[1];
-               $wgValidSkinNames[strtolower($aSkin)] = $aSkin;
-       }
-}
-$skinDir->close();
-unset($matches);
-
 /**
  * The main skin class that provide methods and properties for all other skins.
  * This base class is also the "Standard" skin.
@@ -55,9 +38,35 @@ class Skin extends Linker {
         */
        function getSkinNames() {
                global $wgValidSkinNames;
+               if (!is_array($wgValidSkinNames)) {
+                       Skin::initializeSkinNames();
+               }
                return $wgValidSkinNames;
        }
 
+       /** 
+        * Initializes set of available skins.
+        * @return array of strings - skin names
+        * @static
+        */
+       
+       function initializeSkinNames() {
+               global $wgStyleDirectory, $wgValidSkinNames;
+               $skinDir = dir( $wgStyleDirectory );
+
+               # while code from www.php.net
+               while (false !== ($file = $skinDir->read())) {
+                       // Skip non-PHP files, hidden files, and '.dep' includes
+                       if(preg_match('/^([^.]*)\.php$/',$file, $matches)) {
+                               $aSkin = $matches[1];
+                               $wgValidSkinNames[strtolower($aSkin)] = $aSkin;
+                       }
+               }
+               $skinDir->close();
+               unset($matches);
+               
+       }
+
        /**
         * Normalize a skin preference value to a form that can be loaded.
         * If a skin can't be found, it will fall back to the configured
@@ -745,7 +754,7 @@ END;
                $s = '';
                if ( $wgUser->isAnon() ) {
                        if( $wgShowIPinHeader && isset( $_COOKIE[ini_get('session.name')] ) ) {
-                               $n = wfGetIP();
+                               $n = ProxyTools::getIP();
 
                                $tl = $this->makeKnownLinkObj( $wgUser->getTalkPage(),
                                  $wgLang->getNsText( NS_TALK ) );
@@ -896,8 +905,7 @@ END;
                }
 
                if (isset($wgMaxCredits) && $wgMaxCredits != 0) {
-                   require_once('Credits.php');
-                   $s .= ' ' . getCredits($wgArticle, $wgMaxCredits, $wgShowCreditsIfMax);
+                   $s .= ' ' . Credits::getCredits($wgArticle, $wgMaxCredits, $wgShowCreditsIfMax);
                } else {
                    $s .= $this->lastModified();
                }
@@ -1015,7 +1023,6 @@ END;
         */
        function specialPagesList() {
                global $wgUser, $wgContLang, $wgServer, $wgRedirectScript, $wgAvailableRights;
-               require_once('SpecialPage.php');
                $a = array();
                $pages = SpecialPage::getPages();
 
index f054153..c86b67e 100644 (file)
@@ -343,8 +343,7 @@ class SkinTemplate extends Skin {
                        $this->credits = false;
 
                        if (isset($wgMaxCredits) && $wgMaxCredits != 0) {
-                               require_once("Credits.php");
-                               $this->credits = getCredits($wgArticle, $wgMaxCredits, $wgShowCreditsIfMax);
+                               $this->credits = Credits::getCredits($wgArticle, $wgMaxCredits, $wgShowCreditsIfMax);
                        } else {
                                $tpl->set('lastmod', $this->lastModified());
                        }
index b452b14..c3524e4 100644 (file)
@@ -12,7 +12,7 @@ function wfSpecialBlockme()
 {
        global $wgBlockOpenProxies, $wgOut, $wgProxyKey;
 
-       $ip = wfGetIP();
+       $ip = ProxyTools::getIP();
 
        if ( !$wgBlockOpenProxies || $_REQUEST['ip'] != md5( $ip . $wgProxyKey ) ) {
                $wgOut->addWikiText( wfMsg( "disabled" ) );
index 7c54654..bd2829d 100644 (file)
  * @subpackage SpecialPage
  */
 
+/**
+ * @todo put all global specialpages stuff into class
+ */
+global $wgSpecialPages, $wgDisableCounters, $wgDisableInternalSearch, $wgEmailAuthentication;
 
 /**
  * @access private
index bccbc6e..69a6813 100644 (file)
@@ -444,7 +444,7 @@ class PreferencesForm {
         * @access private
         */
        function mainPrefsForm( $status , $message = '' ) {
-               global $wgUser, $wgOut, $wgLang, $wgContLang, $wgValidSkinNames;
+               global $wgUser, $wgOut, $wgLang, $wgContLang;
                global $wgAllowRealName, $wgImageLimits, $wgThumbLimits;
                global $wgDisableLangConversion;
                global $wgEnotifWatchlist, $wgEnotifUserTalk,$wgEnotifMinorEdits;
@@ -723,7 +723,7 @@ class PreferencesForm {
                $previewtext = wfMsg('skinpreview');
                # Only show members of $wgValidSkinNames rather than
                # $skinNames (skins is all skin names from Language.php)
-               foreach ($wgValidSkinNames as $skinkey => $skinname ) {
+               foreach (Skin::getSkinNames() as $skinkey => $skinname ) {
                        if ( in_array( $skinkey, $wgSkipSkins ) ) {
                                continue;
                        }
index 74c6ebf..48470a7 100644 (file)
@@ -5,13 +5,6 @@
  * @subpackage SpecialPage
  */
 
-/**
- *
- */
-require_once( 'Feed.php' );
-require_once( 'ChangesList.php' );
-require_once( 'Revision.php' );
-
 /**
  * Constructor
  */
index 84b732f..e61f485 100644 (file)
@@ -9,8 +9,6 @@
  *
  */
 require_once 'Image.php';
-require_once 'MacBinary.php';
-require_once 'Licenses.php';
 /**
  * Entry point
  */
index 03a4185..2d38388 100644 (file)
@@ -210,7 +210,7 @@ class LoginForm {
                        return false;
                }
 
-               $ip = wfGetIP();
+               $ip = ProxyTools::getIP();
                if ( $wgEnableSorbs && !in_array( $ip, $wgProxyWhitelist ) &&
                  $wgUser->inSorbsBlacklist( $ip ) )
                {
@@ -416,7 +416,7 @@ class LoginForm {
 
                $u->saveSettings();
 
-               $ip = wfGetIP();
+               $ip = ProxyTools::getIP();
                if ( '' == $ip ) { $ip = '(Unknown)'; }
 
                $m = wfMsg( 'passwordremindertext', $ip, $u->getName(), $np, $wgServer . $wgScript );
index 5f7e857..c941e2b 100644 (file)
@@ -190,7 +190,7 @@ class SpecialVersion {
         * @return string
         */
        function IPInfo() {
-               $ip =  str_replace( '--', ' - ', htmlspecialchars( wfGetIP() ) );
+               $ip =  str_replace( '--', ' - ', htmlspecialchars( ProxyTools::getIP() ) );
                return "<!-- visited from $ip -->\n" .
                        "<span style='display:none'>visited from $ip</span>";
        }
index 1e87fd8..f86bf3e 100644 (file)
@@ -5,9 +5,6 @@
  * @package MediaWiki
  */
 
-/** */
-require_once( 'normal/UtfNormal.php' );
-
 $wgTitleInterwikiCache = array();
 $wgTitleCache = array();
 
@@ -334,7 +331,6 @@ class Title {
         */
        /* static */ function indexTitle( $ns, $title ) {
                global $wgContLang;
-               require_once( 'SearchEngine.php' );
 
                $lc = SearchEngine::legalSearchChars() . '&#;';
                $t = $wgContLang->stripForSearch( $title );
@@ -1162,8 +1158,7 @@ class Title {
         * Check that the corresponding skin exists
         */
        function isValidCssJsSubpage() {
-               global $wgValidSkinNames;
-               return( $this->isCssJsSubpage() && array_key_exists( $this->getSkinFromCssJsSubpage(), $wgValidSkinNames ) );
+               return( $this->isCssJsSubpage() && array_key_exists( $this->getSkinFromCssJsSubpage(), Skin::getSkinNames() ) );
        }
        /**
         * Trim down a .css or .js subpage title to get the corresponding skin name
index e6da731..d3c2b03 100644 (file)
@@ -5,13 +5,4 @@
  * @package MediaWiki
  */
 
-/**
- *
- */
-
-require_once( 'SiteStatsUpdate.php' );
-require_once( 'LinksUpdate.php' );
-require_once( 'SearchUpdate.php' );
-require_once( 'SquidUpdate.php' );
-
 ?>
\ No newline at end of file
index 15d469a..a9ab118 100644 (file)
@@ -5,11 +5,6 @@
  * @package MediaWiki
  */
 
-/**
- *
- */
-require_once( 'WatchedItem.php' );
-
 # Number of characters in user_token field
 define( 'USER_TOKEN_LENGTH', 32 );
 
@@ -433,7 +428,7 @@ class User {
                wfDebug( "$fname: checking...\n" );
 
                $this->mBlockedby = 0;
-               $ip = wfGetIP();
+               $ip = ProxyTools::getIP();
 
                # User/IP blocking
                $block = new Block();
@@ -454,7 +449,7 @@ class User {
                if ( !$this->isAllowed('proxyunbannable') && !in_array( $ip, $wgProxyWhitelist ) ) {
 
                        # Local list
-                       if ( wfIsLocallyBlockedProxy( $ip ) ) {
+                       if ( ProxyTools::isLocallyBlockedProxy( $ip ) ) {
                                $this->mBlockedby = wfMsg( 'proxyblocker' );
                                $this->mBlockreason = wfMsg( 'proxyblockreason' );
                        }
@@ -538,7 +533,7 @@ class User {
                $limits = $wgRateLimits[$action];
                $keys = array();
                $id = $this->getId();
-               $ip = wfGetIP();
+               $ip = ProxyTools::getIP();
 
                if( isset( $limits['anon'] ) && $id == 0 ) {
                        $keys["$wgDBname:limiter:$action:anon"] = $limits['anon'];
@@ -790,7 +785,7 @@ class User {
        function getName() {
                $this->loadFromDatabase();
                if ( $this->mName === false ) {
-                       $this->mName = wfGetIP();
+                       $this->mName = ProxyTools::getIP();
                }
                return $this->mName;
        }
@@ -1526,7 +1521,7 @@ class User {
                }
 
                # Check if this IP address is already blocked
-               $ipblock = Block::newFromDB( wfGetIP() );
+               $ipblock = Block::newFromDB( ProxyTools::getIP() );
                if ( $ipblock->isValid() ) {
                        # If the user is already blocked. Then check if the autoblock would
                        # excede the user block. If it would excede, then do nothing, else
@@ -1541,8 +1536,8 @@ class User {
                }
 
                # Make a new block object with the desired properties
-               wfDebug( "Autoblocking {$this->mName}@" . wfGetIP() . "\n" );
-               $ipblock->mAddress = wfGetIP();
+               wfDebug( "Autoblocking {$this->mName}@" . ProxyTools::getIP() . "\n" );
+               $ipblock->mAddress = ProxyTools::getIP();
                $ipblock->mUser = 0;
                $ipblock->mBy = $userblock->mBy;
                $ipblock->mReason = wfMsg( 'autoblocker', $this->getName(), $userblock->mReason );
@@ -1762,7 +1757,7 @@ class User {
                $url = $this->confirmationTokenUrl( $expiration );
                return $this->sendMail( wfMsg( 'confirmemail_subject' ),
                        wfMsg( 'confirmemail_body',
-                               wfGetIP(),
+                               ProxyTools::getIP(),
                                $this->getName(),
                                $url,
                                $wgContLang->timeanddate( $expiration, false ) ) );
index 736e215..efae012 100644 (file)
@@ -117,7 +117,6 @@ class WebRequest {
                                        $data = $wgContLang->checkTitleEncoding( $data );
                                }
                        }
-                       require_once( 'normal/UtfNormal.php' );
                        $data = $this->normalizeUnicode( $data );
                        return $data;
                } else {
index 187dc06..a134552 100644 (file)
@@ -176,10 +176,8 @@ class MediaWiki {
        
                switch( $title->getNamespace() ) {
                case NS_IMAGE:
-                       require_once( 'includes/ImagePage.php' );
                        return new ImagePage( $title );
                case NS_CATEGORY:
-                       require_once( 'includes/CategoryPage.php' );
                        return new CategoryPage( $title );
                default:
                        return new Article( $title );
@@ -284,8 +282,6 @@ class MediaWiki {
                        $n = intval( $wgJobRunRate );
                }
 
-               require_once( 'JobQueue.php' );
-
                while ( $n-- && false != ($job = Job::pop())) {
                        $output = $job->toString() . "\n";
                        if ( !$job->run() ) {
@@ -359,8 +355,7 @@ class MediaWiki {
                                }
                                break;
                        case 'credits':
-                               require_once( 'includes/Credits.php' );
-                               showCreditsPage( $article );
+                               Credits::showCreditsPage( $article );
                                break;
                        case 'submit':
                                if( !$this->getVal( 'CommandLineMode' ) && !$request->checkSessionCookie() ) {
@@ -375,11 +370,9 @@ class MediaWiki {
                                $oldid = $request->getVal( 'oldid' );
                                if( !$this->getVal( 'UseExternalEditor' ) || $action=='submit' || $internal ||
                                   $section || $oldid || ( !$user->getOption( 'externaleditor' ) && !$external ) ) {
-                                       require_once( 'includes/EditPage.php' );
                                        $editor = new EditPage( $article );
                                        $editor->submit();
                                } elseif( $this->getVal( 'UseExternalEditor' ) && ( $external || $user->getOption( 'externaleditor' ) ) ) {
-                                       require_once( 'includes/ExternalEdit.php' );
                                        $mode = $request->getVal( 'mode' );
                                        $extedit = new ExternalEdit( $article, $mode );
                                        $extedit->edit();
@@ -389,12 +382,10 @@ class MediaWiki {
                                if( $_SERVER['REQUEST_URI'] == $title->getInternalURL( 'action=history' ) ) {
                                        $output->setSquidMaxage( $this->getVal( 'SquidMaxage' ) );
                                }
-                               require_once( 'includes/PageHistory.php' );
                                $history = new PageHistory( $article );
                                $history->history();
                                break;
                        case 'raw':
-                               require_once( 'includes/RawPage.php' );
                                $raw = new RawPage( $article );
                                $raw->view();
                                break;