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 require_once( "$IP/includes/AutoLoader.php" );
33 wfProfileIn( $fname.'-exception' );
34 require_once( "$IP/includes/Exception.php" );
35 wfInstallExceptionHandler();
36 wfProfileOut( $fname.'-exception' );
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' );
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'];
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" );
71 } elseif( isset( $_SERVER['REQUEST_URI'] ) ) {
72 wfDebug( $_SERVER['REQUEST_METHOD'] . ' ' . $_SERVER['REQUEST_URI'] . "\n" );
76 $wgSkipSkins[] = $wgSkipSkin;
79 $wgUseEnotif = $wgEnotifUserTalk ||
$wgEnotifWatchlist;
81 if($wgMetaNamespace === FALSE) {
82 $wgMetaNamespace = str_replace( ' ', '_', $wgSitename );
85 wfProfileOut( $fname.'-misc1' );
86 wfProfileIn( $fname.'-memcached' );
88 $wgMemc =& wfGetMainCache();
89 $messageMemc =& wfGetMessageCacheStorage();
90 $parserMemc =& wfGetParserCacheStorage();
92 wfDebug( 'Main cache: ' . get_class( $wgMemc ) .
93 "\nMessage cache: " . get_class( $messageMemc ) .
94 "\nParser cache: " . get_class( $parserMemc ) . "\n" );
96 wfProfileOut( $fname.'-memcached' );
97 wfProfileIn( $fname.'-SetupSession' );
100 $wgCookiePrefix = $wgDBname . '_' . $wgDBprefix;
101 } elseif ( $wgSharedDB ) {
102 $wgCookiePrefix = $wgSharedDB;
104 $wgCookiePrefix = $wgDBname;
107 # If session.auto_start is there, we can't touch session name
109 if( !ini_get( 'session.auto_start' ) )
110 session_name( $wgSessionName ?
$wgSessionName : $wgCookiePrefix . '_session' );
112 if( !$wgCommandLineMode && ( isset( $_COOKIE[session_name()] ) ||
isset( $_COOKIE[$wgCookiePrefix.'Token'] ) ) ) {
113 wfIncrStats( 'request_with_session' );
115 $wgSessionStarted = true;
117 wfIncrStats( 'request_without_session' );
118 $wgSessionStarted = false;
121 wfProfileOut( $fname.'-SetupSession' );
122 wfProfileIn( $fname.'-globals' );
124 if ( !$wgDBservers ) {
125 $wgDBservers = array(array(
126 'host' => $wgDBserver,
128 'password' => $wgDBpassword,
129 'dbname' => $wgDBname,
132 'flags' => ($wgDebugDumpSql ? DBO_DEBUG
: 0) | DBO_DEFAULT
136 # $wgLanguageCode may be changed later to fit with user preference.
137 # The content language will remain fixed as per the configuration,
139 $wgContLanguageCode = $wgLanguageCode;
141 $wgLoadBalancer = new StubObject( 'wgLoadBalancer', 'LoadBalancer',
142 array( $wgDBservers, false, $wgMasterWaitTimeout, true ) );
143 $wgContLang = new StubContLang
;
144 $wgUser = new StubUser
;
145 $wgLang = new StubUserLang
;
146 $wgOut = new StubObject( 'wgOut', 'OutputPage' );
147 $wgParser = new StubObject( 'wgParser', 'Parser' );
148 $wgMessageCache = new StubObject( 'wgMessageCache', 'MessageCache',
149 array( $parserMemc, $wgUseDatabaseMessages, $wgMsgCacheExpiry, $wgDBname) );
151 wfProfileOut( $fname.'-globals' );
152 wfProfileIn( $fname.'-User' );
154 # Skin setup functions
155 # Entries can be added to this variable during the inclusion
156 # of the extension file. Skins can then perform any necessary initialisation.
158 foreach ( $wgSkinExtensionFunctions as $func ) {
159 call_user_func( $func );
162 if( !is_object( $wgAuth ) ) {
163 $wgAuth = new StubObject( 'wgAuth', 'AuthPlugin' );
165 wfProfileOut( $fname.'-User' );
167 wfProfileIn( $fname.'-misc2' );
169 $wgDeferredUpdateList = array();
170 $wgPostCommitUpdateList = array();
174 # Placeholders in case of DB error
178 wfProfileOut( $fname.'-misc2' );
179 wfProfileIn( $fname.'-extensions' );
181 # Extension setup functions for extensions other than skins
182 # Entries should be added to this variable during the inclusion
183 # of the extension file. This allows the extension to perform
184 # any necessary initialisation in the fully initialised environment
185 foreach ( $wgExtensionFunctions as $func ) {
186 call_user_func( $func );
190 wfRunHooks( 'LogPageValidTypes', array( &$wgLogTypes ) );
191 wfRunHooks( 'LogPageLogName', array( &$wgLogNames ) );
192 wfRunHooks( 'LogPageLogHeader', array( &$wgLogHeaders ) );
193 wfRunHooks( 'LogPageActionText', array( &$wgLogActions ) );
196 wfDebug( "Fully initialised\n" );
197 $wgFullyInitialised = true;
198 wfProfileOut( $fname.'-extensions' );
199 wfProfileOut( $fname );