From: Tim Starling Date: Tue, 3 Oct 2006 13:00:52 +0000 (+0000) Subject: * Removed lots of explicit require_once statements. The autoloader should theoretical... X-Git-Tag: 1.31.0-rc.0~55648 X-Git-Url: https://git.cyclocoop.org/%28%28?a=commitdiff_plain;h=3005679b0e6dbf5238060cbe543eea4695e4a00c;p=lhc%2Fweb%2Fwiklou.git * Removed lots of explicit require_once statements. The autoloader should theoretically be faster, because it always uses an absolute path, eliminating the need for a search, and it is never called unnecessarily. Absolute paths are also more robust in the face of odd configurations or usage patterns. Moved a few constants around to support this, they always have to be available before the method call. * Deleted DatabaseMysql.php, no longer necessary, database classes are autoloaded. * Moved wfGetMimeMagic() to MimeMagic::singleton() * Fixed a couple of __CLASS__.'::'.__FUNCTION__ things. --- diff --git a/includes/AjaxDispatcher.php b/includes/AjaxDispatcher.php index ce10eecd85..618c2736c8 100644 --- a/includes/AjaxDispatcher.php +++ b/includes/AjaxDispatcher.php @@ -8,7 +8,6 @@ if ( ! $wgUseAjax ) { } require_once( 'AjaxFunctions.php' ); -require_once( 'AjaxResponse.php' ); class AjaxDispatcher { var $mode; diff --git a/includes/AjaxFunctions.php b/includes/AjaxFunctions.php index 383dae462b..9f7a332f4b 100644 --- a/includes/AjaxFunctions.php +++ b/includes/AjaxFunctions.php @@ -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). diff --git a/includes/Article.php b/includes/Article.php index f32e15e73c..4764d469dc 100644 --- a/includes/Article.php +++ b/includes/Article.php @@ -4,11 +4,6 @@ * @package MediaWiki */ -/** - * Need the CacheManager to be loaded - */ -require_once( 'CacheManager.php' ); - /** * Class representing a MediaWiki article and history. * @@ -651,7 +646,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 ); @@ -1530,7 +1524,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 index 63ac24b2e7..b1549f66ec 100644 --- a/includes/AutoLoader.php +++ b/includes/AutoLoader.php @@ -19,6 +19,7 @@ function __autoload($className) { 'TurckBagOStuff' => 'includes/BagOStuff.php', 'APCBagOStuff' => 'includes/BagOStuff.php', 'eAccelBagOStuff' => 'includes/BagOStuff.php', + 'DBABagOStuff' => 'includes/BagOStuff.php', 'Block' => 'includes/Block.php', 'CacheManager' => 'includes/CacheManager.php', 'CategoryPage' => 'includes/CategoryPage.php', diff --git a/includes/Database.php b/includes/Database.php index ca306631a5..7ef2274897 100644 --- a/includes/Database.php +++ b/includes/Database.php @@ -5,13 +5,6 @@ * @package MediaWiki */ -/** See Database::makeList() */ -define( 'LIST_COMMA', 0 ); -define( 'LIST_AND', 1 ); -define( 'LIST_SET', 2 ); -define( 'LIST_NAMES', 3); -define( 'LIST_OR', 4); - /** Number of times to re-try an operation in case of deadlock */ define( 'DEADLOCK_TRIES', 4 ); /** Minimum time to wait before retry, in microseconds */ diff --git a/includes/DatabaseMysql.php b/includes/DatabaseMysql.php deleted file mode 100644 index 79e917b3d2..0000000000 --- a/includes/DatabaseMysql.php +++ /dev/null @@ -1,6 +0,0 @@ - diff --git a/includes/DatabaseOracle.php b/includes/DatabaseOracle.php index d5d7379dc6..aa1e329ed0 100644 --- a/includes/DatabaseOracle.php +++ b/includes/DatabaseOracle.php @@ -6,11 +6,6 @@ * @package MediaWiki */ -/** - * Depends on database - */ -require_once( 'Database.php' ); - class OracleBlob extends DBObject { function isLOB() { return true; diff --git a/includes/DatabasePostgres.php b/includes/DatabasePostgres.php index 722b635939..a5e02e77f2 100644 --- a/includes/DatabasePostgres.php +++ b/includes/DatabasePostgres.php @@ -10,11 +10,6 @@ * @package MediaWiki */ -/** - * Depends on database - */ -require_once( 'Database.php' ); - class DatabasePostgres extends Database { var $mInsertId = NULL; var $mLastResult = NULL; diff --git a/includes/Defines.php b/includes/Defines.php index b8acadb03e..407274857b 100644 --- a/includes/Defines.php +++ b/includes/Defines.php @@ -195,4 +195,15 @@ define( 'EDIT_FORCE_BOT', 16 ); define( 'EDIT_DEFER_UPDATES', 32 ); /**#@-*/ +/** + * Flags for Database::makeList() + * These are also available as Database class constants + */ +define( 'LIST_COMMA', 0 ); +define( 'LIST_AND', 1 ); +define( 'LIST_SET', 2 ); +define( 'LIST_NAMES', 3); +define( 'LIST_OR', 4); + + ?> diff --git a/includes/DifferenceEngine.php b/includes/DifferenceEngine.php index 6dc82d6b1f..21ac558b3c 100644 --- a/includes/DifferenceEngine.php +++ b/includes/DifferenceEngine.php @@ -5,10 +5,6 @@ * @subpackage DifferenceEngine */ -/** */ -define( 'MAX_DIFF_LINE', 10000 ); -define( 'MAX_DIFF_XREF_LENGTH', 10000 ); - /** * @todo document * @public @@ -724,6 +720,8 @@ class _DiffOp_Change extends _DiffOp { */ class _DiffEngine { + const MAX_XREF_LENGTH = 10000; + function diff ($from_lines, $to_lines) { $fname = '_DiffEngine::diff'; wfProfileIn( $fname ); @@ -821,7 +819,7 @@ class _DiffEngine * Returns the whole line if it's small enough, or the MD5 hash otherwise */ function _line_hash( $line ) { - if ( strlen( $line ) > MAX_DIFF_XREF_LENGTH ) { + if ( strlen( $line ) > self::MAX_XREF_LENGTH ) { return md5( $line ); } else { return $line; @@ -1576,6 +1574,8 @@ class _HWLDF_WordAccumulator { */ class WordLevelDiff extends MappedDiff { + const MAX_LINE_LENGTH = 10000; + function WordLevelDiff ($orig_lines, $closing_lines) { $fname = 'WordLevelDiff::WordLevelDiff'; wfProfileIn( $fname ); @@ -1604,7 +1604,7 @@ class WordLevelDiff extends MappedDiff $words[] = "\n"; $stripped[] = "\n"; } - if ( strlen( $line ) > MAX_DIFF_LINE ) { + if ( strlen( $line ) > self::MAX_LINE_LENGTH ) { $words[] = $line; $stripped[] = $line; } else { diff --git a/includes/EditPage.php b/includes/EditPage.php index 16c36bf48e..a1207d1038 100644 --- a/includes/EditPage.php +++ b/includes/EditPage.php @@ -1199,7 +1199,6 @@ END $wgOut->addHtml( wfHidden( 'wpAutoSummary', $autosumm ) ); if ( $this->isConflict ) { - require_once( "DifferenceEngine.php" ); $wgOut->addWikiText( '==' . wfMsg( "yourdiff" ) . '==' ); $de = new DifferenceEngine( $this->mTitle ); @@ -1721,7 +1720,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 ); diff --git a/includes/Export.php b/includes/Export.php index 19a6172f13..aa70e27bef 100644 --- a/includes/Export.php +++ b/includes/Export.php @@ -16,50 +16,43 @@ # with this program; if not, write to the Free Software Foundation, Inc., # 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. # http://www.gnu.org/copyleft/gpl.html + /** * * @package MediaWiki * @subpackage SpecialPage */ -/** */ - -define( 'MW_EXPORT_FULL', 0 ); -define( 'MW_EXPORT_CURRENT', 1 ); - -define( 'MW_EXPORT_BUFFER', 0 ); -define( 'MW_EXPORT_STREAM', 1 ); - -define( 'MW_EXPORT_TEXT', 0 ); -define( 'MW_EXPORT_STUB', 1 ); - - -/** - * @package MediaWiki - * @subpackage SpecialPage - */ class WikiExporter { - var $list_authors = false ; # Return distinct author list (when not returning full history) var $author_list = "" ; + const FULL = 0; + const CURRENT = 1; + + const BUFFER = 0; + const STREAM = 1; + + const TEXT = 0; + const STUB = 1; + /** - * If using MW_EXPORT_STREAM to stream a large amount of data, + * If using WikiExporter::STREAM to stream a large amount of data, * provide a database connection which is not managed by * LoadBalancer to read from: some history blob types will * make additional queries to pull source data while the * main query is still running. * * @param Database $db - * @param mixed $history one of MW_EXPORT_FULL or MW_EXPORT_CURRENT, or an + * @param mixed $history one of WikiExporter::FULL or WikiExporter::CURRENT, or an * associative array: * offset: non-inclusive offset at which to start the query * limit: maximum number of rows to return * dir: "asc" or "desc" timestamp order - * @param int $buffer one of MW_EXPORT_BUFFER or MW_EXPORT_STREAM + * @param int $buffer one of WikiExporter::BUFFER or WikiExporter::STREAM */ - function WikiExporter( &$db, $history = MW_EXPORT_CURRENT, - $buffer = MW_EXPORT_BUFFER, $text = MW_EXPORT_TEXT ) { + function WikiExporter( &$db, $history = WikiExporter::CURRENT, + $buffer = WikiExporter::BUFFER, $text = WikiExporter::TEXT ) { $this->db =& $db; $this->history = $history; $this->buffer = $buffer; @@ -175,9 +168,9 @@ class WikiExporter { $order = 'ORDER BY page_id'; $limit = ''; - if( $this->history == MW_EXPORT_FULL ) { + if( $this->history == WikiExporter::FULL ) { $join = 'page_id=rev_page'; - } elseif( $this->history == MW_EXPORT_CURRENT ) { + } elseif( $this->history == WikiExporter::CURRENT ) { if ( $this->list_authors && $cond != '' ) { // List authors, if so desired $this->do_list_authors ( $page , $revision , $cond ); } @@ -207,7 +200,7 @@ class WikiExporter { } $where = ( $cond == '' ) ? '' : "$cond AND"; - if( $this->buffer == MW_EXPORT_STREAM ) { + if( $this->buffer == WikiExporter::STREAM ) { $prev = $this->db->bufferResults( false ); } if( $cond == '' ) { @@ -219,7 +212,7 @@ class WikiExporter { $revindex = ''; $straight = ''; } - if( $this->text == MW_EXPORT_STUB ) { + if( $this->text == WikiExporter::STUB ) { $sql = "SELECT $straight * FROM $page $pageindex, $revision $revindex @@ -241,7 +234,7 @@ class WikiExporter { $this->outputStream( $wrapper ); } - if( $this->buffer == MW_EXPORT_STREAM ) { + if( $this->buffer == WikiExporter::STREAM ) { $this->db->bufferResults( $prev ); } diff --git a/includes/ExternalStoreDB.php b/includes/ExternalStoreDB.php index f610df8053..861a993962 100644 --- a/includes/ExternalStoreDB.php +++ b/includes/ExternalStoreDB.php @@ -6,7 +6,6 @@ * DB accessable external objects * */ -require_once( 'LoadBalancer.php' ); /** @package MediaWiki */ diff --git a/includes/FileStore.php b/includes/FileStore.php index c81504a7fa..69e4be8a1f 100644 --- a/includes/FileStore.php +++ b/includes/FileStore.php @@ -36,18 +36,16 @@ class FileStore { * @fixme Probably only works on MySQL. Abstract to the Database class? */ static function lock() { - $fname = __CLASS__ . '::' . __FUNCTION__; - $dbw = wfGetDB( DB_MASTER ); $lockname = $dbw->addQuotes( FileStore::lockName() ); - $result = $dbw->query( "SELECT GET_LOCK($lockname, 5) AS lockstatus", $fname ); + $result = $dbw->query( "SELECT GET_LOCK($lockname, 5) AS lockstatus", __METHOD__ ); $row = $dbw->fetchObject( $result ); $dbw->freeResult( $result ); if( $row->lockstatus == 1 ) { return true; } else { - wfDebug( "$fname failed to acquire lock\n" ); + wfDebug( __METHOD__." failed to acquire lock\n" ); return false; } } @@ -56,11 +54,9 @@ class FileStore { * Release the global file store lock. */ static function unlock() { - $fname = __CLASS__ . '::' . __FUNCTION__; - $dbw = wfGetDB( DB_MASTER ); $lockname = $dbw->addQuotes( FileStore::lockName() ); - $result = $dbw->query( "SELECT RELEASE_LOCK($lockname)", $fname ); + $result = $dbw->query( "SELECT RELEASE_LOCK($lockname)", __METHOD__ ); $row = $dbw->fetchObject( $result ); $dbw->freeResult( $result ); } @@ -103,8 +99,6 @@ class FileStore { } private function copyFile( $sourcePath, $destPath, $flags=0 ) { - $fname = __CLASS__ . '::' . __FUNCTION__; - if( !file_exists( $sourcePath ) ) { // Abort! Abort! throw new FSException( "missing source file '$sourcePath'\n" ); @@ -135,11 +129,11 @@ class FileStore { wfRestoreWarnings(); if( $ok ) { - wfDebug( "$fname copied '$sourcePath' to '$destPath'\n" ); + wfDebug( __METHOD__." copied '$sourcePath' to '$destPath'\n" ); $transaction->addRollback( FSTransaction::DELETE_FILE, $destPath ); } else { throw new FSException( - "$fname failed to copy '$sourcePath' to '$destPath'\n" ); + __METHOD__." failed to copy '$sourcePath' to '$destPath'\n" ); } } @@ -239,13 +233,11 @@ class FileStore { * @return string or false if could not open file or bad extension */ static function calculateKey( $path, $extension ) { - $fname = __CLASS__ . '::' . __FUNCTION__; - wfSuppressWarnings(); $hash = sha1_file( $path ); wfRestoreWarnings(); if( $hash === false ) { - wfDebug( "$fname: couldn't hash file '$path'\n" ); + wfDebug( __METHOD__.": couldn't hash file '$path'\n" ); return false; } @@ -260,7 +252,7 @@ class FileStore { if( self::validKey( $key ) ) { return $key; } else { - wfDebug( "$fname: generated bad key '$key'\n" ); + wfDebug( __METHOD__.": generated bad key '$key'\n" ); return false; } } @@ -353,7 +345,6 @@ class FSTransaction { } private function apply( $actions ) { - $fname = __CLASS__ . '::' . __FUNCTION__; $result = true; foreach( $actions as $item ) { list( $action, $path ) = $item; @@ -362,9 +353,9 @@ class FSTransaction { $ok = unlink( $path ); wfRestoreWarnings(); if( $ok ) - wfDebug( "$fname: deleting file '$path'\n" ); + wfDebug( __METHOD__.": deleting file '$path'\n" ); else - wfDebug( "$fname: failed to delete file '$path'\n" ); + wfDebug( __METHOD__.": failed to delete file '$path'\n" ); $result = $result && $ok; } } diff --git a/includes/GlobalFunctions.php b/includes/GlobalFunctions.php index c1a99069f5..fbd1f317e8 100644 --- a/includes/GlobalFunctions.php +++ b/includes/GlobalFunctions.php @@ -1462,37 +1462,14 @@ function wfGetSiteNotice() { return $siteNotice; } -/** Global singleton instance of MimeMagic. This is initialized on demand, -* please always use the wfGetMimeMagic() function to get the instance. -* -* @private -*/ -$wgMimeMagic= NULL; - -/** Factory functions for the global MimeMagic object. -* This function always returns the same singleton instance of MimeMagic. -* That objects will be instantiated on the first call to this function. -* If needed, the MimeMagic.php file is automatically included by this function. -* @return MimeMagic the global MimeMagic objects. -*/ +/** + * BC wrapper for MimeMagic::singleton() + * @deprecated + */ function &wfGetMimeMagic() { - global $wgMimeMagic; - - if (!is_null($wgMimeMagic)) { - return $wgMimeMagic; - } - - if (!class_exists("MimeMagic")) { - #include on demand - require_once("MimeMagic.php"); - } - - $wgMimeMagic= new MimeMagic(); - - return $wgMimeMagic; + return MimeMagic::singleton(); } - /** * Tries to get the system directory for temporary files. * The TMPDIR, TMP, and TEMP environment variables are checked in sequence, diff --git a/includes/HistoryBlob.php b/includes/HistoryBlob.php index 8f5d362485..357c1d48c6 100644 --- a/includes/HistoryBlob.php +++ b/includes/HistoryBlob.php @@ -231,7 +231,6 @@ class HistoryBlobStub { wfProfileOut( $fname ); return false; } - require_once('ExternalStore.php'); $row->old_text=ExternalStore::fetchFromUrl($url); } diff --git a/includes/Image.php b/includes/Image.php index 48dcc6b6ce..c66c6bbd85 100644 --- a/includes/Image.php +++ b/includes/Image.php @@ -260,7 +260,7 @@ class Image if ( $this->fileExists ) { - $magic=& wfGetMimeMagic(); + $magic=& MimeMagic::singleton(); $this->mime = $magic->guessMimeType($this->imagePath,true); $this->type = $magic->getMediaType($this->imagePath,$this->mime); @@ -268,7 +268,7 @@ class Image # Get size in bytes $this->size = filesize( $this->imagePath ); - $magic=& wfGetMimeMagic(); + $magic=& MimeMagic::singleton(); # Height and width wfSuppressWarnings(); @@ -2134,7 +2134,7 @@ class Image $tempFile = $store->filePath( $row->fa_storage_key ); $metadata = serialize( $this->retrieveExifData( $tempFile ) ); - $magic = wfGetMimeMagic(); + $magic = MimeMagic::singleton(); $mime = $magic->guessMimeType( $tempFile, true ); $media_type = $magic->getMediaType( $tempFile, $mime ); list( $major_mime, $minor_mime ) = self::splitMime( $mime ); diff --git a/includes/ImagePage.php b/includes/ImagePage.php index 5375244e18..908dd5cc52 100644 --- a/includes/ImagePage.php +++ b/includes/ImagePage.php @@ -9,8 +9,6 @@ if( !defined( 'MEDIAWIKI' ) ) die( 1 ); -require_once( 'Image.php' ); - /** * Special handling for image description pages * @package MediaWiki @@ -359,10 +357,7 @@ END $wgOut->addHTML($sharedtext); if ($wgRepositoryBaseUrl && $wgFetchCommonsDescriptions) { - require_once("HttpFunctions.php"); - $ur = ini_set('allow_url_fopen', true); - $text = wfGetHTTP($url . '?action=render'); - ini_set('allow_url_fopen', $ur); + $text = Http::get($url . '?action=render'); if ($text) $this->mExtraDescription = $text; } diff --git a/includes/LoadBalancer.php b/includes/LoadBalancer.php index 33c23bb100..a68e942787 100644 --- a/includes/LoadBalancer.php +++ b/includes/LoadBalancer.php @@ -4,16 +4,6 @@ * @package MediaWiki */ -/** - * Depends on the database object - */ -require_once( 'Database.php' ); - - -# Scale polling time so that under overload conditions, the database server -# receives a SHOW STATUS query at an average interval of this many microseconds -define( 'AVG_STATUS_POLL', 2000 ); - /** * Database load balancing object @@ -28,6 +18,12 @@ class LoadBalancer { /* private */ var $mWaitForFile, $mWaitForPos, $mWaitTimeout; /* private */ var $mLaggedSlaveMode, $mLastError = 'Unknown error'; + /** + * Scale polling time so that under overload conditions, the database server + * receives a SHOW STATUS query at an average interval of this many microseconds + */ + const AVG_STATUS_POLL = 2000; + function LoadBalancer( $servers, $failFunction = false, $waitTimeout = 10, $waitForMasterNow = false ) { $this->mServers = $servers; @@ -182,7 +178,7 @@ class LoadBalancer { # Too much load, back off and wait for a while. # The sleep time is scaled by the number of threads connected, # to produce a roughly constant global poll rate. - $sleepTime = AVG_STATUS_POLL * $status['Threads_connected']; + $sleepTime = self::AVG_STATUS_POLL * $status['Threads_connected']; # If we reach the timeout and exit the loop, don't use it $i = false; @@ -423,9 +419,6 @@ class LoadBalancer { extract( $server ); # Get class for this database type $class = 'Database' . ucfirst( $type ); - if ( !class_exists( $class ) ) { - require_once( "$class.php" ); - } # Create object $db = new $class( $host, $user, $password, $dbname, 1, $flags ); diff --git a/includes/MimeMagic.php b/includes/MimeMagic.php index 8838d230ad..dd197c31c8 100644 --- a/includes/MimeMagic.php +++ b/includes/MimeMagic.php @@ -74,7 +74,7 @@ if ($wgLoadFileinfoExtension) { * file extension, * * Instances of this class are stateles, there only needs to be one global instance -* of MimeMagic. Please use wfGetMimeMagic to get that instance. +* of MimeMagic. Please use MimeMagic::singleton() to get that instance. * @package MediaWiki */ class MimeMagic { @@ -97,8 +97,11 @@ class MimeMagic { */ var $mExtToMime= NULL; - /** Initializes the MimeMagic object. This is called by wfGetMimeMagic when instantiation - * the global MimeMagic singleton object. + /** The singleton instance + */ + private static $instance; + + /** Initializes the MimeMagic object. This is called by MimeMagic::singleton(). * * This constructor parses the mime.types and mime.info files and build internal mappings. */ @@ -227,6 +230,16 @@ class MimeMagic { } + /** + * Get an instance of this class + */ + static function &singleton() { + if ( !isset( self::$instance ) ) { + self::$instance = new MimeMagic; + } + return self::$instance; + } + /** returns a list of file extensions for a given mime type * as a space separated string. */ diff --git a/includes/ObjectCache.php b/includes/ObjectCache.php index e7ef548b17..2b26cf4efb 100644 --- a/includes/ObjectCache.php +++ b/includes/ObjectCache.php @@ -69,13 +69,10 @@ function &wfGetCache( $inputType ) { } 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; @@ -86,7 +83,6 @@ function &wfGetCache( $inputType ) { } } elseif ( $type == CACHE_DBA ) { if ( !array_key_exists( CACHE_DBA, $wgCaches ) ) { - require_once( 'BagOStuff.php' ); $wgCaches[CACHE_DBA] = new DBABagOStuff; } $cache =& $wgCaches[CACHE_DBA]; @@ -94,7 +90,6 @@ function &wfGetCache( $inputType ) { 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]; diff --git a/includes/ProtectionForm.php b/includes/ProtectionForm.php index 456cc8f164..fd1bc81e03 100644 --- a/includes/ProtectionForm.php +++ b/includes/ProtectionForm.php @@ -230,7 +230,6 @@ class ProtectionForm { function showLogExtract( &$out ) { # Show relevant lines from the deletion log: $out->addHTML( "

