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