Use Doxygen @addtogroup instead of phpdoc @package && @subpackage
[lhc/web/wiklou.git] / includes / Setup.php
1 <?php
2 /**
3 * Include most things that's need to customize the site
4 */
5
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 );
13 }
14
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.
19 #
20
21 $fname = 'Setup.php';
22 wfProfileIn( $fname );
23
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 );
28 }
29
30 // Set various default paths sensibly...
31 if( $wgScript === false ) $wgScript = "$wgScriptPath/index.php";
32 if( $wgRedirectScript === false ) $wgRedirectScript = "$wgScriptPath/redirect.php";
33
34 if( $wgArticlePath === false ) {
35 if( $wgUsePathInfo ) {
36 $wgArticlePath = "$wgScript/$1";
37 } else {
38 $wgArticlePath = "$wgScript?title=$1";
39 }
40 }
41
42 if( $wgStylePath === false ) $wgStylePath = "$wgScriptPath/skins";
43 if( $wgStyleDirectory === false) $wgStyleDirectory = "$IP/skins";
44
45 if( $wgLogo === false ) $wgLogo = "$wgStylePath/common/images/wiki.png";
46
47 if( $wgUploadPath === false ) $wgUploadPath = "$wgScriptPath/images";
48 if( $wgUploadDirectory === false ) $wgUploadDirectory = "$IP/images";
49
50 if( $wgMathPath === false ) $wgMathPath = "{$wgUploadPath}/math";
51 if( $wgMathDirectory === false ) $wgMathDirectory = "{$wgUploadDirectory}/math";
52 if( $wgTmpDirectory === false ) $wgTmpDirectory = "{$wgUploadDirectory}/tmp";
53
54 if( $wgReadOnlyFile === false ) $wgReadOnlyFile = "{$wgUploadDirectory}/lock_yBgMBwiR";
55 if( $wgFileCacheDirectory === false ) $wgFileCacheDirectory = "{$wgUploadDirectory}/cache";
56
57 require_once( "$IP/includes/AutoLoader.php" );
58
59 wfProfileIn( $fname.'-exception' );
60 require_once( "$IP/includes/Exception.php" );
61 wfInstallExceptionHandler();
62 wfProfileOut( $fname.'-exception' );
63
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' );
74
75
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 = '';
84 }
85
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" );
95 }
96 wfDebug( "\n" );
97 } elseif( isset( $_SERVER['REQUEST_URI'] ) ) {
98 wfDebug( $_SERVER['REQUEST_METHOD'] . ' ' . $_SERVER['REQUEST_URI'] . "\n" );
99 }
100
101 if ( $wgSkipSkin ) {
102 $wgSkipSkins[] = $wgSkipSkin;
103 }
104
105 $wgUseEnotif = $wgEnotifUserTalk || $wgEnotifWatchlist;
106
107 if($wgMetaNamespace === FALSE) {
108 $wgMetaNamespace = str_replace( ' ', '_', $wgSitename );
109 }
110
111 # These are now the same, always
112 # To determine the user language, use $wgLang->getCode()
113 $wgContLanguageCode = $wgLanguageCode;
114
115 wfProfileOut( $fname.'-misc1' );
116 wfProfileIn( $fname.'-memcached' );
117
118 $wgMemc =& wfGetMainCache();
119 $messageMemc =& wfGetMessageCacheStorage();
120 $parserMemc =& wfGetParserCacheStorage();
121
122 wfDebug( 'Main cache: ' . get_class( $wgMemc ) .
123 "\nMessage cache: " . get_class( $messageMemc ) .
124 "\nParser cache: " . get_class( $parserMemc ) . "\n" );
125
126 wfProfileOut( $fname.'-memcached' );
127 wfProfileIn( $fname.'-SetupSession' );
128
129 if ( $wgDBprefix ) {
130 $wgCookiePrefix = $wgDBname . '_' . $wgDBprefix;
131 } elseif ( $wgSharedDB ) {
132 $wgCookiePrefix = $wgSharedDB;
133 } else {
134 $wgCookiePrefix = $wgDBname;
135 }
136
137 # If session.auto_start is there, we can't touch session name
138 #
139 if( !ini_get( 'session.auto_start' ) )
140 session_name( $wgSessionName ? $wgSessionName : $wgCookiePrefix . '_session' );
141
142 if( !$wgCommandLineMode && ( isset( $_COOKIE[session_name()] ) || isset( $_COOKIE[$wgCookiePrefix.'Token'] ) ) ) {
143 wfIncrStats( 'request_with_session' );
144 wfSetupSession();
145 $wgSessionStarted = true;
146 } else {
147 wfIncrStats( 'request_without_session' );
148 $wgSessionStarted = false;
149 }
150
151 wfProfileOut( $fname.'-SetupSession' );
152 wfProfileIn( $fname.'-globals' );
153
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
163 ));
164 }
165
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() ) );
175
176 wfProfileOut( $fname.'-globals' );
177 wfProfileIn( $fname.'-User' );
178
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.
182 #
183 foreach ( $wgSkinExtensionFunctions as $func ) {
184 call_user_func( $func );
185 }
186
187 if( !is_object( $wgAuth ) ) {
188 $wgAuth = new StubObject( 'wgAuth', 'AuthPlugin' );
189 wfRunHooks( 'AuthPluginSetup', array( &$wgAuth ) );
190 }
191
192 wfProfileOut( $fname.'-User' );
193
194 wfProfileIn( $fname.'-misc2' );
195
196 $wgDeferredUpdateList = array();
197 $wgPostCommitUpdateList = array();
198
199 if ( $wgAjaxSearch ) $wgAjaxExportList[] = 'wfSajaxSearch';
200 if ( $wgAjaxWatch ) $wgAjaxExportList[] = 'wfAjaxWatch';
201
202 wfSeedRandom();
203
204 # Placeholders in case of DB error
205 $wgTitle = null;
206 $wgArticle = null;
207
208 wfProfileOut( $fname.'-misc2' );
209 wfProfileIn( $fname.'-extensions' );
210
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 );
220 }
221
222 // For compatibility
223 wfRunHooks( 'LogPageValidTypes', array( &$wgLogTypes ) );
224 wfRunHooks( 'LogPageLogName', array( &$wgLogNames ) );
225 wfRunHooks( 'LogPageLogHeader', array( &$wgLogHeaders ) );
226 wfRunHooks( 'LogPageActionText', array( &$wgLogActions ) );
227
228
229 wfDebug( "Fully initialised\n" );
230 $wgFullyInitialised = true;
231 wfProfileOut( $fname.'-extensions' );
232 wfProfileOut( $fname );
233
234 ?>