Improvements in MediaWiki namespace handling, enhanced rollback
[lhc/web/wiklou.git] / includes / Setup.php
1 <?
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.
6 #
7
8 if( !isset( $wgProfiling ) )
9 $wgProfiling = false;
10
11 if ( $wgProfiling and (0 == rand() % $wgProfileSampleRate ) ) {
12 include_once( "Profiling.php" );
13 } else {
14 function wfProfileIn( $fn ) {}
15 function wfProfileOut( $fn = "" ) {}
16 function wfGetProfilingOutput( $s, $e ) {}
17 function wfProfileClose() {}
18 }
19
20 $fname = "Setup.php";
21 wfProfileIn( $fname );
22 global $wgUseDynamicDates;
23 wfProfileIn( "$fname-includes" );
24
25 include_once( "GlobalFunctions.php" );
26 include_once( "Namespace.php" );
27 include_once( "Skin.php" );
28 include_once( "OutputPage.php" );
29 include_once( "User.php" );
30 include_once( "LinkCache.php" );
31 include_once( "Title.php" );
32 include_once( "Article.php" );
33 include_once( "MagicWord.php" );
34 include_once( "MemCachedClient.inc.php" );
35 include_once( "Block.php" );
36 include_once( "SearchEngine.php" );
37 include_once( "DifferenceEngine.php" );
38 include_once( "MessageCache.php" );
39
40 wfProfileOut( "$fname-includes" );
41 wfProfileIn( "$fname-memcached" );
42 global $wgUser, $wgLang, $wgOut, $wgTitle;
43 global $wgArticle, $wgDeferredUpdateList, $wgLinkCache;
44 global $wgMemc, $wgMagicWords, $wgMwRedir, $wgDebugLogFile;
45 global $wgMessageCache, $wgUseMemCached, $wgUseDatabaseMessages;
46 global $wgMsgCacheExpiry, $wgDBname;
47
48 class MemCachedClientforWiki extends MemCachedClient {
49 function _debug( $text ) {
50 wfDebug( "memcached: $text\n" );
51 }
52 }
53
54 $wgMemc = new MemCachedClientforWiki();
55 if( $wgUseMemCached ) {
56 $wgMemc->set_servers( $wgMemCachedServers );
57 $wgMemc->set_debug( $wgMemCachedDebug );
58
59 # Test it to see if it's working
60 # This is necessary because otherwise wfMsg would be extremely inefficient
61 if ( !$wgMemc->set( "test", "", 0 ) ) {
62 wfDebug( "Memcached error: " . $wgMemc->error_string() . "\n" );
63 $wgUseMemCached = false;
64 }
65 }
66
67 wfProfileOut( "$fname-memcached" );
68 wfProfileIn( "$fname-misc" );
69
70 include_once( "Language.php" );
71
72 $wgMessageCache = new MessageCache( $wgUseMemCached, $wgUseDatabaseMessages, $wgMsgCacheExpiry, $wgDBname );
73
74 $wgOut = new OutputPage();
75 wfDebug( "\n\n" );
76
77 $wgLangClass = "Language" . ucfirst( $wgLanguageCode );
78 if( ! class_exists( $wgLangClass ) ) {
79 include_once( "LanguageUtf8.php" );
80 $wgLangClass = "LanguageUtf8";
81 }
82 $wgLang = new $wgLangClass();
83
84 if ( $wgUseDynamicDates ) {
85 include_once( "DateFormatter.php" );
86 global $wgDateFormatter;
87 $wgDateFormatter = new DateFormatter;
88 }
89
90 if( !$wgCommandLineMode ) {
91 if( $wgSessionsInMemcached ) {
92 include_once( "MemcachedSessions.php" );
93 }
94 session_set_cookie_params( 0, $wgCookiePath, $wgCookieDomain );
95 session_cache_limiter( "private, must-revalidate" );
96 session_start();
97 session_register( "wsUserID" );
98 session_register( "wsUserName" );
99 session_register( "wsUserPassword" );
100 session_register( "wsUploadFiles" );
101 }
102
103 $wgUser = User::loadFromSession();
104 $wgDeferredUpdateList = array();
105 $wgLinkCache = new LinkCache();
106 $wgMagicWords = array();
107 $wgMwRedir =& MagicWord::get( MAG_REDIRECT );
108
109 wfProfileOut( "$fname-misc" );
110 wfProfileOut( $fname );
111
112 ?>