EditPage::newSectionSummary should return a value in all code paths
[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 if ( $wgLocalInterwiki ) {
275 array_unshift( $wgLocalInterwikis, $wgLocalInterwiki );
276 }
277
278 // Set default shared prefix
279 if ( $wgSharedPrefix === false ) {
280 $wgSharedPrefix = $wgDBprefix;
281 }
282
283 if ( !$wgCookiePrefix ) {
284 if ( $wgSharedDB && $wgSharedPrefix && in_array( 'user', $wgSharedTables ) ) {
285 $wgCookiePrefix = $wgSharedDB . '_' . $wgSharedPrefix;
286 } elseif ( $wgSharedDB && in_array( 'user', $wgSharedTables ) ) {
287 $wgCookiePrefix = $wgSharedDB;
288 } elseif ( $wgDBprefix ) {
289 $wgCookiePrefix = $wgDBname . '_' . $wgDBprefix;
290 } else {
291 $wgCookiePrefix = $wgDBname;
292 }
293 }
294 $wgCookiePrefix = strtr( $wgCookiePrefix, '=,; +."\'\\[', '__________' );
295
296 $wgUseEnotif = $wgEnotifUserTalk || $wgEnotifWatchlist;
297
298 if ( $wgMetaNamespace === false ) {
299 $wgMetaNamespace = str_replace( ' ', '_', $wgSitename );
300 }
301
302 // Default value is either the suhosin limit or -1 for unlimited
303 if ( $wgResourceLoaderMaxQueryLength === false ) {
304 $maxValueLength = ini_get( 'suhosin.get.max_value_length' );
305 $wgResourceLoaderMaxQueryLength = $maxValueLength > 0 ? $maxValueLength : -1;
306 }
307
308 /**
309 * Definitions of the NS_ constants are in Defines.php
310 * @private
311 */
312 $wgCanonicalNamespaceNames = array(
313 NS_MEDIA => 'Media',
314 NS_SPECIAL => 'Special',
315 NS_TALK => 'Talk',
316 NS_USER => 'User',
317 NS_USER_TALK => 'User_talk',
318 NS_PROJECT => 'Project',
319 NS_PROJECT_TALK => 'Project_talk',
320 NS_FILE => 'File',
321 NS_FILE_TALK => 'File_talk',
322 NS_MEDIAWIKI => 'MediaWiki',
323 NS_MEDIAWIKI_TALK => 'MediaWiki_talk',
324 NS_TEMPLATE => 'Template',
325 NS_TEMPLATE_TALK => 'Template_talk',
326 NS_HELP => 'Help',
327 NS_HELP_TALK => 'Help_talk',
328 NS_CATEGORY => 'Category',
329 NS_CATEGORY_TALK => 'Category_talk',
330 );
331
332 /// @todo UGLY UGLY
333 if ( is_array( $wgExtraNamespaces ) ) {
334 $wgCanonicalNamespaceNames = $wgCanonicalNamespaceNames + $wgExtraNamespaces;
335 }
336
337 // These are now the same, always
338 // To determine the user language, use $wgLang->getCode()
339 $wgContLanguageCode = $wgLanguageCode;
340
341 // Easy to forget to falsify $wgShowIPinHeader for static caches.
342 // If file cache or squid cache is on, just disable this (DWIMD).
343 // Do the same for $wgDebugToolbar.
344 if ( $wgUseFileCache || $wgUseSquid ) {
345 $wgShowIPinHeader = false;
346 $wgDebugToolbar = false;
347 }
348
349 // Doesn't make sense to have if disabled.
350 if ( !$wgEnotifMinorEdits ) {
351 $wgHiddenPrefs[] = 'enotifminoredits';
352 }
353
354 // We always output HTML5 since 1.22, overriding these is no longer supported
355 // we set them here for extensions that depend on its value.
356 $wgHtml5 = true;
357 $wgXhtmlDefaultNamespace = 'http://www.w3.org/1999/xhtml';
358 $wgJsMimeType = 'text/javascript';
359
360 if ( !$wgHtml5Version && $wgAllowRdfaAttributes ) {
361 // see http://www.w3.org/TR/rdfa-in-html/#document-conformance
362 if ( $wgMimeType == 'application/xhtml+xml' ) {
363 $wgHtml5Version = 'XHTML+RDFa 1.0';
364 } else {
365 $wgHtml5Version = 'HTML+RDFa 1.0';
366 }
367 }
368
369 // Blacklisted file extensions shouldn't appear on the "allowed" list
370 $wgFileExtensions = array_values( array_diff ( $wgFileExtensions, $wgFileBlacklist ) );
371
372 if ( $wgInvalidateCacheOnLocalSettingsChange ) {
373 // @codingStandardsIgnoreStart Generic.PHP.NoSilencedErrors.Discouraged - No GlobalFunction here yet.
374 $wgCacheEpoch = max( $wgCacheEpoch, gmdate( 'YmdHis', @filemtime( "$IP/LocalSettings.php" ) ) );
375 // @codingStandardsIgnoreEnd
376 }
377
378 if ( $wgNewUserLog ) {
379 // Add a new log type
380 $wgLogTypes[] = 'newusers';
381 $wgLogNames['newusers'] = 'newuserlogpage';
382 $wgLogHeaders['newusers'] = 'newuserlogpagetext';
383 $wgLogActionsHandlers['newusers/newusers'] = 'NewUsersLogFormatter';
384 $wgLogActionsHandlers['newusers/create'] = 'NewUsersLogFormatter';
385 $wgLogActionsHandlers['newusers/create2'] = 'NewUsersLogFormatter';
386 $wgLogActionsHandlers['newusers/byemail'] = 'NewUsersLogFormatter';
387 $wgLogActionsHandlers['newusers/autocreate'] = 'NewUsersLogFormatter';
388 }
389
390 if ( $wgPageLanguageUseDB ) {
391 $wgLogTypes[] = 'pagelang';
392 $wgLogActionsHandlers['pagelang/pagelang'] = 'PageLangLogFormatter';
393 }
394
395 if ( $wgCookieSecure === 'detect' ) {
396 $wgCookieSecure = ( WebRequest::detectProtocol() === 'https' );
397 }
398
399 if ( $wgRC2UDPAddress ) {
400 $wgRCFeeds['default'] = array(
401 'formatter' => 'IRCColourfulRCFeedFormatter',
402 'uri' => "udp://$wgRC2UDPAddress:$wgRC2UDPPort/$wgRC2UDPPrefix",
403 'add_interwiki_prefix' => &$wgRC2UDPInterwikiPrefix,
404 'omit_bots' => &$wgRC2UDPOmitBots,
405 );
406 }
407
408 wfProfileOut( $fname . '-defaults' );
409
410 // Disable MWDebug for command line mode, this prevents MWDebug from eating up
411 // all the memory from logging SQL queries on maintenance scripts
412 global $wgCommandLineMode;
413 if ( $wgDebugToolbar && !$wgCommandLineMode ) {
414 wfProfileIn( $fname . '-debugtoolbar' );
415 MWDebug::init();
416 wfProfileOut( $fname . '-debugtoolbar' );
417 }
418
419 if ( !class_exists( 'AutoLoader' ) ) {
420 require_once "$IP/includes/AutoLoader.php";
421 }
422
423 wfProfileIn( $fname . '-exception' );
424 MWExceptionHandler::installHandler();
425 wfProfileOut( $fname . '-exception' );
426
427 wfProfileIn( $fname . '-includes' );
428 require_once "$IP/includes/normal/UtfNormalUtil.php";
429 require_once "$IP/includes/GlobalFunctions.php";
430 require_once "$IP/includes/normal/UtfNormalDefines.php";
431 wfProfileOut( $fname . '-includes' );
432
433 wfProfileIn( $fname . '-defaults2' );
434
435 if ( $wgCanonicalServer === false ) {
436 $wgCanonicalServer = wfExpandUrl( $wgServer, PROTO_HTTP );
437 }
438
439 // Set server name
440 $serverParts = wfParseUrl( $wgCanonicalServer );
441 if ( $wgServerName !== false ) {
442 wfWarn( '$wgServerName should be derived from $wgCanonicalServer, '
443 . 'not customized. Overwriting $wgServerName.' );
444 }
445 $wgServerName = $serverParts['host'];
446 unset( $serverParts );
447
448 // Set defaults for configuration variables
449 // that are derived from the server name by default
450 if ( $wgEmergencyContact === false ) {
451 $wgEmergencyContact = 'wikiadmin@' . $wgServerName;
452 }
453
454 if ( $wgPasswordSender === false ) {
455 $wgPasswordSender = 'apache@' . $wgServerName;
456 }
457
458 if ( $wgSecureLogin && substr( $wgServer, 0, 2 ) !== '//' ) {
459 $wgSecureLogin = false;
460 wfWarn( 'Secure login was enabled on a server that only supports '
461 . 'HTTP or HTTPS. Disabling secure login.' );
462 }
463
464 // Now that GlobalFunctions is loaded, set defaults that depend
465 // on it.
466 if ( $wgTmpDirectory === false ) {
467 wfProfileIn( $fname . '-tempDir' );
468 $wgTmpDirectory = wfTempDir();
469 wfProfileOut( $fname . '-tempDir' );
470 }
471
472 // $wgHTCPMulticastRouting got renamed to $wgHTCPRouting in MediaWiki 1.22
473 // ensure back compatibility.
474 if ( !$wgHTCPRouting && $wgHTCPMulticastRouting ) {
475 $wgHTCPRouting = $wgHTCPMulticastRouting;
476 }
477
478 // Initialize $wgHTCPRouting from backwards-compatible settings that
479 // comes from pre 1.20 version.
480 if ( !$wgHTCPRouting && $wgHTCPMulticastAddress ) {
481 $wgHTCPRouting = array(
482 '' => array(
483 'host' => $wgHTCPMulticastAddress,
484 'port' => $wgHTCPPort,
485 )
486 );
487 }
488
489 // Back compatibility for $wgRateLimitLog deprecated with 1.23
490 if ( $wgRateLimitLog && !array_key_exists( 'ratelimit', $wgDebugLogGroups ) ) {
491 $wgDebugLogGroups['ratelimit'] = $wgRateLimitLog;
492 }
493
494 if ( $wgProfileOnly ) {
495 $wgDebugLogGroups['profileoutput'] = $wgDebugLogFile;
496 $wgDebugLogFile = '';
497 }
498
499 wfProfileOut( $fname . '-defaults2' );
500 wfProfileIn( $fname . '-misc1' );
501
502 // Raise the memory limit if it's too low
503 wfMemoryLimit();
504
505 /**
506 * Set up the timezone, suppressing the pseudo-security warning in PHP 5.1+
507 * that happens whenever you use a date function without the timezone being
508 * explicitly set. Inspired by phpMyAdmin's treatment of the problem.
509 */
510 if ( is_null( $wgLocaltimezone ) ) {
511 wfSuppressWarnings();
512 $wgLocaltimezone = date_default_timezone_get();
513 wfRestoreWarnings();
514 }
515
516 date_default_timezone_set( $wgLocaltimezone );
517 if ( is_null( $wgLocalTZoffset ) ) {
518 $wgLocalTZoffset = date( 'Z' ) / 60;
519 }
520
521 // Useful debug output
522 if ( $wgCommandLineMode ) {
523 $wgRequest = new FauxRequest( array() );
524
525 wfDebug( "\n\nStart command line script $self\n" );
526 } else {
527 // Can't stub this one, it sets up $_GET and $_REQUEST in its constructor
528 $wgRequest = new WebRequest;
529
530 $debug = "\n\nStart request {$wgRequest->getMethod()} {$wgRequest->getRequestURL()}\n";
531
532 if ( $wgDebugPrintHttpHeaders ) {
533 $debug .= "HTTP HEADERS:\n";
534
535 foreach ( $wgRequest->getAllHeaders() as $name => $value ) {
536 $debug .= "$name: $value\n";
537 }
538 }
539 wfDebug( $debug );
540 }
541
542 wfProfileOut( $fname . '-misc1' );
543 wfProfileIn( $fname . '-memcached' );
544
545 $wgMemc = wfGetMainCache();
546 $messageMemc = wfGetMessageCacheStorage();
547 $parserMemc = wfGetParserCacheStorage();
548 $wgLangConvMemc = wfGetLangConverterCacheStorage();
549
550 wfDebugLog( 'caches', 'main: ' . get_class( $wgMemc ) .
551 ', message: ' . get_class( $messageMemc ) .
552 ', parser: ' . get_class( $parserMemc ) );
553
554 wfProfileOut( $fname . '-memcached' );
555
556 // Most of the config is out, some might want to run hooks here.
557 wfRunHooks( 'SetupAfterCache' );
558
559 wfProfileIn( $fname . '-session' );
560
561 // If session.auto_start is there, we can't touch session name
562 if ( !wfIniGetBool( 'session.auto_start' ) ) {
563 session_name( $wgSessionName ? $wgSessionName : $wgCookiePrefix . '_session' );
564 }
565
566 if ( !defined( 'MW_NO_SESSION' ) && !$wgCommandLineMode &&
567 ( $wgRequest->checkSessionCookie() || isset( $_COOKIE[$wgCookiePrefix . 'Token'] ) )
568 ) {
569 wfSetupSession();
570 }
571
572 wfProfileOut( $fname . '-session' );
573 wfProfileIn( $fname . '-globals' );
574
575 /**
576 * @var Language $wgContLang
577 */
578 $wgContLang = Language::factory( $wgLanguageCode );
579 $wgContLang->initEncoding();
580 $wgContLang->initContLang();
581
582 // Now that variant lists may be available...
583 $wgRequest->interpolateTitle();
584
585 /**
586 * @var User $wgUser
587 */
588 $wgUser = RequestContext::getMain()->getUser(); // BackCompat
589
590 /**
591 * @var Language $wgLang
592 */
593 $wgLang = new StubUserLang;
594
595 /**
596 * @var OutputPage $wgOut
597 */
598 $wgOut = RequestContext::getMain()->getOutput(); // BackCompat
599
600 /**
601 * @var Parser $wgParser
602 */
603 $wgParser = new StubObject( 'wgParser', $wgParserConf['class'], array( $wgParserConf ) );
604
605 if ( !is_object( $wgAuth ) ) {
606 $wgAuth = new AuthPlugin;
607 wfRunHooks( 'AuthPluginSetup', array( &$wgAuth ) );
608 }
609
610 /**
611 * @var Title $wgTitle
612 */
613 $wgTitle = null;
614
615 $wgDeferredUpdateList = array();
616
617 // Disable all other email settings automatically if $wgEnableEmail
618 // is set to false. - bug 63678
619 if ( !$wgEnableEmail ) {
620 $wgAllowHTMLEmail = false;
621 $wgEmailAuthentication = false; // do not require auth if you're not sending email anyway
622 $wgEnableUserEmail = false;
623 $wgEnotifFromEditor = false;
624 $wgEnotifImpersonal = false;
625 $wgEnotifMaxRecips = 0;
626 $wgEnotifMinorEdits = false;
627 $wgEnotifRevealEditorAddress = false;
628 $wgEnotifUseJobQ = false;
629 $wgEnotifUseRealName = false;
630 $wgEnotifUserTalk = false;
631 $wgEnotifWatchlist = false;
632 unset( $wgGroupPermissions['user']['sendemail'] );
633 $wgUserEmailUseReplyTo = false;
634 $wgUsersNotifiedOnAllChanges = array();
635 }
636
637 wfProfileOut( $fname . '-globals' );
638 wfProfileIn( $fname . '-extensions' );
639
640 // Extension setup functions for extensions other than skins
641 // Entries should be added to this variable during the inclusion
642 // of the extension file. This allows the extension to perform
643 // any necessary initialisation in the fully initialised environment
644 foreach ( $wgExtensionFunctions as $func ) {
645 // Allow closures in PHP 5.3+
646 if ( is_object( $func ) && $func instanceof Closure ) {
647 $profName = $fname . '-extensions-closure';
648 } elseif ( is_array( $func ) ) {
649 if ( is_object( $func[0] ) ) {
650 $profName = $fname . '-extensions-' . get_class( $func[0] ) . '::' . $func[1];
651 } else {
652 $profName = $fname . '-extensions-' . implode( '::', $func );
653 }
654 } else {
655 $profName = $fname . '-extensions-' . strval( $func );
656 }
657
658 wfProfileIn( $profName );
659 call_user_func( $func );
660 wfProfileOut( $profName );
661 }
662
663 wfDebug( "Fully initialised\n" );
664 $wgFullyInitialised = true;
665
666 wfProfileOut( $fname . '-extensions' );
667 wfProfileOut( $fname );