3 * Include most things that's need to customize the site
8 * This file is not a valid entry point, perform no further processing unless
11 if( !defined( 'MEDIAWIKI' ) ) {
12 echo "This file is part of MediaWiki, it is not a valid entry point.\n";
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.
23 wfProfileIn( $fname );
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";
31 // Set various default paths sensibly...
32 if( $wgScript === false ) $wgScript = "$wgScriptPath/index.php";
33 if( $wgRedirectScript === false ) $wgRedirectScript = "$wgScriptPath/redirect.php";
35 if( $wgArticlePath === false ) {
36 if( $wgUsePathInfo ) {
37 $wgArticlePath = "$wgScript/$1";
39 $wgArticlePath = "$wgScript?title=$1";
43 if( $wgStylePath === false ) $wgStylePath = "$wgScriptPath/skins";
44 if( $wgStyleDirectory === false) $wgStyleDirectory = "$IP/skins";
46 if( $wgLogo === false ) $wgLogo = "$wgStylePath/common/images/wiki.png";
48 if( $wgUploadPath === false ) $wgUploadPath = "$wgScriptPath/images";
49 if( $wgUploadDirectory === false ) $wgUploadDirectory = "$IP/images";
51 if( $wgMathPath === false ) $wgMathPath = "{$wgUploadPath}/math";
52 if( $wgMathDirectory === false ) $wgMathDirectory = "{$wgUploadDirectory}/math";
53 if( $wgTmpDirectory === false ) $wgTmpDirectory = "{$wgUploadDirectory}/tmp";
55 if( $wgReadOnlyFile === false ) $wgReadOnlyFile = "{$wgUploadDirectory}/lock_yBgMBwiR";
56 if( $wgFileCacheDirectory === false ) $wgFileCacheDirectory = "{$wgUploadDirectory}/cache";
58 require_once( "$IP/includes/AutoLoader.php" );
60 wfProfileIn( $fname.'-exception' );
61 require_once( "$IP/includes/Exception.php" );
62 wfInstallExceptionHandler();
63 wfProfileOut( $fname.'-exception' );
65 wfProfileIn( $fname.'-includes' );
66 require_once( "$IP/includes/GlobalFunctions.php" );
67 require_once( "$IP/includes/Hooks.php" );
68 require_once( "$IP/includes/Namespace.php" );
69 require_once( "$IP/includes/ProxyTools.php" );
70 require_once( "$IP/includes/ObjectCache.php" );
71 require_once( "$IP/includes/ImageFunctions.php" );
72 require_once( "$IP/includes/StubObject.php" );
73 wfProfileOut( $fname.'-includes' );
74 wfProfileIn( $fname.'-misc1' );
77 $wgIP = false; # Load on demand
78 # Can't stub this one, it sets up $_GET and $_REQUEST in its constructor
79 $wgRequest = new WebRequest
;
80 if ( function_exists( 'posix_uname' ) ) {
81 $wguname = posix_uname();
82 $wgNodeName = $wguname['nodename'];
88 if ( $wgCommandLineMode ) {
89 wfDebug( "\n\nStart command line script $self\n" );
90 } elseif ( function_exists( 'getallheaders' ) ) {
91 wfDebug( "\n\nStart request\n" );
92 wfDebug( $_SERVER['REQUEST_METHOD'] . ' ' . $_SERVER['REQUEST_URI'] . "\n" );
93 $headers = getallheaders();
94 foreach ($headers as $name => $value) {
95 wfDebug( "$name: $value\n" );
98 } elseif( isset( $_SERVER['REQUEST_URI'] ) ) {
99 wfDebug( $_SERVER['REQUEST_METHOD'] . ' ' . $_SERVER['REQUEST_URI'] . "\n" );
103 $wgSkipSkins[] = $wgSkipSkin;
106 $wgUseEnotif = $wgEnotifUserTalk ||
$wgEnotifWatchlist;
108 if($wgMetaNamespace === FALSE) {
109 $wgMetaNamespace = str_replace( ' ', '_', $wgSitename );
112 # These are now the same, always
113 # To determine the user language, use $wgLang->getCode()
114 $wgContLanguageCode = $wgLanguageCode;
116 wfProfileOut( $fname.'-misc1' );
117 wfProfileIn( $fname.'-memcached' );
119 $wgMemc =& wfGetMainCache();
120 $messageMemc =& wfGetMessageCacheStorage();
121 $parserMemc =& wfGetParserCacheStorage();
123 wfDebug( 'Main cache: ' . get_class( $wgMemc ) .
124 "\nMessage cache: " . get_class( $messageMemc ) .
125 "\nParser cache: " . get_class( $parserMemc ) . "\n" );
127 wfProfileOut( $fname.'-memcached' );
128 wfProfileIn( $fname.'-SetupSession' );
131 $wgCookiePrefix = $wgDBname . '_' . $wgDBprefix;
132 } elseif ( $wgSharedDB ) {
133 $wgCookiePrefix = $wgSharedDB;
135 $wgCookiePrefix = $wgDBname;
138 # If session.auto_start is there, we can't touch session name
140 if( !ini_get( 'session.auto_start' ) )
141 session_name( $wgSessionName ?
$wgSessionName : $wgCookiePrefix . '_session' );
143 if( !$wgCommandLineMode && ( isset( $_COOKIE[session_name()] ) ||
isset( $_COOKIE[$wgCookiePrefix.'Token'] ) ) ) {
144 wfIncrStats( 'request_with_session' );
146 $wgSessionStarted = true;
148 wfIncrStats( 'request_without_session' );
149 $wgSessionStarted = false;
152 wfProfileOut( $fname.'-SetupSession' );
153 wfProfileIn( $fname.'-globals' );
155 if ( !$wgDBservers ) {
156 $wgDBservers = array(array(
157 'host' => $wgDBserver,
159 'password' => $wgDBpassword,
160 'dbname' => $wgDBname,
163 'flags' => ($wgDebugDumpSql ? DBO_DEBUG
: 0) | DBO_DEFAULT
167 $wgLoadBalancer = new StubObject( 'wgLoadBalancer', 'LoadBalancer',
168 array( $wgDBservers, false, $wgMasterWaitTimeout, true ) );
169 $wgContLang = new StubContLang
;
170 $wgUser = new StubUser
;
171 $wgLang = new StubUserLang
;
172 $wgOut = new StubObject( 'wgOut', 'OutputPage' );
173 $wgParser = new StubObject( 'wgParser', 'Parser' );
174 $wgMessageCache = new StubObject( 'wgMessageCache', 'MessageCache',
175 array( $parserMemc, $wgUseDatabaseMessages, $wgMsgCacheExpiry, wfWikiID() ) );
177 wfProfileOut( $fname.'-globals' );
178 wfProfileIn( $fname.'-User' );
180 # Skin setup functions
181 # Entries can be added to this variable during the inclusion
182 # of the extension file. Skins can then perform any necessary initialisation.
184 foreach ( $wgSkinExtensionFunctions as $func ) {
185 call_user_func( $func );
188 if( !is_object( $wgAuth ) ) {
189 $wgAuth = new StubObject( 'wgAuth', 'AuthPlugin' );
190 wfRunHooks( 'AuthPluginSetup', array( &$wgAuth ) );
193 wfProfileOut( $fname.'-User' );
195 wfProfileIn( $fname.'-misc2' );
197 $wgDeferredUpdateList = array();
198 $wgPostCommitUpdateList = array();
200 if ( $wgAjaxSearch ) $wgAjaxExportList[] = 'wfSajaxSearch';
201 if ( $wgAjaxWatch ) $wgAjaxExportList[] = 'wfAjaxWatch';
205 # Placeholders in case of DB error
209 wfProfileOut( $fname.'-misc2' );
210 wfProfileIn( $fname.'-extensions' );
212 # Extension setup functions for extensions other than skins
213 # Entries should be added to this variable during the inclusion
214 # of the extension file. This allows the extension to perform
215 # any necessary initialisation in the fully initialised environment
216 foreach ( $wgExtensionFunctions as $func ) {
217 $profName = $fname.'-extensions-'.strval( $func );
218 wfProfileIn( $profName );
219 call_user_func( $func );
220 wfProfileOut( $profName );
224 wfRunHooks( 'LogPageValidTypes', array( &$wgLogTypes ) );
225 wfRunHooks( 'LogPageLogName', array( &$wgLogNames ) );
226 wfRunHooks( 'LogPageLogHeader', array( &$wgLogHeaders ) );
227 wfRunHooks( 'LogPageActionText', array( &$wgLogActions ) );
230 wfDebug( "Fully initialised\n" );
231 $wgFullyInitialised = true;
232 wfProfileOut( $fname.'-extensions' );
233 wfProfileOut( $fname );