" . htmlspecialchars( LogPage::logName( 'protect' ) ) . "

\n" ); - require_once( 'SpecialLog.php' ); $logViewer = new LogViewer( new LogReader( new FauxRequest( diff --git a/includes/Revision.php b/includes/Revision.php index 8ea4df2a87..e8d802d692 100644 --- a/includes/Revision.php +++ b/includes/Revision.php @@ -4,9 +4,6 @@ * @todo document */ -/** */ -require_once( 'Database.php' ); - /** * @package MediaWiki * @todo document @@ -539,7 +536,6 @@ class Revision { wfProfileOut( $fname ); return false; } - require_once('ExternalStore.php'); $text=ExternalStore::fetchFromURL($url); } @@ -629,7 +625,6 @@ class Revision { } else { $store = $wgDefaultExternalStore; } - require_once('ExternalStore.php'); // Store and get the URL $data = ExternalStore::insert( $store, $data ); if ( !$data ) { @@ -701,8 +696,12 @@ class Revision { } // If we kept data for lazy extraction, use it now... - $row = $this->mTextRow; - $this->mTextRow = null; + if ( isset( $this->mTextRow ) ) { + $row = $this->mTextRow; + $this->mTextRow = null; + } else { + $row = null; + } if( !$row ) { // Text data is immutable; check slaves first. diff --git a/includes/Skin.php b/includes/Skin.php index 8816ac080f..074cf2b11e 100644 --- a/includes/Skin.php +++ b/includes/Skin.php @@ -1087,7 +1087,6 @@ END; */ function specialPagesList() { global $wgUser, $wgContLang, $wgServer, $wgRedirectScript; - require_once('SpecialPage.php'); $a = array(); $pages = array_merge( SpecialPage::getRegularPages(), SpecialPage::getRestrictedPages() ); foreach ( $pages as $name => $page ) { diff --git a/includes/SpecialExport.php b/includes/SpecialExport.php index 3e56f2fc0f..dc52e00bcd 100644 --- a/includes/SpecialExport.php +++ b/includes/SpecialExport.php @@ -22,9 +22,6 @@ * @subpackage SpecialPage */ -/** */ -require_once( 'Export.php' ); - /** * */ @@ -56,7 +53,7 @@ function wfSpecialExport( $page = '' ) { ); $historyCheck = $wgRequest->getCheck( 'history' ); if ( $curonly ) { - $history = MW_EXPORT_CURRENT; + $history = WikiExporter::CURRENT; } elseif ( !$historyCheck ) { if ( $limit > 0 && $limit < $wgExportMaxHistory ) { $history['limit'] = $limit; @@ -73,14 +70,14 @@ function wfSpecialExport( $page = '' ) { $page = $wgRequest->getText( 'pages', $page ); $historyCheck = $wgRequest->getCheck( 'history' ); if( $historyCheck ) { - $history = MW_EXPORT_FULL; + $history = WikiExporter::FULL; } else { - $history = MW_EXPORT_CURRENT; + $history = WikiExporter::CURRENT; } } if( !$wgExportAllowHistory ) { // Override - $history = MW_EXPORT_CURRENT; + $history = WikiExporter::CURRENT; } $list_authors = $wgRequest->getCheck( 'listauthors' ); diff --git a/includes/SpecialLongpages.php b/includes/SpecialLongpages.php index af56c17cb3..3736d6fc62 100644 --- a/includes/SpecialLongpages.php +++ b/includes/SpecialLongpages.php @@ -5,11 +5,6 @@ * @subpackage SpecialPage */ -/** - * - */ -require_once( 'SpecialShortpages.php' ); - /** * * @package MediaWiki diff --git a/includes/SpecialRecentchanges.php b/includes/SpecialRecentchanges.php index 97f810d9bf..d3d9453f6d 100644 --- a/includes/SpecialRecentchanges.php +++ b/includes/SpecialRecentchanges.php @@ -624,7 +624,6 @@ function rcFormatDiffRow( $title, $oldid, $newid, $timestamp, $comment ) { $fname = 'rcFormatDiff'; wfProfileIn( $fname ); - require_once( 'DifferenceEngine.php' ); $skin = $wgUser->getSkin(); $completeText = '

