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