8fe9ef71acd0c25781b63ce6a044ab3d8c27a9ed
[lhc/web/wiklou.git] / includes / Setup.php
1 <?php
2 /**
3 * Include most things that's need to customize the site
4 * @package MediaWiki
5 */
6
7 /**
8 * This file is not a valid entry point, perform no further processing unless
9 * MEDIAWIKI is defined
10 */
11 if( !defined( 'MEDIAWIKI' ) ) {
12 echo "This file is part of MediaWiki, it is not a valid entry point.\n";
13 exit( 1 );
14 }
15
16 # The main wiki script and things like database
17 # conversion and maintenance scripts all share a
18 # common setup of including lots of classes and
19 # setting up a few globals.
20 #
21
22 $fname = 'Setup.php';
23 wfProfileIn( $fname );
24
25 // Check to see if we are at the file scope
26 if ( !isset( $wgVersion ) ) {
27 echo "Error, Setup.php must be included from the file scope, after DefaultSettings.php\n";
28 die( 1 );
29 }
30
31 require_once( "$IP/includes/AutoLoader.php" );
32
33 wfProfileIn( $fname.'-exception' );
34 require_once( "$IP/includes/Exception.php" );
35 wfInstallExceptionHandler();
36 wfProfileOut( $fname.'-exception' );
37
38 wfProfileIn( $fname.'-includes' );
39 require_once( "$IP/includes/GlobalFunctions.php" );
40 require_once( "$IP/includes/Hooks.php" );
41 require_once( "$IP/includes/Namespace.php" );
42 require_once( "$IP/includes/ProxyTools.php" );
43 require_once( "$IP/includes/ObjectCache.php" );
44 require_once( "$IP/includes/ImageFunctions.php" );
45 require_once( "$IP/includes/StubObject.php" );
46 wfProfileOut( $fname.'-includes' );
47 wfProfileIn( $fname.'-misc1' );
48
49
50 $wgIP = false; # Load on demand
51 # Can't stub this one, it sets up $_GET and $_REQUEST in its constructor
52 $wgRequest = new WebRequest;
53 if ( function_exists( 'posix_uname' ) ) {
54 $wguname = posix_uname();
55 $wgNodeName = $wguname['nodename'];
56 } else {
57 $wgNodeName = '';
58 }
59
60 # Useful debug output
61 if ( $wgCommandLineMode ) {
62 wfDebug( "\n\nStart command line script $self\n" );
63 } elseif ( function_exists( 'getallheaders' ) ) {
64 wfDebug( "\n\nStart request\n" );
65 wfDebug( $_SERVER['REQUEST_METHOD'] . ' ' . $_SERVER['REQUEST_URI'] . "\n" );
66 $headers = getallheaders();
67 foreach ($headers as $name => $value) {
68 wfDebug( "$name: $value\n" );
69 }
70 wfDebug( "\n" );
71 } elseif( isset( $_SERVER['REQUEST_URI'] ) ) {
72 wfDebug( $_SERVER['REQUEST_METHOD'] . ' ' . $_SERVER['REQUEST_URI'] . "\n" );
73 }
74
75 if ( $wgSkipSkin ) {
76 $wgSkipSkins[] = $wgSkipSkin;
77 }
78
79 $wgUseEnotif = $wgEnotifUserTalk || $wgEnotifWatchlist;
80
81 if($wgMetaNamespace === FALSE) {
82 $wgMetaNamespace = str_replace( ' ', '_', $wgSitename );
83 }
84
85 # These are now the same, always
86 # To determine the user language, use $wgLang->getCode()
87 $wgContLanguageCode = $wgLanguageCode;
88
89 wfProfileOut( $fname.'-misc1' );
90 wfProfileIn( $fname.'-memcached' );
91
92 $wgMemc =& wfGetMainCache();
93 $messageMemc =& wfGetMessageCacheStorage();
94 $parserMemc =& wfGetParserCacheStorage();
95
96 wfDebug( 'Main cache: ' . get_class( $wgMemc ) .
97 "\nMessage cache: " . get_class( $messageMemc ) .
98 "\nParser cache: " . get_class( $parserMemc ) . "\n" );
99
100 wfProfileOut( $fname.'-memcached' );
101 wfProfileIn( $fname.'-SetupSession' );
102
103 if ( $wgDBprefix ) {
104 $wgCookiePrefix = $wgDBname . '_' . $wgDBprefix;
105 } elseif ( $wgSharedDB ) {
106 $wgCookiePrefix = $wgSharedDB;
107 } else {
108 $wgCookiePrefix = $wgDBname;
109 }
110
111 # If session.auto_start is there, we can't touch session name
112 #
113 if( !ini_get( 'session.auto_start' ) )
114 session_name( $wgSessionName ? $wgSessionName : $wgCookiePrefix . '_session' );
115
116 if( !$wgCommandLineMode && ( isset( $_COOKIE[session_name()] ) || isset( $_COOKIE[$wgCookiePrefix.'Token'] ) ) ) {
117 wfIncrStats( 'request_with_session' );
118 wfSetupSession();
119 $wgSessionStarted = true;
120 } else {
121 wfIncrStats( 'request_without_session' );
122 $wgSessionStarted = false;
123 }
124
125 wfProfileOut( $fname.'-SetupSession' );
126 wfProfileIn( $fname.'-globals' );
127
128 if ( !$wgDBservers ) {
129 $wgDBservers = array(array(
130 'host' => $wgDBserver,
131 'user' => $wgDBuser,
132 'password' => $wgDBpassword,
133 'dbname' => $wgDBname,
134 'type' => $wgDBtype,
135 'load' => 1,
136 'flags' => ($wgDebugDumpSql ? DBO_DEBUG : 0) | DBO_DEFAULT
137 ));
138 }
139
140 $wgLoadBalancer = new StubObject( 'wgLoadBalancer', 'LoadBalancer',
141 array( $wgDBservers, false, $wgMasterWaitTimeout, true ) );
142 $wgContLang = new StubContLang;
143 $wgUser = new StubUser;
144 $wgLang = new StubUserLang;
145 $wgOut = new StubObject( 'wgOut', 'OutputPage' );
146 $wgParser = new StubObject( 'wgParser', 'Parser' );
147 $wgMessageCache = new StubObject( 'wgMessageCache', 'MessageCache',
148 array( $parserMemc, $wgUseDatabaseMessages, $wgMsgCacheExpiry, wfWikiID() ) );
149
150 wfProfileOut( $fname.'-globals' );
151 wfProfileIn( $fname.'-User' );
152
153 # Skin setup functions
154 # Entries can be added to this variable during the inclusion
155 # of the extension file. Skins can then perform any necessary initialisation.
156 #
157 foreach ( $wgSkinExtensionFunctions as $func ) {
158 call_user_func( $func );
159 }
160
161 if( !is_object( $wgAuth ) ) {
162 $wgAuth = new StubObject( 'wgAuth', 'AuthPlugin' );
163 }
164 wfProfileOut( $fname.'-User' );
165
166 wfProfileIn( $fname.'-misc2' );
167
168 $wgDeferredUpdateList = array();
169 $wgPostCommitUpdateList = array();
170
171 if ( $wgAjaxSearch ) $wgAjaxExportList[] = 'wfSajaxSearch';
172
173 wfSeedRandom();
174
175 # Placeholders in case of DB error
176 $wgTitle = null;
177 $wgArticle = null;
178
179 wfProfileOut( $fname.'-misc2' );
180 wfProfileIn( $fname.'-extensions' );
181
182 # Extension setup functions for extensions other than skins
183 # Entries should be added to this variable during the inclusion
184 # of the extension file. This allows the extension to perform
185 # any necessary initialisation in the fully initialised environment
186 foreach ( $wgExtensionFunctions as $func ) {
187 $profName = $fname.'-extensions-'.strval( $func );
188 wfProfileIn( $profName );
189 call_user_func( $func );
190 wfProfileOut( $profName );
191 }
192
193 // For compatibility
194 wfRunHooks( 'LogPageValidTypes', array( &$wgLogTypes ) );
195 wfRunHooks( 'LogPageLogName', array( &$wgLogNames ) );
196 wfRunHooks( 'LogPageLogHeader', array( &$wgLogHeaders ) );
197 wfRunHooks( 'LogPageActionText', array( &$wgLogActions ) );
198
199
200 wfDebug( "Fully initialised\n" );
201 $wgFullyInitialised = true;
202 wfProfileOut( $fname.'-extensions' );
203 wfProfileOut( $fname );
204
205 ?>