' . $skin->formatComment( $comment ) . "

\n"; diff --git a/includes/SpecialUndelete.php b/includes/SpecialUndelete.php index 0efdc1b6f9..c91f1a9500 100644 --- a/includes/SpecialUndelete.php +++ b/includes/SpecialUndelete.php @@ -77,7 +77,6 @@ class PageArchive { * @fixme Does this belong in Image for fuller encapsulation? */ function listFiles() { - $fname = __CLASS__ . '::' . __FUNCTION__; if( $this->title->getNamespace() == NS_IMAGE ) { $dbr =& wfGetDB( DB_SLAVE ); $res = $dbr->select( 'filearchive', @@ -93,7 +92,7 @@ class PageArchive { 'fa_user_text', 'fa_timestamp' ), array( 'fa_name' => $this->title->getDbKey() ), - $fname, + __METHOD__, array( 'ORDER BY' => 'fa_timestamp DESC' ) ); $ret = $dbr->resultObject( $res ); return $ret; @@ -108,14 +107,13 @@ class PageArchive { * @return string */ function getRevisionText( $timestamp ) { - $fname = 'PageArchive::getRevisionText'; $dbr =& wfGetDB( DB_SLAVE ); $row = $dbr->selectRow( 'archive', array( 'ar_text', 'ar_flags', 'ar_text_id' ), array( 'ar_namespace' => $this->title->getNamespace(), 'ar_title' => $this->title->getDbkey(), 'ar_timestamp' => $dbr->timestamp( $timestamp ) ), - $fname ); + __METHOD__ ); if( $row ) { return $this->getTextFromRow( $row ); } else { @@ -127,8 +125,6 @@ class PageArchive { * Get the text from an archive row containing ar_text, ar_flags and ar_text_id */ function getTextFromRow( $row ) { - $fname = 'PageArchive::getTextFromRow'; - if( is_null( $row->ar_text_id ) ) { // An old row from MediaWiki 1.4 or previous. // Text is embedded in this row in classic compression format. @@ -139,7 +135,7 @@ class PageArchive { $text = $dbr->selectRow( 'text', array( 'old_text', 'old_flags' ), array( 'old_id' => $row->ar_text_id ), - $fname ); + __METHOD__ ); return Revision::getRevisionText( $text ); } } @@ -252,7 +248,6 @@ class PageArchive { private function undeleteRevisions( $timestamps ) { global $wgParser, $wgDBtype; - $fname = __CLASS__ . '::' . __FUNCTION__; $restoreAll = empty( $timestamps ); $dbw =& wfGetDB( DB_MASTER ); @@ -267,7 +262,7 @@ class PageArchive { array( 'page_id', 'page_latest' ), array( 'page_namespace' => $this->title->getNamespace(), 'page_title' => $this->title->getDBkey() ), - $fname, + __METHOD__, $options ); if( $page ) { # Page already exists. Import the history, and if necessary @@ -311,12 +306,12 @@ class PageArchive { 'ar_namespace' => $this->title->getNamespace(), 'ar_title' => $this->title->getDBkey(), $oldones ), - $fname, + __METHOD__, /* options */ array( 'ORDER BY' => 'ar_timestamp' ) ); if( $dbw->numRows( $result ) < count( $timestamps ) ) { - wfDebug( "$fname: couldn't find all requested rows\n" ); + wfDebug( __METHOD__.": couldn't find all requested rows\n" ); return false; } @@ -383,7 +378,7 @@ class PageArchive { 'ar_namespace' => $this->title->getNamespace(), 'ar_title' => $this->title->getDBkey(), $oldones ), - $fname ); + __METHOD__ ); return $restored; } @@ -463,7 +458,6 @@ class UndeleteForm { /* private */ function showList() { global $wgLang, $wgContLang, $wgUser, $wgOut; - $fname = "UndeleteForm::showList"; # List undeletable articles $result = PageArchive::listAllPages(); @@ -492,7 +486,6 @@ class UndeleteForm { /* private */ function showRevision( $timestamp ) { global $wgLang, $wgUser, $wgOut; - $fname = "UndeleteForm::showRevision"; if(!preg_match("/[0-9]{14}/",$timestamp)) return 0; @@ -615,7 +608,6 @@ class UndeleteForm { # Show relevant lines from the deletion log: $wgOut->addHTML( "

