Date formatter into temp branch
[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
59 if ( $wgUseDynamicDates ) {
60 include_once( "DateFormatter.php" );
61 global $wgDateFormatter;
62 $wgDateFormatter = new DateFormatter;
63
64 # Test it to see if it's working
65 # This is necessary because otherwise wfMsg would be extremely inefficient
66 if ( !$wgMemc->set( "test", "", 0 ) ) {
67 wfDebug( "Memcached error: " . $wgMemc->error_string() . "\n" );
68 $wgUseMemCached = false;
69 }
70 }
71 wfProfileOut( "$fname-memcached" );
72 wfProfileIn( "$fname-misc" );
73
74 include_once( "Language.php" );
75
76 $wgOut = new OutputPage();
77 wfDebug( "\n\n" );
78
79 $wgLangClass = "Language" . ucfirst( $wgLanguageCode );
80 if( ! class_exists( $wgLangClass ) ) {
81 include_once( "LanguageUtf8.php" );
82 $wgLangClass = "LanguageUtf8";
83 }
84 $wgLang = new $wgLangClass();
85
86 if( !$wgCommandLineMode ) {
87 if( $wgSessionsInMemcached ) {
88 include_once( "MemcachedSessions.php" );
89 }
90 session_set_cookie_params( 0, $wgCookiePath, $wgCookieDomain );
91 session_cache_limiter( "private, must-revalidate" );
92 session_start();
93 session_register( "wsUserID" );
94 session_register( "wsUserName" );
95 session_register( "wsUserPassword" );
96 session_register( "wsUploadFiles" );
97 }
98
99 $wgUser = User::loadFromSession();
100 $wgDeferredUpdateList = array();
101 $wgLinkCache = new LinkCache();
102 $wgMagicWords = array();
103 $wgMwRedir =& MagicWord::get( MAG_REDIRECT );
104
105 wfProfileOut( "$fname-misc" );
106 wfProfileOut( $fname );
107
108 ?>