Made enhanced wfMsg() faster
[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 include_once( "$IP/GlobalFunctions.php" );
10 include_once( "$IP/Namespace.php" );
11 include_once( "$IP/Skin.php" );
12 include_once( "$IP/OutputPage.php" );
13 include_once( "$IP/DifferenceEngine.php" );
14 include_once( "$IP/SearchEngine.php" );
15 include_once( "$IP/User.php" );
16 include_once( "$IP/LinkCache.php" );
17 include_once( "$IP/Title.php" );
18 include_once( "$IP/Article.php" );
19 include_once( "$IP/MagicWord.php" );
20 include_once( "$IP/MemCachedClient.inc.php" );
21 include_once( "$IP/Block.php" );
22
23 global $wgUser, $wgLang, $wgOut, $wgTitle;
24 global $wgArticle, $wgDeferredUpdateList, $wgLinkCache;
25 global $wgMemc, $wgMagicWords, $wgMwRedir, $wgDebugLogFile;
26
27 class MemCachedClientforWiki extends MemCachedClient {
28 function _debug( $text ) {
29 wfDebug( "memcached: $text\n" );
30 }
31 }
32
33 $wgMemc = new MemCachedClientforWiki();
34 if( $wgUseMemCached ) {
35 $wgMemc->set_servers( $wgMemCachedServers );
36 $wgMemc->set_debug( $wgMemCachedDebug );
37
38 # Test it to see if it's working
39 # This is necessary because otherwise wfMsg would be extremely inefficient
40 if ( !$wgMemc->set( "test", "", 0 ) ) {
41 wfDebug( "Memcached error: " . $wgMemc->error_string() . "\n" );
42 $wgUseMemCached = false;
43 }
44 }
45
46 include_once( "$IP/Language.php" );
47
48 $wgOut = new OutputPage();
49 wfDebug( "\n\n" );
50
51 $wgLangClass = "Language" . ucfirst( $wgLanguageCode );
52 if( ! class_exists( $wgLangClass ) ) {
53 include_once( "$IP/LanguageUtf8.php" );
54 $wgLangClass = "LanguageUtf8";
55 }
56 $wgLang = new $wgLangClass();
57
58 if( !isset( $wgProfiling ) )
59 $wgProfiling = false;
60
61 if ( $wgProfiling ) {
62 include_once( "$IP/Profiling.php" );
63 } else {
64 function wfProfileIn( $fn ) {}
65 function wfProfileOut( $fn = "" ) {}
66 function wfGetProfilingOutput( $s, $e ) {}
67 function wfProfileClose() {}
68 }
69
70 $wgUser = User::loadFromSession();
71 $wgDeferredUpdateList = array();
72 $wgLinkCache = new LinkCache();
73 $wgMagicWords = array();
74 $wgMwRedir =& MagicWord::get( MAG_REDIRECT );
75 ?>