* Recent Changes improvements: object oriented back end, move page annotation and...
[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( "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" );
40
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;
48
49 class MemCachedClientforWiki extends MemCachedClient {
50 function _debug( $text ) {
51 wfDebug( "memcached: $text\n" );
52 }
53 }
54
55 $wgMemc = new MemCachedClientforWiki();
56 if( $wgUseMemCached ) {
57 $wgMemc->set_servers( $wgMemCachedServers );
58 $wgMemc->set_debug( $wgMemCachedDebug );
59
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;
65 }
66 }
67
68 wfProfileOut( "$fname-memcached" );
69 wfProfileIn( "$fname-misc" );
70
71 include_once( "Language.php" );
72
73 $wgMessageCache = new MessageCache;
74
75 $wgOut = new OutputPage();
76 wfDebug( "\n\n" );
77
78 $wgLangClass = "Language" . ucfirst( $wgLanguageCode );
79 if( ! class_exists( $wgLangClass ) ) {
80 include_once( "LanguageUtf8.php" );
81 $wgLangClass = "LanguageUtf8";
82 }
83
84 $wgLang = new $wgLangClass();
85 if ( !is_object($wgLang) ) {
86 print "No language class ($wgLang)\N";
87 }
88 $wgMessageCache->initialise( $wgUseMemCached, $wgUseDatabaseMessages, $wgMsgCacheExpiry, $wgDBname );
89
90 if ( $wgUseDynamicDates ) {
91 include_once( "DateFormatter.php" );
92 global $wgDateFormatter;
93 $wgDateFormatter = new DateFormatter;
94 }
95
96 if( !$wgCommandLineMode ) {
97 if( $wgSessionsInMemcached ) {
98 include_once( "MemcachedSessions.php" );
99 }
100 session_set_cookie_params( 0, $wgCookiePath, $wgCookieDomain );
101 session_cache_limiter( "private, must-revalidate" );
102 session_start();
103 session_register( "wsUserID" );
104 session_register( "wsUserName" );
105 session_register( "wsUserPassword" );
106 session_register( "wsUploadFiles" );
107 }
108
109 $wgUser = User::loadFromSession();
110 $wgDeferredUpdateList = array();
111 $wgLinkCache = new LinkCache();
112 $wgMagicWords = array();
113 $wgMwRedir =& MagicWord::get( MAG_REDIRECT );
114
115 wfProfileOut( "$fname-misc" );
116 wfProfileOut( $fname );
117
118 ?>