Merge "Allow local interwiki links with an empty title part"
[lhc/web/wiklou.git] / includes / Setup.php
1 <?php
2 /**
3 * Include most things that are needed to make %MediaWiki work.
4 *
5 * This file is included by WebStart.php and doMaintenance.php so that both
6 * web and maintenance scripts share a final set up phase to include necessary
7 * files and create global object variables.
8 *
9 * This program is free software; you can redistribute it and/or modify
10 * it under the terms of the GNU General Public License as published by
11 * the Free Software Foundation; either version 2 of the License, or
12 * (at your option) any later version.
13 *
14 * This program is distributed in the hope that it will be useful,
15 * but WITHOUT ANY WARRANTY; without even the implied warranty of
16 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
17 * GNU General Public License for more details.
18 *
19 * You should have received a copy of the GNU General Public License along
20 * with this program; if not, write to the Free Software Foundation, Inc.,
21 * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
22 * http://www.gnu.org/copyleft/gpl.html
23 *
24 * @file
25 */
26
27 /**
28 * This file is not a valid entry point, perform no further processing unless
29 * MEDIAWIKI is defined
30 */
31 if ( !defined( 'MEDIAWIKI' ) ) {
32 exit( 1 );
33 }
34
35 $fname = 'Setup.php';
36 wfProfileIn( $fname );
37 wfProfileIn( $fname . '-defaults' );
38
39 // Check to see if we are at the file scope
40 if ( !isset( $wgVersion ) ) {
41 echo "Error, Setup.php must be included from the file scope, after DefaultSettings.php\n";
42 die( 1 );
43 }
44
45 // Set various default paths sensibly...
46
47 if ( $wgScript === false ) {
48 $wgScript = "$wgScriptPath/index$wgScriptExtension";
49 }
50 if ( $wgLoadScript === false ) {
51 $wgLoadScript = "$wgScriptPath/load$wgScriptExtension";
52 }
53
54 if ( $wgArticlePath === false ) {
55 if ( $wgUsePathInfo ) {
56 $wgArticlePath = "$wgScript/$1";
57 } else {
58 $wgArticlePath = "$wgScript?title=$1";
59 }
60 }
61
62 if ( !empty( $wgActionPaths ) && !isset( $wgActionPaths['view'] ) ) {
63 // 'view' is assumed the default action path everywhere in the code
64 // but is rarely filled in $wgActionPaths
65 $wgActionPaths['view'] = $wgArticlePath;
66 }
67
68 if ( $wgStylePath === false ) {
69 $wgStylePath = "$wgScriptPath/skins";
70 }
71 if ( $wgLocalStylePath === false ) {
72 $wgLocalStylePath = "$wgScriptPath/skins";
73 }
74 if ( $wgStyleDirectory === false ) {
75 $wgStyleDirectory = "$IP/skins";
76 }
77 if ( $wgExtensionAssetsPath === false ) {
78 $wgExtensionAssetsPath = "$wgScriptPath/extensions";
79 }
80
81 // Enable default skins. Temporary, to be removed before 1.24 release.
82 // This is hacky and bad, the require_once calls should eventually be generated by the installer
83 // and placed in LocalSettings.php.
84 // While this is in Setup.php, it needs to be done as soon as possible, as some of the setup code
85 // depends on all extensions and skins being already required (bug 67318).
86 require_once "$wgStyleDirectory/MonoBook/MonoBook.php";
87 require_once "$wgStyleDirectory/Vector/Vector.php";
88
89 if ( $wgLogo === false ) {
90 $wgLogo = "$wgStylePath/common/images/wiki.png";
91 }
92
93 if ( $wgUploadPath === false ) {
94 $wgUploadPath = "$wgScriptPath/images";
95 }
96 if ( $wgUploadDirectory === false ) {
97 $wgUploadDirectory = "$IP/images";
98 }
99 if ( $wgReadOnlyFile === false ) {
100 $wgReadOnlyFile = "{$wgUploadDirectory}/lock_yBgMBwiR";
101 }
102 if ( $wgFileCacheDirectory === false ) {
103 $wgFileCacheDirectory = "{$wgUploadDirectory}/cache";
104 }
105 if ( $wgDeletedDirectory === false ) {
106 $wgDeletedDirectory = "{$wgUploadDirectory}/deleted";
107 }
108
109 if ( isset( $wgFileStore['deleted']['directory'] ) ) {
110 $wgDeletedDirectory = $wgFileStore['deleted']['directory'];
111 }
112
113 if ( isset( $wgFooterIcons['copyright'] )
114 && isset( $wgFooterIcons['copyright']['copyright'] )
115 && $wgFooterIcons['copyright']['copyright'] === array()
116 ) {
117 if ( isset( $wgCopyrightIcon ) && $wgCopyrightIcon ) {
118 $wgFooterIcons['copyright']['copyright'] = $wgCopyrightIcon;
119 } elseif ( $wgRightsIcon || $wgRightsText ) {
120 $wgFooterIcons['copyright']['copyright'] = array(
121 'url' => $wgRightsUrl,
122 'src' => $wgRightsIcon,
123 'alt' => $wgRightsText,
124 );
125 } else {
126 unset( $wgFooterIcons['copyright']['copyright'] );
127 }
128 }
129
130 if ( isset( $wgFooterIcons['poweredby'] )
131 && isset( $wgFooterIcons['poweredby']['mediawiki'] )
132 && $wgFooterIcons['poweredby']['mediawiki']['src'] === null
133 ) {
134 $wgFooterIcons['poweredby']['mediawiki']['src'] =
135 "$wgStylePath/common/images/poweredby_mediawiki_88x31.png";
136 }
137
138 /**
139 * Unconditional protection for NS_MEDIAWIKI since otherwise it's too easy for a
140 * sysadmin to set $wgNamespaceProtection incorrectly and leave the wiki insecure.
141 *
142 * Note that this is the definition of editinterface and it can be granted to
143 * all users if desired.
144 */
145 $wgNamespaceProtection[NS_MEDIAWIKI] = 'editinterface';
146
147 /**
148 * The canonical names of namespaces 6 and 7 are, as of v1.14, "File"
149 * and "File_talk". The old names "Image" and "Image_talk" are
150 * retained as aliases for backwards compatibility.
151 */
152 $wgNamespaceAliases['Image'] = NS_FILE;
153 $wgNamespaceAliases['Image_talk'] = NS_FILE_TALK;
154
155 /**
156 * Initialise $wgLockManagers to include basic FS version
157 */
158 $wgLockManagers[] = array(
159 'name' => 'fsLockManager',
160 'class' => 'FSLockManager',
161 'lockDirectory' => "{$wgUploadDirectory}/lockdir",
162 );
163 $wgLockManagers[] = array(
164 'name' => 'nullLockManager',
165 'class' => 'NullLockManager',
166 );
167
168 /**
169 * Initialise $wgLocalFileRepo from backwards-compatible settings
170 */
171 if ( !$wgLocalFileRepo ) {
172 if ( isset( $wgFileStore['deleted']['hash'] ) ) {
173 $deletedHashLevel = $wgFileStore['deleted']['hash'];
174 } else {
175 $deletedHashLevel = $wgHashedUploadDirectory ? 3 : 0;
176 }
177 $wgLocalFileRepo = array(
178 'class' => 'LocalRepo',
179 'name' => 'local',
180 'directory' => $wgUploadDirectory,
181 'scriptDirUrl' => $wgScriptPath,
182 'scriptExtension' => $wgScriptExtension,
183 'url' => $wgUploadBaseUrl ? $wgUploadBaseUrl . $wgUploadPath : $wgUploadPath,
184 'hashLevels' => $wgHashedUploadDirectory ? 2 : 0,
185 'thumbScriptUrl' => $wgThumbnailScriptPath,
186 'transformVia404' => !$wgGenerateThumbnailOnParse,
187 'deletedDir' => $wgDeletedDirectory,
188 'deletedHashLevels' => $deletedHashLevel
189 );
190 }
191 /**
192 * Initialise shared repo from backwards-compatible settings
193 */
194 if ( $wgUseSharedUploads ) {
195 if ( $wgSharedUploadDBname ) {
196 $wgForeignFileRepos[] = array(
197 'class' => 'ForeignDBRepo',
198 'name' => 'shared',
199 'directory' => $wgSharedUploadDirectory,
200 'url' => $wgSharedUploadPath,
201 'hashLevels' => $wgHashedSharedUploadDirectory ? 2 : 0,
202 'thumbScriptUrl' => $wgSharedThumbnailScriptPath,
203 'transformVia404' => !$wgGenerateThumbnailOnParse,
204 'dbType' => $wgDBtype,
205 'dbServer' => $wgDBserver,
206 'dbUser' => $wgDBuser,
207 'dbPassword' => $wgDBpassword,
208 'dbName' => $wgSharedUploadDBname,
209 'dbFlags' => ( $wgDebugDumpSql ? DBO_DEBUG : 0 ) | DBO_DEFAULT,
210 'tablePrefix' => $wgSharedUploadDBprefix,
211 'hasSharedCache' => $wgCacheSharedUploads,
212 'descBaseUrl' => $wgRepositoryBaseUrl,
213 'fetchDescription' => $wgFetchCommonsDescriptions,
214 );
215 } else {
216 $wgForeignFileRepos[] = array(
217 'class' => 'FileRepo',
218 'name' => 'shared',
219 'directory' => $wgSharedUploadDirectory,
220 'url' => $wgSharedUploadPath,
221 'hashLevels' => $wgHashedSharedUploadDirectory ? 2 : 0,
222 'thumbScriptUrl' => $wgSharedThumbnailScriptPath,
223 'transformVia404' => !$wgGenerateThumbnailOnParse,
224 'descBaseUrl' => $wgRepositoryBaseUrl,
225 'fetchDescription' => $wgFetchCommonsDescriptions,
226 );
227 }
228 }
229 if ( $wgUseInstantCommons ) {
230 $wgForeignFileRepos[] = array(
231 'class' => 'ForeignAPIRepo',
232 'name' => 'wikimediacommons',
233 'apibase' => WebRequest::detectProtocol() === 'https' ?
234 'https://commons.wikimedia.org/w/api.php' :
235 'http://commons.wikimedia.org/w/api.php',
236 'hashLevels' => 2,
237 'fetchDescription' => true,
238 'descriptionCacheExpiry' => 43200,
239 'apiThumbCacheExpiry' => 86400,
240 );
241 }
242 /*
243 * Add on default file backend config for file repos.
244 * FileBackendGroup will handle initializing the backends.
245 */
246 if ( !isset( $wgLocalFileRepo['backend'] ) ) {
247 $wgLocalFileRepo['backend'] = $wgLocalFileRepo['name'] . '-backend';
248 }
249 foreach ( $wgForeignFileRepos as &$repo ) {
250 if ( !isset( $repo['directory'] ) && $repo['class'] === 'ForeignAPIRepo' ) {
251 $repo['directory'] = $wgUploadDirectory; // b/c
252 }
253 if ( !isset( $repo['backend'] ) ) {
254 $repo['backend'] = $repo['name'] . '-backend';
255 }
256 }
257 unset( $repo ); // no global pollution; destroy reference
258
259 if ( $wgRCFilterByAge ) {
260 // Trim down $wgRCLinkDays so that it only lists links which are valid
261 // as determined by $wgRCMaxAge.
262 // Note that we allow 1 link higher than the max for things like 56 days but a 60 day link.
263 sort( $wgRCLinkDays );
264
265 // @codingStandardsIgnoreStart Generic.CodeAnalysis.ForLoopWithTestFunctionCall.NotAllowed
266 for ( $i = 0; $i < count( $wgRCLinkDays ); $i++ ) {
267 // @codingStandardsIgnoreEnd
268 if ( $wgRCLinkDays[$i] >= $wgRCMaxAge / ( 3600 * 24 ) ) {
269 $wgRCLinkDays = array_slice( $wgRCLinkDays, 0, $i + 1, false );
270 break;
271 }
272 }
273 }
274
275 if ( $wgSkipSkin ) {
276 $wgSkipSkins[] = $wgSkipSkin;
277 }
278
279 if ( $wgLocalInterwiki ) {
280 array_unshift( $wgLocalInterwikis, $wgLocalInterwiki );
281 }
282
283 // Set default shared prefix
284 if ( $wgSharedPrefix === false ) {
285 $wgSharedPrefix = $wgDBprefix;
286 }
287
288 if ( !$wgCookiePrefix ) {
289 if ( $wgSharedDB && $wgSharedPrefix && in_array( 'user', $wgSharedTables ) ) {
290 $wgCookiePrefix = $wgSharedDB . '_' . $wgSharedPrefix;
291 } elseif ( $wgSharedDB && in_array( 'user', $wgSharedTables ) ) {
292 $wgCookiePrefix = $wgSharedDB;
293 } elseif ( $wgDBprefix ) {
294 $wgCookiePrefix = $wgDBname . '_' . $wgDBprefix;
295 } else {
296 $wgCookiePrefix = $wgDBname;
297 }
298 }
299 $wgCookiePrefix = strtr( $wgCookiePrefix, '=,; +."\'\\[', '__________' );
300
301 $wgUseEnotif = $wgEnotifUserTalk || $wgEnotifWatchlist;
302
303 if ( $wgMetaNamespace === false ) {
304 $wgMetaNamespace = str_replace( ' ', '_', $wgSitename );
305 }
306
307 // Default value is either the suhosin limit or -1 for unlimited
308 if ( $wgResourceLoaderMaxQueryLength === false ) {
309 $maxValueLength = ini_get( 'suhosin.get.max_value_length' );
310 $wgResourceLoaderMaxQueryLength = $maxValueLength > 0 ? $maxValueLength : -1;
311 }
312
313 /**
314 * Definitions of the NS_ constants are in Defines.php
315 * @private
316 */
317 $wgCanonicalNamespaceNames = array(
318 NS_MEDIA => 'Media',
319 NS_SPECIAL => 'Special',
320 NS_TALK => 'Talk',
321 NS_USER => 'User',
322 NS_USER_TALK => 'User_talk',
323 NS_PROJECT => 'Project',
324 NS_PROJECT_TALK => 'Project_talk',
325 NS_FILE => 'File',
326 NS_FILE_TALK => 'File_talk',
327 NS_MEDIAWIKI => 'MediaWiki',
328 NS_MEDIAWIKI_TALK => 'MediaWiki_talk',
329 NS_TEMPLATE => 'Template',
330 NS_TEMPLATE_TALK => 'Template_talk',
331 NS_HELP => 'Help',
332 NS_HELP_TALK => 'Help_talk',
333 NS_CATEGORY => 'Category',
334 NS_CATEGORY_TALK => 'Category_talk',
335 );
336
337 /// @todo UGLY UGLY
338 if ( is_array( $wgExtraNamespaces ) ) {
339 $wgCanonicalNamespaceNames = $wgCanonicalNamespaceNames + $wgExtraNamespaces;
340 }
341
342 // These are now the same, always
343 // To determine the user language, use $wgLang->getCode()
344 $wgContLanguageCode = $wgLanguageCode;
345
346 // Easy to forget to falsify $wgShowIPinHeader for static caches.
347 // If file cache or squid cache is on, just disable this (DWIMD).
348 // Do the same for $wgDebugToolbar.
349 if ( $wgUseFileCache || $wgUseSquid ) {
350 $wgShowIPinHeader = false;
351 $wgDebugToolbar = false;
352 }
353
354 // Doesn't make sense to have if disabled.
355 if ( !$wgEnotifMinorEdits ) {
356 $wgHiddenPrefs[] = 'enotifminoredits';
357 }
358
359 // We always output HTML5 since 1.22, overriding these is no longer supported
360 // we set them here for extensions that depend on its value.
361 $wgHtml5 = true;
362 $wgXhtmlDefaultNamespace = 'http://www.w3.org/1999/xhtml';
363 $wgJsMimeType = 'text/javascript';
364
365 if ( !$wgHtml5Version && $wgAllowRdfaAttributes ) {
366 // see http://www.w3.org/TR/rdfa-in-html/#document-conformance
367 if ( $wgMimeType == 'application/xhtml+xml' ) {
368 $wgHtml5Version = 'XHTML+RDFa 1.0';
369 } else {
370 $wgHtml5Version = 'HTML+RDFa 1.0';
371 }
372 }
373
374 // Blacklisted file extensions shouldn't appear on the "allowed" list
375 $wgFileExtensions = array_values( array_diff ( $wgFileExtensions, $wgFileBlacklist ) );
376
377 if ( $wgArticleCountMethod === null ) {
378 $wgArticleCountMethod = $wgUseCommaCount ? 'comma' : 'link';
379 }
380
381 if ( $wgInvalidateCacheOnLocalSettingsChange ) {
382 // @codingStandardsIgnoreStart Generic.PHP.NoSilencedErrors.Discouraged - No GlobalFunction here yet.
383 $wgCacheEpoch = max( $wgCacheEpoch, gmdate( 'YmdHis', @filemtime( "$IP/LocalSettings.php" ) ) );
384 // @codingStandardsIgnoreEnd
385 }
386
387 if ( $wgNewUserLog ) {
388 // Add a new log type
389 $wgLogTypes[] = 'newusers';
390 $wgLogNames['newusers'] = 'newuserlogpage';
391 $wgLogHeaders['newusers'] = 'newuserlogpagetext';
392 $wgLogActionsHandlers['newusers/newusers'] = 'NewUsersLogFormatter';
393 $wgLogActionsHandlers['newusers/create'] = 'NewUsersLogFormatter';
394 $wgLogActionsHandlers['newusers/create2'] = 'NewUsersLogFormatter';
395 $wgLogActionsHandlers['newusers/byemail'] = 'NewUsersLogFormatter';
396 $wgLogActionsHandlers['newusers/autocreate'] = 'NewUsersLogFormatter';
397 }
398
399 if ( $wgPageLanguageUseDB ) {
400 $wgLogTypes[] = 'pagelang';
401 $wgLogActionsHandlers['pagelang/pagelang'] = 'PageLangLogFormatter';
402 }
403
404 if ( $wgCookieSecure === 'detect' ) {
405 $wgCookieSecure = ( WebRequest::detectProtocol() === 'https' );
406 }
407
408 if ( $wgRC2UDPAddress ) {
409 $wgRCFeeds['default'] = array(
410 'formatter' => 'IRCColourfulRCFeedFormatter',
411 'uri' => "udp://$wgRC2UDPAddress:$wgRC2UDPPort/$wgRC2UDPPrefix",
412 'add_interwiki_prefix' => &$wgRC2UDPInterwikiPrefix,
413 'omit_bots' => &$wgRC2UDPOmitBots,
414 );
415 }
416
417 wfProfileOut( $fname . '-defaults' );
418
419 // Disable MWDebug for command line mode, this prevents MWDebug from eating up
420 // all the memory from logging SQL queries on maintenance scripts
421 global $wgCommandLineMode;
422 if ( $wgDebugToolbar && !$wgCommandLineMode ) {
423 wfProfileIn( $fname . '-debugtoolbar' );
424 MWDebug::init();
425 wfProfileOut( $fname . '-debugtoolbar' );
426 }
427
428 if ( !class_exists( 'AutoLoader' ) ) {
429 require_once "$IP/includes/AutoLoader.php";
430 }
431
432 wfProfileIn( $fname . '-exception' );
433 MWExceptionHandler::installHandler();
434 wfProfileOut( $fname . '-exception' );
435
436 wfProfileIn( $fname . '-includes' );
437 require_once "$IP/includes/normal/UtfNormalUtil.php";
438 require_once "$IP/includes/GlobalFunctions.php";
439 require_once "$IP/includes/normal/UtfNormalDefines.php";
440 wfProfileOut( $fname . '-includes' );
441
442 wfProfileIn( $fname . '-defaults2' );
443
444 if ( $wgCanonicalServer === false ) {
445 $wgCanonicalServer = wfExpandUrl( $wgServer, PROTO_HTTP );
446 }
447
448 // Set server name
449 $serverParts = wfParseUrl( $wgCanonicalServer );
450 if ( $wgServerName !== false ) {
451 wfWarn( '$wgServerName should be derived from $wgCanonicalServer, '
452 . 'not customized. Overwriting $wgServerName.' );
453 }
454 $wgServerName = $serverParts['host'];
455 unset( $serverParts );
456
457 // Set defaults for configuration variables
458 // that are derived from the server name by default
459 if ( $wgEmergencyContact === false ) {
460 $wgEmergencyContact = 'wikiadmin@' . $wgServerName;
461 }
462
463 if ( $wgPasswordSender === false ) {
464 $wgPasswordSender = 'apache@' . $wgServerName;
465 }
466
467 if ( $wgSecureLogin && substr( $wgServer, 0, 2 ) !== '//' ) {
468 $wgSecureLogin = false;
469 wfWarn( 'Secure login was enabled on a server that only supports '
470 . 'HTTP or HTTPS. Disabling secure login.' );
471 }
472
473 // Now that GlobalFunctions is loaded, set defaults that depend
474 // on it.
475 if ( $wgTmpDirectory === false ) {
476 wfProfileIn( $fname . '-tempDir' );
477 $wgTmpDirectory = wfTempDir();
478 wfProfileOut( $fname . '-tempDir' );
479 }
480
481 // $wgHTCPMulticastRouting got renamed to $wgHTCPRouting in MediaWiki 1.22
482 // ensure back compatibility.
483 if ( !$wgHTCPRouting && $wgHTCPMulticastRouting ) {
484 $wgHTCPRouting = $wgHTCPMulticastRouting;
485 }
486
487 // Initialize $wgHTCPRouting from backwards-compatible settings that
488 // comes from pre 1.20 version.
489 if ( !$wgHTCPRouting && $wgHTCPMulticastAddress ) {
490 $wgHTCPRouting = array(
491 '' => array(
492 'host' => $wgHTCPMulticastAddress,
493 'port' => $wgHTCPPort,
494 )
495 );
496 }
497
498 // Back compatibility for $wgRateLimitLog deprecated with 1.23
499 if ( $wgRateLimitLog && ! array_key_exists( 'ratelimit', $wgDebugLogGroups ) ) {
500 $wgDebugLogGroups['ratelimit'] = $wgRateLimitLog;
501 }
502
503 if ( $wgProfileOnly ) {
504 $wgDebugLogGroups['profileoutput'] = $wgDebugLogFile;
505 $wgDebugLogFile = '';
506 }
507
508 wfProfileOut( $fname . '-defaults2' );
509 wfProfileIn( $fname . '-misc1' );
510
511 // Raise the memory limit if it's too low
512 wfMemoryLimit();
513
514 /**
515 * Set up the timezone, suppressing the pseudo-security warning in PHP 5.1+
516 * that happens whenever you use a date function without the timezone being
517 * explicitly set. Inspired by phpMyAdmin's treatment of the problem.
518 */
519 if ( is_null( $wgLocaltimezone ) ) {
520 wfSuppressWarnings();
521 $wgLocaltimezone = date_default_timezone_get();
522 wfRestoreWarnings();
523 }
524
525 date_default_timezone_set( $wgLocaltimezone );
526 if ( is_null( $wgLocalTZoffset ) ) {
527 $wgLocalTZoffset = date( 'Z' ) / 60;
528 }
529
530 // Useful debug output
531 if ( $wgCommandLineMode ) {
532 $wgRequest = new FauxRequest( array() );
533
534 wfDebug( "\n\nStart command line script $self\n" );
535 } else {
536 // Can't stub this one, it sets up $_GET and $_REQUEST in its constructor
537 $wgRequest = new WebRequest;
538
539 $debug = "\n\nStart request {$wgRequest->getMethod()} {$wgRequest->getRequestURL()}\n";
540
541 if ( $wgDebugPrintHttpHeaders ) {
542 $debug .= "HTTP HEADERS:\n";
543
544 foreach ( $wgRequest->getAllHeaders() as $name => $value ) {
545 $debug .= "$name: $value\n";
546 }
547 }
548 wfDebug( $debug );
549 }
550
551 wfProfileOut( $fname . '-misc1' );
552 wfProfileIn( $fname . '-memcached' );
553
554 $wgMemc = wfGetMainCache();
555 $messageMemc = wfGetMessageCacheStorage();
556 $parserMemc = wfGetParserCacheStorage();
557 $wgLangConvMemc = wfGetLangConverterCacheStorage();
558
559 wfDebugLog( 'caches', 'main: ' . get_class( $wgMemc ) .
560 ', message: ' . get_class( $messageMemc ) .
561 ', parser: ' . get_class( $parserMemc ) );
562
563 wfProfileOut( $fname . '-memcached' );
564
565 // Most of the config is out, some might want to run hooks here.
566 wfRunHooks( 'SetupAfterCache' );
567
568 wfProfileIn( $fname . '-session' );
569
570 // If session.auto_start is there, we can't touch session name
571 if ( !wfIniGetBool( 'session.auto_start' ) ) {
572 session_name( $wgSessionName ? $wgSessionName : $wgCookiePrefix . '_session' );
573 }
574
575 if ( !defined( 'MW_NO_SESSION' ) && !$wgCommandLineMode &&
576 ( $wgRequest->checkSessionCookie() || isset( $_COOKIE[$wgCookiePrefix . 'Token'] ) )
577 ) {
578 wfSetupSession();
579 }
580
581 wfProfileOut( $fname . '-session' );
582 wfProfileIn( $fname . '-globals' );
583
584 /**
585 * @var Language $wgContLang
586 */
587 $wgContLang = Language::factory( $wgLanguageCode );
588 $wgContLang->initEncoding();
589 $wgContLang->initContLang();
590
591 // Now that variant lists may be available...
592 $wgRequest->interpolateTitle();
593
594 /**
595 * @var User $wgUser
596 */
597 $wgUser = RequestContext::getMain()->getUser(); // BackCompat
598
599 /**
600 * @var Language $wgLang
601 */
602 $wgLang = new StubUserLang;
603
604 /**
605 * @var OutputPage $wgOut
606 */
607 $wgOut = RequestContext::getMain()->getOutput(); // BackCompat
608
609 /**
610 * @var Parser $wgParser
611 */
612 $wgParser = new StubObject( 'wgParser', $wgParserConf['class'], array( $wgParserConf ) );
613
614 if ( !is_object( $wgAuth ) ) {
615 $wgAuth = new AuthPlugin;
616 wfRunHooks( 'AuthPluginSetup', array( &$wgAuth ) );
617 }
618
619 /**
620 * @var Title $wgTitle
621 */
622 $wgTitle = null;
623
624 $wgDeferredUpdateList = array();
625
626 wfProfileOut( $fname . '-globals' );
627 wfProfileIn( $fname . '-extensions' );
628
629 // Extension setup functions for extensions other than skins
630 // Entries should be added to this variable during the inclusion
631 // of the extension file. This allows the extension to perform
632 // any necessary initialisation in the fully initialised environment
633 foreach ( $wgExtensionFunctions as $func ) {
634 // Allow closures in PHP 5.3+
635 if ( is_object( $func ) && $func instanceof Closure ) {
636 $profName = $fname . '-extensions-closure';
637 } elseif ( is_array( $func ) ) {
638 if ( is_object( $func[0] ) ) {
639 $profName = $fname . '-extensions-' . get_class( $func[0] ) . '::' . $func[1];
640 } else {
641 $profName = $fname . '-extensions-' . implode( '::', $func );
642 }
643 } else {
644 $profName = $fname . '-extensions-' . strval( $func );
645 }
646
647 wfProfileIn( $profName );
648 call_user_func( $func );
649 wfProfileOut( $profName );
650 }
651
652 wfDebug( "Fully initialised\n" );
653 $wgFullyInitialised = true;
654
655 wfProfileOut( $fname . '-extensions' );
656 wfProfileOut( $fname );