Return nothing on empty math tags instead of char encoding
[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 // Set various default paths sensibly...
32 if( $wgScript === false ) $wgScript = "$wgScriptPath/index.php";
33 if( $wgRedirectScript === false ) $wgRedirectScript = "$wgScriptPath/redirect.php";
34
35 if( $wgArticlePath === false ) {
36 if( $wgUsePathInfo ) {
37 $wgArticlePath = "$wgScript/$1";
38 } else {
39 $wgArticlePath = "$wgScript?title=$1";
40 }
41 }
42
43 if( $wgStylePath === false ) $wgStylePath = "$wgScriptPath/skins";
44 if( $wgStyleDirectory === false) $wgStyleDirectory = "$IP/skins";
45
46 if( $wgLogo === false ) $wgLogo = "$wgStylePath/common/images/wiki.png";
47
48 if( $wgUploadPath === false ) $wgUploadPath = "$wgScriptPath/images";
49 if( $wgUploadDirectory === false ) $wgUploadDirectory = "$IP/images";
50
51 if( $wgMathPath === false ) $wgMathPath = "{$wgUploadPath}/math";
52 if( $wgMathDirectory === false ) $wgMathDirectory = "{$wgUploadDirectory}/math";
53 if( $wgTmpDirectory === false ) $wgTmpDirectory = "{$wgUploadDirectory}/tmp";
54
55 require_once( "$IP/includes/AutoLoader.php" );
56
57 wfProfileIn( $fname.'-exception' );
58 require_once( "$IP/includes/Exception.php" );
59 wfInstallExceptionHandler();
60 wfProfileOut( $fname.'-exception' );
61
62 wfProfileIn( $fname.'-includes' );
63 require_once( "$IP/includes/GlobalFunctions.php" );
64 require_once( "$IP/includes/Hooks.php" );
65 require_once( "$IP/includes/Namespace.php" );
66 require_once( "$IP/includes/ProxyTools.php" );
67 require_once( "$IP/includes/ObjectCache.php" );
68 require_once( "$IP/includes/ImageFunctions.php" );
69 require_once( "$IP/includes/StubObject.php" );
70 wfProfileOut( $fname.'-includes' );
71 wfProfileIn( $fname.'-misc1' );
72
73
74 $wgIP = false; # Load on demand
75 # Can't stub this one, it sets up $_GET and $_REQUEST in its constructor
76 $wgRequest = new WebRequest;
77 if ( function_exists( 'posix_uname' ) ) {
78 $wguname = posix_uname();
79 $wgNodeName = $wguname['nodename'];
80 } else {
81 $wgNodeName = '';
82 }
83
84 # Useful debug output
85 if ( $wgCommandLineMode ) {
86 wfDebug( "\n\nStart command line script $self\n" );
87 } elseif ( function_exists( 'getallheaders' ) ) {
88 wfDebug( "\n\nStart request\n" );
89 wfDebug( $_SERVER['REQUEST_METHOD'] . ' ' . $_SERVER['REQUEST_URI'] . "\n" );
90 $headers = getallheaders();
91 foreach ($headers as $name => $value) {
92 wfDebug( "$name: $value\n" );
93 }
94 wfDebug( "\n" );
95 } elseif( isset( $_SERVER['REQUEST_URI'] ) ) {
96 wfDebug( $_SERVER['REQUEST_METHOD'] . ' ' . $_SERVER['REQUEST_URI'] . "\n" );
97 }
98
99 if ( $wgSkipSkin ) {
100 $wgSkipSkins[] = $wgSkipSkin;
101 }
102
103 $wgUseEnotif = $wgEnotifUserTalk || $wgEnotifWatchlist;
104
105 if($wgMetaNamespace === FALSE) {
106 $wgMetaNamespace = str_replace( ' ', '_', $wgSitename );
107 }
108
109 # These are now the same, always
110 # To determine the user language, use $wgLang->getCode()
111 $wgContLanguageCode = $wgLanguageCode;
112
113 wfProfileOut( $fname.'-misc1' );
114 wfProfileIn( $fname.'-memcached' );
115
116 $wgMemc =& wfGetMainCache();
117 $messageMemc =& wfGetMessageCacheStorage();
118 $parserMemc =& wfGetParserCacheStorage();
119
120 wfDebug( 'Main cache: ' . get_class( $wgMemc ) .
121 "\nMessage cache: " . get_class( $messageMemc ) .
122 "\nParser cache: " . get_class( $parserMemc ) . "\n" );
123
124 wfProfileOut( $fname.'-memcached' );
125 wfProfileIn( $fname.'-SetupSession' );
126
127 if ( $wgDBprefix ) {
128 $wgCookiePrefix = $wgDBname . '_' . $wgDBprefix;
129 } elseif ( $wgSharedDB ) {
130 $wgCookiePrefix = $wgSharedDB;
131 } else {
132 $wgCookiePrefix = $wgDBname;
133 }
134
135 # If session.auto_start is there, we can't touch session name
136 #
137 if( !ini_get( 'session.auto_start' ) )
138 session_name( $wgSessionName ? $wgSessionName : $wgCookiePrefix . '_session' );
139
140 if( !$wgCommandLineMode && ( isset( $_COOKIE[session_name()] ) || isset( $_COOKIE[$wgCookiePrefix.'Token'] ) ) ) {
141 wfIncrStats( 'request_with_session' );
142 wfSetupSession();
143 $wgSessionStarted = true;
144 } else {
145 wfIncrStats( 'request_without_session' );
146 $wgSessionStarted = false;
147 }
148
149 wfProfileOut( $fname.'-SetupSession' );
150 wfProfileIn( $fname.'-globals' );
151
152 if ( !$wgDBservers ) {
153 $wgDBservers = array(array(
154 'host' => $wgDBserver,
155 'user' => $wgDBuser,
156 'password' => $wgDBpassword,
157 'dbname' => $wgDBname,
158 'type' => $wgDBtype,
159 'load' => 1,
160 'flags' => ($wgDebugDumpSql ? DBO_DEBUG : 0) | DBO_DEFAULT
161 ));
162 }
163
164 $wgLoadBalancer = new StubObject( 'wgLoadBalancer', 'LoadBalancer',
165 array( $wgDBservers, false, $wgMasterWaitTimeout, true ) );
166 $wgContLang = new StubContLang;
167 $wgUser = new StubUser;
168 $wgLang = new StubUserLang;
169 $wgOut = new StubObject( 'wgOut', 'OutputPage' );
170 $wgParser = new StubObject( 'wgParser', 'Parser' );
171 $wgMessageCache = new StubObject( 'wgMessageCache', 'MessageCache',
172 array( $parserMemc, $wgUseDatabaseMessages, $wgMsgCacheExpiry, wfWikiID() ) );
173
174 wfProfileOut( $fname.'-globals' );
175 wfProfileIn( $fname.'-User' );
176
177 # Skin setup functions
178 # Entries can be added to this variable during the inclusion
179 # of the extension file. Skins can then perform any necessary initialisation.
180 #
181 foreach ( $wgSkinExtensionFunctions as $func ) {
182 call_user_func( $func );
183 }
184
185 if( !is_object( $wgAuth ) ) {
186 $wgAuth = new StubObject( 'wgAuth', 'AuthPlugin' );
187 wfRunHooks( 'AuthPluginSetup', array( &$wgAuth ) );
188 }
189
190 wfProfileOut( $fname.'-User' );
191
192 wfProfileIn( $fname.'-misc2' );
193
194 $wgDeferredUpdateList = array();
195 $wgPostCommitUpdateList = array();
196
197 if ( $wgAjaxSearch ) $wgAjaxExportList[] = 'wfSajaxSearch';
198 if ( $wgAjaxWatch ) $wgAjaxExportList[] = 'wfAjaxWatch';
199
200 wfSeedRandom();
201
202 # Placeholders in case of DB error
203 $wgTitle = null;
204 $wgArticle = null;
205
206 wfProfileOut( $fname.'-misc2' );
207 wfProfileIn( $fname.'-extensions' );
208
209 # Extension setup functions for extensions other than skins
210 # Entries should be added to this variable during the inclusion
211 # of the extension file. This allows the extension to perform
212 # any necessary initialisation in the fully initialised environment
213 foreach ( $wgExtensionFunctions as $func ) {
214 $profName = $fname.'-extensions-'.strval( $func );
215 wfProfileIn( $profName );
216 call_user_func( $func );
217 wfProfileOut( $profName );
218 }
219
220 // For compatibility
221 wfRunHooks( 'LogPageValidTypes', array( &$wgLogTypes ) );
222 wfRunHooks( 'LogPageLogName', array( &$wgLogNames ) );
223 wfRunHooks( 'LogPageLogHeader', array( &$wgLogHeaders ) );
224 wfRunHooks( 'LogPageActionText', array( &$wgLogActions ) );
225
226
227 wfDebug( "Fully initialised\n" );
228 $wgFullyInitialised = true;
229 wfProfileOut( $fname.'-extensions' );
230 wfProfileOut( $fname );
231
232 ?>