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