2 # The main wiki script and things like database
3 # conversion and maintenance scripts all share a
4 # common setup of including lots of classes and
5 # setting up a few globals.
8 if( !isset( $wgProfiling ) )
11 if ( $wgProfiling and (0 == rand() %
$wgProfileSampleRate ) ) {
12 include_once( "Profiling.php" );
14 function wfProfileIn( $fn ) {}
15 function wfProfileOut( $fn = "" ) {}
16 function wfGetProfilingOutput( $s, $e ) {}
17 function wfProfileClose() {}
21 wfProfileIn( $fname );
22 global $wgUseDynamicDates;
23 wfProfileIn( "$fname-includes" );
25 include_once( "GlobalFunctions.php" );
26 include_once( "Namespace.php" );
27 include_once( "RecentChange.php" );
28 include_once( "Skin.php" );
29 include_once( "OutputPage.php" );
30 include_once( "User.php" );
31 include_once( "LinkCache.php" );
32 include_once( "Title.php" );
33 include_once( "Article.php" );
34 include_once( "MagicWord.php" );
35 include_once( "MemCachedClient.inc.php" );
36 include_once( "Block.php" );
37 include_once( "SearchEngine.php" );
38 include_once( "DifferenceEngine.php" );
39 include_once( "MessageCache.php" );
41 wfProfileOut( "$fname-includes" );
42 wfProfileIn( "$fname-memcached" );
43 global $wgUser, $wgLang, $wgOut, $wgTitle;
44 global $wgArticle, $wgDeferredUpdateList, $wgLinkCache;
45 global $wgMemc, $wgMagicWords, $wgMwRedir, $wgDebugLogFile;
46 global $wgMessageCache, $wgUseMemCached, $wgUseDatabaseMessages;
47 global $wgMsgCacheExpiry, $wgDBname, $wgCommandLineMode;
49 class MemCachedClientforWiki
extends MemCachedClient
{
50 function _debug( $text ) {
51 wfDebug( "memcached: $text\n" );
55 $wgMemc = new MemCachedClientforWiki();
56 if( $wgUseMemCached ) {
57 $wgMemc->set_servers( $wgMemCachedServers );
58 $wgMemc->set_debug( $wgMemCachedDebug );
60 # Test it to see if it's working
61 # This is necessary because otherwise wfMsg would be extremely inefficient
62 if ( !$wgMemc->set( "test", "", 0 ) ) {
63 wfDebug( "Memcached error: " . $wgMemc->error_string() . "\n" );
64 $wgUseMemCached = false;
68 wfProfileOut( "$fname-memcached" );
69 wfProfileIn( "$fname-misc" );
71 include_once( "Language.php" );
73 $wgMessageCache = new MessageCache
;
75 $wgOut = new OutputPage();
78 $wgLangClass = "Language" . ucfirst( $wgLanguageCode );
79 if( ! class_exists( $wgLangClass ) ) {
80 include_once( "LanguageUtf8.php" );
81 $wgLangClass = "LanguageUtf8";
84 $wgLang = new $wgLangClass();
85 if ( !is_object($wgLang) ) {
86 print "No language class ($wgLang)\N";
88 $wgMessageCache->initialise( $wgUseMemCached, $wgUseDatabaseMessages, $wgMsgCacheExpiry, $wgDBname );
90 if ( $wgUseDynamicDates ) {
91 include_once( "DateFormatter.php" );
92 global $wgDateFormatter;
93 $wgDateFormatter = new DateFormatter
;
96 if( !$wgCommandLineMode ) {
97 if( $wgSessionsInMemcached ) {
98 include_once( "MemcachedSessions.php" );
100 session_set_cookie_params( 0, $wgCookiePath, $wgCookieDomain );
101 session_cache_limiter( "private, must-revalidate" );
103 session_register( "wsUserID" );
104 session_register( "wsUserName" );
105 session_register( "wsUserPassword" );
106 session_register( "wsUploadFiles" );
109 $wgUser = User
::loadFromSession();
110 $wgDeferredUpdateList = array();
111 $wgLinkCache = new LinkCache();
112 $wgMagicWords = array();
113 $wgMwRedir =& MagicWord
::get( MAG_REDIRECT
);
115 wfProfileOut( "$fname-misc" );
116 wfProfileOut( $fname );