16cc547460c1d2d57e1c8ece82be50014b52da9a
[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 global $IP;
9
10 if( !isset( $wgProfiling ) )
11 $wgProfiling = false;
12
13 if ( $wgProfiling ) {
14 include_once( "$IP/Profiling.php" );
15 } else {
16 function wfProfileIn( $fn ) {}
17 function wfProfileOut( $fn = "" ) {}
18 function wfGetProfilingOutput( $s, $e ) {}
19 function wfProfileClose() {}
20 }
21
22 $fname = "Setup.php";
23 wfProfileIn( $fname );
24 wfProfileIn( "$fname-includes" );
25
26 # Only files which are used on every invocation should be included here
27 # Otherwise, include them conditionally [TS]
28 include_once( "$IP/GlobalFunctions.php" );
29 include_once( "$IP/Namespace.php" );
30 include_once( "$IP/Skin.php" );
31 include_once( "$IP/OutputPage.php" );
32 include_once( "$IP/User.php" );
33 include_once( "$IP/LinkCache.php" );
34 include_once( "$IP/Title.php" );
35 include_once( "$IP/Article.php" );
36 include_once( "$IP/MagicWord.php" );
37 include_once( "$IP/MemCachedClient.inc.php" );
38 include_once( "$IP/Block.php" );
39 include_once( "$IP/SearchEngine.php" );
40 include_once( "$IP/DifferenceEngine.php" );
41
42 wfProfileOut( "$fname-includes" );
43 wfProfileIn( "$fname-memcached" );
44 global $wgUser, $wgLang, $wgOut, $wgTitle;
45 global $wgArticle, $wgDeferredUpdateList, $wgLinkCache;
46 global $wgMemc, $wgMagicWords, $wgMwRedir, $wgDebugLogFile;
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 wfProfileOut( "$fname-memcached" );
67 wfProfileIn( "$fname-misc" );
68
69 include_once( "$IP/Language.php" );
70
71 $wgOut = new OutputPage();
72 wfDebug( "\n\n" );
73
74 $wgLangClass = "Language" . ucfirst( $wgLanguageCode );
75 if( ! class_exists( $wgLangClass ) ) {
76 include_once( "$IP/LanguageUtf8.php" );
77 $wgLangClass = "LanguageUtf8";
78 }
79 $wgLang = new $wgLangClass();
80
81 if( !$wgCommandLineMode ) {
82 if( $wgSessionsInMemcached ) {
83 include_once( "$IP/MemcachedSessions.php" );
84 }
85 session_set_cookie_params( 0, $wgCookiePath, $wgCookieDomain );
86 session_cache_limiter( "private, must-revalidate" );
87 session_start();
88 session_register( "wsUserID" );
89 session_register( "wsUserName" );
90 session_register( "wsUserPassword" );
91 session_register( "wsUploadFiles" );
92 }
93
94 $wgUser = User::loadFromSession();
95 $wgDeferredUpdateList = array();
96 $wgLinkCache = new LinkCache();
97 $wgMagicWords = array();
98 $wgMwRedir =& MagicWord::get( MAG_REDIRECT );
99
100 wfProfileOut( "$fname-misc" );
101 wfProfileOut( $fname );
102
103 ?>