" . htmlspecialchars( LogPage::logName( 'delete' ) ) . "

\n" ); - require_once( 'SpecialLog.php' ); $logViewer = new LogViewer( new LogReader( new FauxRequest( diff --git a/includes/SpecialUpload.php b/includes/SpecialUpload.php index 64d16b87ee..ade5805644 100644 --- a/includes/SpecialUpload.php +++ b/includes/SpecialUpload.php @@ -5,10 +5,7 @@ * @subpackage SpecialPage */ -/** - * - */ -require_once 'Image.php'; + /** * Entry point */ @@ -887,7 +884,7 @@ class UploadForm { */ function verify( $tmpfile, $extension ) { #magically determine mime type - $magic=& wfGetMimeMagic(); + $magic=& MimeMagic::singleton(); $mime= $magic->guessMimeType($tmpfile,false); $fname= "SpecialUpload::verify"; @@ -936,7 +933,7 @@ class UploadForm { function verifyExtension( $mime, $extension ) { $fname = 'SpecialUpload::verifyExtension'; - $magic =& wfGetMimeMagic(); + $magic =& MimeMagic::singleton(); if ( ! $mime || $mime == 'unknown' || $mime == 'unknown/unknown' ) if ( ! $magic->isRecognizableExtension( $extension ) ) { diff --git a/includes/SpecialUploadMogile.php b/includes/SpecialUploadMogile.php index 51a6dd28c5..05bfca085a 100644 --- a/includes/SpecialUploadMogile.php +++ b/includes/SpecialUploadMogile.php @@ -8,7 +8,6 @@ /** * */ -require_once( 'SpecialUpload.php' ); require_once( 'MogileFS.php' ); /** diff --git a/includes/StreamFile.php b/includes/StreamFile.php index 99cb4d7cc8..81538a846e 100644 --- a/includes/StreamFile.php +++ b/includes/StreamFile.php @@ -66,7 +66,7 @@ function wfGetType( $filename ) { return 'unknown/unknown'; } else { - $magic=& wfGetMimeMagic(); + $magic=& MimeMagic::singleton(); return $magic->guessMimeType($filename); //full fancy mime detection } } diff --git a/includes/WebRequest.php b/includes/WebRequest.php index 6b8e944911..d0ce25e668 100644 --- a/includes/WebRequest.php +++ b/includes/WebRequest.php @@ -119,7 +119,6 @@ class WebRequest { $data = $wgContLang->checkTitleEncoding( $data ); } } - require_once( 'normal/UtfNormal.php' ); $data = $this->normalizeUnicode( $data ); return $data; } else { diff --git a/maintenance/dumpBackup.php b/maintenance/dumpBackup.php index 1735422d2d..ef5d47c92d 100644 --- a/maintenance/dumpBackup.php +++ b/maintenance/dumpBackup.php @@ -57,12 +57,12 @@ if( isset( $options['end'] ) ) { $dumper->skipHeader = isset( $options['skip-header'] ); $dumper->skipFooter = isset( $options['skip-footer'] ); -$textMode = isset( $options['stub'] ) ? MW_EXPORT_STUB : MW_EXPORT_TEXT; +$textMode = isset( $options['stub'] ) ? WikiExporter::STUB : WikiExporter::TEXT; if( isset( $options['full'] ) ) { - $dumper->dump( MW_EXPORT_FULL, $textMode ); + $dumper->dump( WikiExporter::FULL, $textMode ); } elseif( isset( $options['current'] ) ) { - $dumper->dump( MW_EXPORT_CURRENT, $textMode ); + $dumper->dump( WikiExporter::CURRENT, $textMode ); } else { $dumper->progress( <<input = $url; break; case 'current': - $this->history = MW_EXPORT_CURRENT; + $this->history = WikiExporter::CURRENT; break; case 'full': - $this->history = MW_EXPORT_FULL; + $this->history = WikiExporter::FULL; break; } }