Quotation marks missed. Thanks to Shinjiman.
[mediawiki.git] / includes / Setup.php
blobeaffbe1e5a3ec30ecff05737b4dc76a54e4da5e8
1 <?php
2 /**
3 * Include most things that's need to customize the site
4 */
6 /**
7 * This file is not a valid entry point, perform no further processing unless
8 * MEDIAWIKI is defined
9 */
10 if( !defined( 'MEDIAWIKI' ) ) {
11 echo "This file is part of MediaWiki, it is not a valid entry point.\n";
12 exit( 1 );
15 # The main wiki script and things like database
16 # conversion and maintenance scripts all share a
17 # common setup of including lots of classes and
18 # setting up a few globals.
21 $fname = 'Setup.php';
22 wfProfileIn( $fname );
24 // Check to see if we are at the file scope
25 if ( !isset( $wgVersion ) ) {
26 echo "Error, Setup.php must be included from the file scope, after DefaultSettings.php\n";
27 die( 1 );
30 // Set various default paths sensibly...
31 if( $wgScript === false ) $wgScript = "$wgScriptPath/index.php";
32 if( $wgRedirectScript === false ) $wgRedirectScript = "$wgScriptPath/redirect.php";
34 if( $wgArticlePath === false ) {
35 if( $wgUsePathInfo ) {
36 $wgArticlePath = "$wgScript/$1";
37 } else {
38 $wgArticlePath = "$wgScript?title=$1";
42 if( $wgStylePath === false ) $wgStylePath = "$wgScriptPath/skins";
43 if( $wgStyleDirectory === false) $wgStyleDirectory = "$IP/skins";
45 if( $wgLogo === false ) $wgLogo = "$wgStylePath/common/images/wiki.png";
47 if( $wgUploadPath === false ) $wgUploadPath = "$wgScriptPath/images";
48 if( $wgUploadDirectory === false ) $wgUploadDirectory = "$IP/images";
50 if( $wgMathPath === false ) $wgMathPath = "{$wgUploadPath}/math";
51 if( $wgMathDirectory === false ) $wgMathDirectory = "{$wgUploadDirectory}/math";
52 if( $wgTmpDirectory === false ) $wgTmpDirectory = "{$wgUploadDirectory}/tmp";
54 if( $wgReadOnlyFile === false ) $wgReadOnlyFile = "{$wgUploadDirectory}/lock_yBgMBwiR";
55 if( $wgFileCacheDirectory === false ) $wgFileCacheDirectory = "{$wgUploadDirectory}/cache";
57 require_once( "$IP/includes/AutoLoader.php" );
59 wfProfileIn( $fname.'-exception' );
60 require_once( "$IP/includes/Exception.php" );
61 wfInstallExceptionHandler();
62 wfProfileOut( $fname.'-exception' );
64 wfProfileIn( $fname.'-includes' );
65 require_once( "$IP/includes/GlobalFunctions.php" );
66 require_once( "$IP/includes/Hooks.php" );
67 require_once( "$IP/includes/Namespace.php" );
68 require_once( "$IP/includes/ProxyTools.php" );
69 require_once( "$IP/includes/ObjectCache.php" );
70 require_once( "$IP/includes/ImageFunctions.php" );
71 require_once( "$IP/includes/StubObject.php" );
72 wfProfileOut( $fname.'-includes' );
73 wfProfileIn( $fname.'-misc1' );
76 $wgIP = false; # Load on demand
77 # Can't stub this one, it sets up $_GET and $_REQUEST in its constructor
78 $wgRequest = new WebRequest;
79 if ( function_exists( 'posix_uname' ) ) {
80 $wguname = posix_uname();
81 $wgNodeName = $wguname['nodename'];
82 } else {
83 $wgNodeName = '';
86 # Useful debug output
87 if ( $wgCommandLineMode ) {
88 wfDebug( "\n\nStart command line script $self\n" );
89 } elseif ( function_exists( 'getallheaders' ) ) {
90 wfDebug( "\n\nStart request\n" );
91 wfDebug( $_SERVER['REQUEST_METHOD'] . ' ' . $_SERVER['REQUEST_URI'] . "\n" );
92 $headers = getallheaders();
93 foreach ($headers as $name => $value) {
94 wfDebug( "$name: $value\n" );
96 wfDebug( "\n" );
97 } elseif( isset( $_SERVER['REQUEST_URI'] ) ) {
98 wfDebug( $_SERVER['REQUEST_METHOD'] . ' ' . $_SERVER['REQUEST_URI'] . "\n" );
101 if ( $wgSkipSkin ) {
102 $wgSkipSkins[] = $wgSkipSkin;
105 $wgUseEnotif = $wgEnotifUserTalk || $wgEnotifWatchlist;
107 if($wgMetaNamespace === FALSE) {
108 $wgMetaNamespace = str_replace( ' ', '_', $wgSitename );
111 # These are now the same, always
112 # To determine the user language, use $wgLang->getCode()
113 $wgContLanguageCode = $wgLanguageCode;
115 wfProfileOut( $fname.'-misc1' );
116 wfProfileIn( $fname.'-memcached' );
118 $wgMemc =& wfGetMainCache();
119 $messageMemc =& wfGetMessageCacheStorage();
120 $parserMemc =& wfGetParserCacheStorage();
122 wfDebug( 'Main cache: ' . get_class( $wgMemc ) .
123 "\nMessage cache: " . get_class( $messageMemc ) .
124 "\nParser cache: " . get_class( $parserMemc ) . "\n" );
126 wfProfileOut( $fname.'-memcached' );
127 wfProfileIn( $fname.'-SetupSession' );
129 if ( $wgDBprefix ) {
130 $wgCookiePrefix = $wgDBname . '_' . $wgDBprefix;
131 } elseif ( $wgSharedDB ) {
132 $wgCookiePrefix = $wgSharedDB;
133 } else {
134 $wgCookiePrefix = $wgDBname;
137 # If session.auto_start is there, we can't touch session name
139 if( !ini_get( 'session.auto_start' ) )
140 session_name( $wgSessionName ? $wgSessionName : $wgCookiePrefix . '_session' );
142 if( !$wgCommandLineMode && ( $wgRequest->checkSessionCookie() || isset( $_COOKIE[$wgCookiePrefix.'Token'] ) ) ) {
143 wfIncrStats( 'request_with_session' );
144 wfSetupSession();
145 $wgSessionStarted = true;
146 } else {
147 wfIncrStats( 'request_without_session' );
148 $wgSessionStarted = false;
151 wfProfileOut( $fname.'-SetupSession' );
152 wfProfileIn( $fname.'-globals' );
154 if ( !$wgDBservers ) {
155 $wgDBservers = array(array(
156 'host' => $wgDBserver,
157 'user' => $wgDBuser,
158 'password' => $wgDBpassword,
159 'dbname' => $wgDBname,
160 'type' => $wgDBtype,
161 'load' => 1,
162 'flags' => ($wgDebugDumpSql ? DBO_DEBUG : 0) | DBO_DEFAULT
166 $wgLoadBalancer = new StubObject( 'wgLoadBalancer', 'LoadBalancer',
167 array( $wgDBservers, false, $wgMasterWaitTimeout, true ) );
168 $wgContLang = new StubContLang;
169 $wgUser = new StubUser;
170 $wgLang = new StubUserLang;
171 $wgOut = new StubObject( 'wgOut', 'OutputPage' );
172 $wgParser = new StubObject( 'wgParser', 'Parser' );
173 $wgMessageCache = new StubObject( 'wgMessageCache', 'MessageCache',
174 array( $parserMemc, $wgUseDatabaseMessages, $wgMsgCacheExpiry, wfWikiID() ) );
176 wfProfileOut( $fname.'-globals' );
177 wfProfileIn( $fname.'-User' );
179 # Skin setup functions
180 # Entries can be added to this variable during the inclusion
181 # of the extension file. Skins can then perform any necessary initialisation.
183 foreach ( $wgSkinExtensionFunctions as $func ) {
184 call_user_func( $func );
187 if( !is_object( $wgAuth ) ) {
188 $wgAuth = new StubObject( 'wgAuth', 'AuthPlugin' );
189 wfRunHooks( 'AuthPluginSetup', array( &$wgAuth ) );
192 wfProfileOut( $fname.'-User' );
194 wfProfileIn( $fname.'-misc2' );
196 $wgDeferredUpdateList = array();
197 $wgPostCommitUpdateList = array();
199 if ( $wgAjaxSearch ) $wgAjaxExportList[] = 'wfSajaxSearch';
200 if ( $wgAjaxWatch ) $wgAjaxExportList[] = 'wfAjaxWatch';
202 wfSeedRandom();
204 # Placeholders in case of DB error
205 $wgTitle = null;
206 $wgArticle = null;
208 wfProfileOut( $fname.'-misc2' );
209 wfProfileIn( $fname.'-extensions' );
211 # Extension setup functions for extensions other than skins
212 # Entries should be added to this variable during the inclusion
213 # of the extension file. This allows the extension to perform
214 # any necessary initialisation in the fully initialised environment
215 foreach ( $wgExtensionFunctions as $func ) {
216 $profName = $fname.'-extensions-'.strval( $func );
217 wfProfileIn( $profName );
218 call_user_func( $func );
219 wfProfileOut( $profName );
222 // For compatibility
223 wfRunHooks( 'LogPageValidTypes', array( &$wgLogTypes ) );
224 wfRunHooks( 'LogPageLogName', array( &$wgLogNames ) );
225 wfRunHooks( 'LogPageLogHeader', array( &$wgLogHeaders ) );
226 wfRunHooks( 'LogPageActionText', array( &$wgLogActions ) );
229 wfDebug( "Fully initialised\n" );
230 $wgFullyInitialised = true;
231 wfProfileOut( $fname.'-extensions' );
232 wfProfileOut( $fname );