Latest features and bug fixes imported from stable
[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
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
47 class MemCachedClientforWiki extends MemCachedClient {
48 function _debug( $text ) {
49 wfDebug( "memcached: $text\n" );
50 }
51 }
52
53 $wgMemc = new MemCachedClientforWiki();
54 if( $wgUseMemCached ) {
55 $wgMemc->set_servers( $wgMemCachedServers );
56 $wgMemc->set_debug( $wgMemCachedDebug );
57
58 # Test it to see if it's working
59 # This is necessary because otherwise wfMsg would be extremely inefficient
60 if ( !$wgMemc->set( "test", "", 0 ) ) {
61 wfDebug( "Memcached error: " . $wgMemc->error_string() . "\n" );
62 $wgUseMemCached = false;
63 }
64 }
65 wfProfileOut( "$fname-memcached" );
66 wfProfileIn( "$fname-misc" );
67
68 include_once( "$IP/Language.php" );
69
70 $wgOut = new OutputPage();
71 wfDebug( "\n\n" );
72
73 $wgLangClass = "Language" . ucfirst( $wgLanguageCode );
74 if( ! class_exists( $wgLangClass ) ) {
75 include_once( "$IP/LanguageUtf8.php" );
76 $wgLangClass = "LanguageUtf8";
77 }
78 $wgLang = new $wgLangClass();
79
80 if( !$wgCommandLineMode ) {
81 if( $wgSessionsInMemcached ) {
82 include_once( "$IP/MemcachedSessions.php" );
83 }
84 session_set_cookie_params( 0, $wgCookiePath, $wgCookieDomain );
85 session_cache_limiter( "private, must-revalidate" );
86 session_start();
87 session_register( "wsUserID" );
88 session_register( "wsUserName" );
89 session_register( "wsUserPassword" );
90 session_register( "wsUploadFiles" );
91 }
92
93 $wgUser = User::loadFromSession();
94 $wgDeferredUpdateList = array();
95 $wgLinkCache = new LinkCache();
96 $wgMagicWords = array();
97 $wgMwRedir =& MagicWord::get( MAG_REDIRECT );
98
99 wfProfileOut( "$fname-misc" );
100 wfProfileOut( $fname );
101
102 ?>