Merged localisation-work branch:
[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 wfProfileOut( $fname.'-misc1' );
86 wfProfileIn( $fname.'-memcached' );
87
88 $wgMemc =& wfGetMainCache();
89 $messageMemc =& wfGetMessageCacheStorage();
90 $parserMemc =& wfGetParserCacheStorage();
91
92 wfDebug( 'Main cache: ' . get_class( $wgMemc ) .
93 "\nMessage cache: " . get_class( $messageMemc ) .
94 "\nParser cache: " . get_class( $parserMemc ) . "\n" );
95
96 wfProfileOut( $fname.'-memcached' );
97 wfProfileIn( $fname.'-SetupSession' );
98
99 if ( $wgDBprefix ) {
100 $wgCookiePrefix = $wgDBname . '_' . $wgDBprefix;
101 } elseif ( $wgSharedDB ) {
102 $wgCookiePrefix = $wgSharedDB;
103 } else {
104 $wgCookiePrefix = $wgDBname;
105 }
106
107 # If session.auto_start is there, we can't touch session name
108 #
109 if( !ini_get( 'session.auto_start' ) )
110 session_name( $wgSessionName ? $wgSessionName : $wgCookiePrefix . '_session' );
111
112 if( !$wgCommandLineMode && ( isset( $_COOKIE[session_name()] ) || isset( $_COOKIE[$wgCookiePrefix.'Token'] ) ) ) {
113 wfIncrStats( 'request_with_session' );
114 wfSetupSession();
115 $wgSessionStarted = true;
116 } else {
117 wfIncrStats( 'request_without_session' );
118 $wgSessionStarted = false;
119 }
120
121 wfProfileOut( $fname.'-SetupSession' );
122 wfProfileIn( $fname.'-globals' );
123
124 if ( !$wgDBservers ) {
125 $wgDBservers = array(array(
126 'host' => $wgDBserver,
127 'user' => $wgDBuser,
128 'password' => $wgDBpassword,
129 'dbname' => $wgDBname,
130 'type' => $wgDBtype,
131 'load' => 1,
132 'flags' => ($wgDebugDumpSql ? DBO_DEBUG : 0) | DBO_DEFAULT
133 ));
134 }
135
136 # $wgLanguageCode may be changed later to fit with user preference.
137 # The content language will remain fixed as per the configuration,
138 # so let's keep it.
139 $wgContLanguageCode = $wgLanguageCode;
140
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) );
150
151 wfProfileOut( $fname.'-globals' );
152 wfProfileIn( $fname.'-User' );
153
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.
157 #
158 foreach ( $wgSkinExtensionFunctions as $func ) {
159 call_user_func( $func );
160 }
161
162 if( !is_object( $wgAuth ) ) {
163 $wgAuth = new StubObject( 'wgAuth', 'AuthPlugin' );
164 }
165 wfProfileOut( $fname.'-User' );
166
167 wfProfileIn( $fname.'-misc2' );
168
169 $wgDeferredUpdateList = array();
170 $wgPostCommitUpdateList = array();
171
172 wfSeedRandom();
173
174 # Placeholders in case of DB error
175 $wgTitle = null;
176 $wgArticle = null;
177
178 wfProfileOut( $fname.'-misc2' );
179 wfProfileIn( $fname.'-extensions' );
180
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 );
187 }
188
189 // For compatibility
190 wfRunHooks( 'LogPageValidTypes', array( &$wgLogTypes ) );
191 wfRunHooks( 'LogPageLogName', array( &$wgLogNames ) );
192 wfRunHooks( 'LogPageLogHeader', array( &$wgLogHeaders ) );
193 wfRunHooks( 'LogPageActionText', array( &$wgLogActions ) );
194
195
196 wfDebug( "Fully initialised\n" );
197 $wgFullyInitialised = true;
198 wfProfileOut( $fname.'-extensions' );
199 wfProfileOut( $fname );
200
201 ?>