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