3079dc5e88bff1ddbcdd4e92ef32492511577b70
[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 # Only files which are used on every invocation should be included here
26 # Otherwise, include them conditionally [TS]
27 include_once( "GlobalFunctions.php" );
28 include_once( "Namespace.php" );
29 include_once( "Skin.php" );
30 include_once( "OutputPage.php" );
31 include_once( "User.php" );
32 include_once( "LinkCache.php" );
33 include_once( "Title.php" );
34 include_once( "Article.php" );
35 include_once( "MagicWord.php" );
36 include_once( "MemCachedClient.inc.php" );
37 include_once( "Block.php" );
38 include_once( "SearchEngine.php" );
39 include_once( "DifferenceEngine.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
66 wfProfileOut( "$fname-memcached" );
67 wfProfileIn( "$fname-misc" );
68
69 include_once( "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( "LanguageUtf8.php" );
77 $wgLangClass = "LanguageUtf8";
78 }
79 $wgLang = new $wgLangClass();
80
81 if ( $wgUseDynamicDates ) {
82 include_once( "DateFormatter.php" );
83 global $wgDateFormatter;
84 $wgDateFormatter = new DateFormatter;
85 }
86
87 if( !$wgCommandLineMode ) {
88 if( $wgSessionsInMemcached ) {
89 include_once( "MemcachedSessions.php" );
90 }
91 session_set_cookie_params( 0, $wgCookiePath, $wgCookieDomain );
92 session_cache_limiter( "private, must-revalidate" );
93 session_start();
94 session_register( "wsUserID" );
95 session_register( "wsUserName" );
96 session_register( "wsUserPassword" );
97 session_register( "wsUploadFiles" );
98 }
99
100 $wgUser = User::loadFromSession();
101 $wgDeferredUpdateList = array();
102 $wgLinkCache = new LinkCache();
103 $wgMagicWords = array();
104 $wgMwRedir =& MagicWord::get( MAG_REDIRECT );
105
106 wfProfileOut( "$fname-misc" );
107 wfProfileOut( $fname );
108
109 ?>