3 * Include most things that are needed to make %MediaWiki work.
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.
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.
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.
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
28 * This file is not a valid entry point, perform no further processing unless
29 * MEDIAWIKI is defined
31 if ( !defined( 'MEDIAWIKI' ) ) {
36 $ps_setup = Profiler
::instance()->scopedProfileIn( $fname );
38 // If any extensions are still queued, force load them
39 ExtensionRegistry
::getInstance()->loadFromQueue();
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";
47 // Set various default paths sensibly...
48 $ps_default = Profiler
::instance()->scopedProfileIn( $fname . '-defaults' );
50 if ( $wgScript === false ) {
51 $wgScript = "$wgScriptPath/index.php";
53 if ( $wgLoadScript === false ) {
54 $wgLoadScript = "$wgScriptPath/load.php";
57 if ( $wgArticlePath === false ) {
58 if ( $wgUsePathInfo ) {
59 $wgArticlePath = "$wgScript/$1";
61 $wgArticlePath = "$wgScript?title=$1";
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;
71 if ( $wgResourceBasePath === null ) {
72 $wgResourceBasePath = $wgScriptPath;
74 if ( $wgStylePath === false ) {
75 $wgStylePath = "$wgResourceBasePath/skins";
77 if ( $wgLocalStylePath === false ) {
78 // Avoid wgResourceBasePath here since that may point to a different domain (e.g. CDN)
79 $wgLocalStylePath = "$wgScriptPath/skins";
81 if ( $wgExtensionAssetsPath === false ) {
82 $wgExtensionAssetsPath = "$wgResourceBasePath/extensions";
85 if ( $wgLogo === false ) {
86 $wgLogo = "$wgResourceBasePath/resources/assets/wiki.png";
89 if ( $wgUploadPath === false ) {
90 $wgUploadPath = "$wgScriptPath/images";
92 if ( $wgUploadDirectory === false ) {
93 $wgUploadDirectory = "$IP/images";
95 if ( $wgReadOnlyFile === false ) {
96 $wgReadOnlyFile = "{$wgUploadDirectory}/lock_yBgMBwiR";
98 if ( $wgFileCacheDirectory === false ) {
99 $wgFileCacheDirectory = "{$wgUploadDirectory}/cache";
101 if ( $wgDeletedDirectory === false ) {
102 $wgDeletedDirectory = "{$wgUploadDirectory}/deleted";
105 if ( $wgGitInfoCacheDirectory === false && $wgCacheDirectory !== false ) {
106 $wgGitInfoCacheDirectory = "{$wgCacheDirectory}/gitinfo";
109 if ( $wgEnableParserCache === false ) {
110 $wgParserCacheType = CACHE_NONE
;
113 // Fix path to icon images after they were moved in 1.24
114 if ( $wgRightsIcon ) {
115 $wgRightsIcon = str_replace(
116 "{$wgStylePath}/common/images/",
117 "{$wgResourceBasePath}/resources/assets/licenses/",
122 if ( isset( $wgFooterIcons['copyright'] )
123 && isset( $wgFooterIcons['copyright']['copyright'] )
124 && $wgFooterIcons['copyright']['copyright'] === array()
126 if ( $wgCopyrightIcon ) {
127 $wgFooterIcons['copyright']['copyright'] = $wgCopyrightIcon;
128 } elseif ( $wgRightsIcon ||
$wgRightsText ) {
129 $wgFooterIcons['copyright']['copyright'] = array(
130 'url' => $wgRightsUrl,
131 'src' => $wgRightsIcon,
132 'alt' => $wgRightsText,
135 unset( $wgFooterIcons['copyright']['copyright'] );
139 if ( isset( $wgFooterIcons['poweredby'] )
140 && isset( $wgFooterIcons['poweredby']['mediawiki'] )
141 && $wgFooterIcons['poweredby']['mediawiki']['src'] === null
143 $wgFooterIcons['poweredby']['mediawiki']['src'] =
144 "$wgResourceBasePath/resources/assets/poweredby_mediawiki_88x31.png";
145 $wgFooterIcons['poweredby']['mediawiki']['srcset'] =
146 "$wgResourceBasePath/resources/assets/poweredby_mediawiki_132x47.png 1.5x, " .
147 "$wgResourceBasePath/resources/assets/poweredby_mediawiki_176x62.png 2x";
151 * Unconditional protection for NS_MEDIAWIKI since otherwise it's too easy for a
152 * sysadmin to set $wgNamespaceProtection incorrectly and leave the wiki insecure.
154 * Note that this is the definition of editinterface and it can be granted to
155 * all users if desired.
157 $wgNamespaceProtection[NS_MEDIAWIKI
] = 'editinterface';
160 * The canonical names of namespaces 6 and 7 are, as of v1.14, "File"
161 * and "File_talk". The old names "Image" and "Image_talk" are
162 * retained as aliases for backwards compatibility.
164 $wgNamespaceAliases['Image'] = NS_FILE
;
165 $wgNamespaceAliases['Image_talk'] = NS_FILE_TALK
;
168 * Initialise $wgLockManagers to include basic FS version
170 $wgLockManagers[] = array(
171 'name' => 'fsLockManager',
172 'class' => 'FSLockManager',
173 'lockDirectory' => "{$wgUploadDirectory}/lockdir",
175 $wgLockManagers[] = array(
176 'name' => 'nullLockManager',
177 'class' => 'NullLockManager',
181 * Initialise $wgLocalFileRepo from backwards-compatible settings
183 if ( !$wgLocalFileRepo ) {
184 $wgLocalFileRepo = array(
185 'class' => 'LocalRepo',
187 'directory' => $wgUploadDirectory,
188 'scriptDirUrl' => $wgScriptPath,
189 'scriptExtension' => '.php',
190 'url' => $wgUploadBaseUrl ?
$wgUploadBaseUrl . $wgUploadPath : $wgUploadPath,
191 'hashLevels' => $wgHashedUploadDirectory ?
2 : 0,
192 'thumbScriptUrl' => $wgThumbnailScriptPath,
193 'transformVia404' => !$wgGenerateThumbnailOnParse,
194 'deletedDir' => $wgDeletedDirectory,
195 'deletedHashLevels' => $wgHashedUploadDirectory ?
3 : 0
199 * Initialise shared repo from backwards-compatible settings
201 if ( $wgUseSharedUploads ) {
202 if ( $wgSharedUploadDBname ) {
203 $wgForeignFileRepos[] = array(
204 'class' => 'ForeignDBRepo',
206 'directory' => $wgSharedUploadDirectory,
207 'url' => $wgSharedUploadPath,
208 'hashLevels' => $wgHashedSharedUploadDirectory ?
2 : 0,
209 'thumbScriptUrl' => $wgSharedThumbnailScriptPath,
210 'transformVia404' => !$wgGenerateThumbnailOnParse,
211 'dbType' => $wgDBtype,
212 'dbServer' => $wgDBserver,
213 'dbUser' => $wgDBuser,
214 'dbPassword' => $wgDBpassword,
215 'dbName' => $wgSharedUploadDBname,
216 'dbFlags' => ( $wgDebugDumpSql ? DBO_DEBUG
: 0 ) | DBO_DEFAULT
,
217 'tablePrefix' => $wgSharedUploadDBprefix,
218 'hasSharedCache' => $wgCacheSharedUploads,
219 'descBaseUrl' => $wgRepositoryBaseUrl,
220 'fetchDescription' => $wgFetchCommonsDescriptions,
223 $wgForeignFileRepos[] = array(
224 'class' => 'FileRepo',
226 'directory' => $wgSharedUploadDirectory,
227 'url' => $wgSharedUploadPath,
228 'hashLevels' => $wgHashedSharedUploadDirectory ?
2 : 0,
229 'thumbScriptUrl' => $wgSharedThumbnailScriptPath,
230 'transformVia404' => !$wgGenerateThumbnailOnParse,
231 'descBaseUrl' => $wgRepositoryBaseUrl,
232 'fetchDescription' => $wgFetchCommonsDescriptions,
236 if ( $wgUseInstantCommons ) {
237 $wgForeignFileRepos[] = array(
238 'class' => 'ForeignAPIRepo',
239 'name' => 'wikimediacommons',
240 'apibase' => 'https://commons.wikimedia.org/w/api.php',
241 'url' => 'https://upload.wikimedia.org/wikipedia/commons',
242 'thumbUrl' => 'https://upload.wikimedia.org/wikipedia/commons/thumb',
244 'transformVia404' => true,
245 'fetchDescription' => true,
246 'descriptionCacheExpiry' => 43200,
247 'apiThumbCacheExpiry' => 86400,
251 * Add on default file backend config for file repos.
252 * FileBackendGroup will handle initializing the backends.
254 if ( !isset( $wgLocalFileRepo['backend'] ) ) {
255 $wgLocalFileRepo['backend'] = $wgLocalFileRepo['name'] . '-backend';
257 foreach ( $wgForeignFileRepos as &$repo ) {
258 if ( !isset( $repo['directory'] ) && $repo['class'] === 'ForeignAPIRepo' ) {
259 $repo['directory'] = $wgUploadDirectory; // b/c
261 if ( !isset( $repo['backend'] ) ) {
262 $repo['backend'] = $repo['name'] . '-backend';
265 unset( $repo ); // no global pollution; destroy reference
267 if ( $wgRCFilterByAge ) {
268 // Trim down $wgRCLinkDays so that it only lists links which are valid
269 // as determined by $wgRCMaxAge.
270 // Note that we allow 1 link higher than the max for things like 56 days but a 60 day link.
271 sort( $wgRCLinkDays );
273 // @codingStandardsIgnoreStart Generic.CodeAnalysis.ForLoopWithTestFunctionCall.NotAllowed
274 for ( $i = 0; $i < count( $wgRCLinkDays ); $i++
) {
275 // @codingStandardsIgnoreEnd
276 if ( $wgRCLinkDays[$i] >= $wgRCMaxAge / ( 3600 * 24 ) ) {
277 $wgRCLinkDays = array_slice( $wgRCLinkDays, 0, $i +
1, false );
284 $wgSkipSkins[] = $wgSkipSkin;
288 // Use a closure to avoid leaking into global state
289 call_user_func( function () use ( $wgValidSkinNames ) {
290 $factory = SkinFactory
::getDefaultInstance();
291 foreach ( $wgValidSkinNames as $name => $skin ) {
292 $factory->register( $name, $skin, function () use ( $name, $skin ) {
293 $class = "Skin$skin";
294 return new $class( $name );
297 // Register a hidden "fallback" skin
298 $factory->register( 'fallback', 'Fallback', function () {
299 return new SkinFallback
;
301 // Register a hidden skin for api output
302 $factory->register( 'apioutput', 'ApiOutput', function () {
306 $wgSkipSkins[] = 'fallback';
307 $wgSkipSkins[] = 'apioutput';
309 if ( $wgLocalInterwiki ) {
310 array_unshift( $wgLocalInterwikis, $wgLocalInterwiki );
313 // Set default shared prefix
314 if ( $wgSharedPrefix === false ) {
315 $wgSharedPrefix = $wgDBprefix;
318 // Set default shared schema
319 if ( $wgSharedSchema === false ) {
320 $wgSharedSchema = $wgDBmwschema;
323 if ( !$wgCookiePrefix ) {
324 if ( $wgSharedDB && $wgSharedPrefix && in_array( 'user', $wgSharedTables ) ) {
325 $wgCookiePrefix = $wgSharedDB . '_' . $wgSharedPrefix;
326 } elseif ( $wgSharedDB && in_array( 'user', $wgSharedTables ) ) {
327 $wgCookiePrefix = $wgSharedDB;
328 } elseif ( $wgDBprefix ) {
329 $wgCookiePrefix = $wgDBname . '_' . $wgDBprefix;
331 $wgCookiePrefix = $wgDBname;
334 $wgCookiePrefix = strtr( $wgCookiePrefix, '=,; +."\'\\[', '__________' );
336 if ( $wgEnableEmail ) {
337 $wgUseEnotif = $wgEnotifUserTalk ||
$wgEnotifWatchlist;
339 // Disable all other email settings automatically if $wgEnableEmail
340 // is set to false. - bug 63678
341 $wgAllowHTMLEmail = false;
342 $wgEmailAuthentication = false; // do not require auth if you're not sending email anyway
343 $wgEnableUserEmail = false;
344 $wgEnotifFromEditor = false;
345 $wgEnotifImpersonal = false;
346 $wgEnotifMaxRecips = 0;
347 $wgEnotifMinorEdits = false;
348 $wgEnotifRevealEditorAddress = false;
349 $wgEnotifUseJobQ = false;
350 $wgEnotifUseRealName = false;
351 $wgEnotifUserTalk = false;
352 $wgEnotifWatchlist = false;
353 unset( $wgGroupPermissions['user']['sendemail'] );
354 $wgUseEnotif = false;
355 $wgUserEmailUseReplyTo = false;
356 $wgUsersNotifiedOnAllChanges = array();
359 // Doesn't make sense to have if disabled.
360 if ( !$wgEnotifMinorEdits ) {
361 $wgHiddenPrefs[] = 'enotifminoredits';
364 if ( $wgMetaNamespace === false ) {
365 $wgMetaNamespace = str_replace( ' ', '_', $wgSitename );
368 // Default value is 2000 or the suhosin limit if it is between 1 and 2000
369 if ( $wgResourceLoaderMaxQueryLength === false ) {
370 $suhosinMaxValueLength = (int)ini_get( 'suhosin.get.max_value_length' );
371 if ( $suhosinMaxValueLength > 0 && $suhosinMaxValueLength < 2000 ) {
372 $wgResourceLoaderMaxQueryLength = $suhosinMaxValueLength;
374 $wgResourceLoaderMaxQueryLength = 2000;
376 unset( $suhosinMaxValueLength );
379 // Ensure the minimum chunk size is less than PHP upload limits or the maximum
381 $wgMinUploadChunkSize = min(
382 $wgMinUploadChunkSize,
383 UploadBase
::getMaxUploadSize( 'file' ),
384 UploadBase
::getMaxPhpUploadSize(),
385 ( wfShorthandToInteger(
386 ini_get( 'post_max_size' ) ?
: ini_get( 'hhvm.server.max_post_size' ),
388 ) ?
: PHP_INT_MAX
) - 1024 // Leave some room for other POST parameters
392 * Definitions of the NS_ constants are in Defines.php
395 $wgCanonicalNamespaceNames = array(
397 NS_SPECIAL
=> 'Special',
400 NS_USER_TALK
=> 'User_talk',
401 NS_PROJECT
=> 'Project',
402 NS_PROJECT_TALK
=> 'Project_talk',
404 NS_FILE_TALK
=> 'File_talk',
405 NS_MEDIAWIKI
=> 'MediaWiki',
406 NS_MEDIAWIKI_TALK
=> 'MediaWiki_talk',
407 NS_TEMPLATE
=> 'Template',
408 NS_TEMPLATE_TALK
=> 'Template_talk',
410 NS_HELP_TALK
=> 'Help_talk',
411 NS_CATEGORY
=> 'Category',
412 NS_CATEGORY_TALK
=> 'Category_talk',
416 if ( is_array( $wgExtraNamespaces ) ) {
417 $wgCanonicalNamespaceNames = $wgCanonicalNamespaceNames +
$wgExtraNamespaces;
420 // These are now the same, always
421 // To determine the user language, use $wgLang->getCode()
422 $wgContLanguageCode = $wgLanguageCode;
424 // Easy to forget to falsify $wgDebugToolbar for static caches.
425 // If file cache or CDN cache is on, just disable this (DWIMD).
426 if ( $wgUseFileCache ||
$wgUseSquid ) {
427 $wgDebugToolbar = false;
430 // We always output HTML5 since 1.22, overriding these is no longer supported
431 // we set them here for extensions that depend on its value.
433 $wgXhtmlDefaultNamespace = 'http://www.w3.org/1999/xhtml';
434 $wgJsMimeType = 'text/javascript';
436 if ( !$wgHtml5Version && $wgAllowRdfaAttributes ) {
437 // see http://www.w3.org/TR/rdfa-in-html/#document-conformance
438 if ( $wgMimeType == 'application/xhtml+xml' ) {
439 $wgHtml5Version = 'XHTML+RDFa 1.0';
441 $wgHtml5Version = 'HTML+RDFa 1.0';
445 // Blacklisted file extensions shouldn't appear on the "allowed" list
446 $wgFileExtensions = array_values( array_diff( $wgFileExtensions, $wgFileBlacklist ) );
448 if ( $wgInvalidateCacheOnLocalSettingsChange ) {
449 MediaWiki\
suppressWarnings();
450 $wgCacheEpoch = max( $wgCacheEpoch, gmdate( 'YmdHis', filemtime( "$IP/LocalSettings.php" ) ) );
451 MediaWiki\restoreWarnings
();
454 if ( $wgNewUserLog ) {
455 // Add a new log type
456 $wgLogTypes[] = 'newusers';
457 $wgLogNames['newusers'] = 'newuserlogpage';
458 $wgLogHeaders['newusers'] = 'newuserlogpagetext';
459 $wgLogActionsHandlers['newusers/newusers'] = 'NewUsersLogFormatter';
460 $wgLogActionsHandlers['newusers/create'] = 'NewUsersLogFormatter';
461 $wgLogActionsHandlers['newusers/create2'] = 'NewUsersLogFormatter';
462 $wgLogActionsHandlers['newusers/byemail'] = 'NewUsersLogFormatter';
463 $wgLogActionsHandlers['newusers/autocreate'] = 'NewUsersLogFormatter';
466 if ( $wgPageLanguageUseDB ) {
467 $wgLogTypes[] = 'pagelang';
468 $wgLogActionsHandlers['pagelang/pagelang'] = 'PageLangLogFormatter';
471 if ( $wgCookieSecure === 'detect' ) {
472 $wgCookieSecure = ( WebRequest
::detectProtocol() === 'https' );
475 if ( $wgProfileOnly ) {
476 $wgDebugLogGroups['profileoutput'] = $wgDebugLogFile;
477 $wgDebugLogFile = '';
480 // Backwards compatibility with old password limits
481 if ( $wgMinimalPasswordLength !== false ) {
482 $wgPasswordPolicy['policies']['default']['MinimalPasswordLength'] = $wgMinimalPasswordLength;
485 if ( $wgMaximalPasswordLength !== false ) {
486 $wgPasswordPolicy['policies']['default']['MaximalPasswordLength'] = $wgMaximalPasswordLength;
489 // Backwards compatibility with deprecated alias
490 // Must be before call to wfSetupSession()
491 if ( $wgSessionsInMemcached ) {
492 $wgSessionsInObjectCache = true;
495 Profiler
::instance()->scopedProfileOut( $ps_default );
497 // Disable MWDebug for command line mode, this prevents MWDebug from eating up
498 // all the memory from logging SQL queries on maintenance scripts
499 global $wgCommandLineMode;
500 if ( $wgDebugToolbar && !$wgCommandLineMode ) {
504 if ( !class_exists( 'AutoLoader' ) ) {
505 require_once "$IP/includes/AutoLoader.php";
508 MWExceptionHandler
::installHandler();
510 require_once "$IP/includes/compat/normal/UtfNormalUtil.php";
512 $ps_validation = Profiler
::instance()->scopedProfileIn( $fname . '-validation' );
514 // T48998: Bail out early if $wgArticlePath is non-absolute
515 if ( !preg_match( '/^(https?:\/\/|\/)/', $wgArticlePath ) ) {
516 throw new FatalError(
517 'If you use a relative URL for $wgArticlePath, it must start ' .
518 'with a slash (<code>/</code>).<br><br>See ' .
519 '<a href="https://www.mediawiki.org/wiki/Manual:$wgArticlePath">' .
520 'https://www.mediawiki.org/wiki/Manual:$wgArticlePath</a>.'
524 Profiler
::instance()->scopedProfileOut( $ps_validation );
526 $ps_default2 = Profiler
::instance()->scopedProfileIn( $fname . '-defaults2' );
528 if ( $wgCanonicalServer === false ) {
529 $wgCanonicalServer = wfExpandUrl( $wgServer, PROTO_HTTP
);
533 $serverParts = wfParseUrl( $wgCanonicalServer );
534 if ( $wgServerName !== false ) {
535 wfWarn( '$wgServerName should be derived from $wgCanonicalServer, '
536 . 'not customized. Overwriting $wgServerName.' );
538 $wgServerName = $serverParts['host'];
539 unset( $serverParts );
541 // Set defaults for configuration variables
542 // that are derived from the server name by default
543 // Note: $wgEmergencyContact and $wgPasswordSender may be false or empty string (T104142)
544 if ( !$wgEmergencyContact ) {
545 $wgEmergencyContact = 'wikiadmin@' . $wgServerName;
547 if ( !$wgPasswordSender ) {
548 $wgPasswordSender = 'apache@' . $wgServerName;
551 if ( $wgSecureLogin && substr( $wgServer, 0, 2 ) !== '//' ) {
552 $wgSecureLogin = false;
553 wfWarn( 'Secure login was enabled on a server that only supports '
554 . 'HTTP or HTTPS. Disabling secure login.' );
557 $wgVirtualRestConfig['global']['domain'] = $wgCanonicalServer;
559 // Now that GlobalFunctions is loaded, set defaults that depend on it.
560 if ( $wgTmpDirectory === false ) {
561 $wgTmpDirectory = wfTempDir();
564 // We don't use counters anymore. Left here for extensions still
565 // expecting this to exist. Should be removed sometime 1.26 or later.
566 if ( !isset( $wgDisableCounters ) ) {
567 $wgDisableCounters = true;
570 if ( $wgMainWANCache === false ) {
571 // Setup a WAN cache from $wgMainCacheType with no relayer.
572 // Sites using multiple datacenters can configure a relayer.
573 $wgMainWANCache = 'mediawiki-main-default';
574 $wgWANObjectCaches[$wgMainWANCache] = array(
575 'class' => 'WANObjectCache',
576 'cacheId' => $wgMainCacheType,
577 'pool' => 'mediawiki-main-default',
578 'relayerConfig' => array( 'class' => 'EventRelayerNull' )
582 Profiler
::instance()->scopedProfileOut( $ps_default2 );
584 $ps_misc = Profiler
::instance()->scopedProfileIn( $fname . '-misc1' );
586 // Raise the memory limit if it's too low
590 * Set up the timezone, suppressing the pseudo-security warning in PHP 5.1+
591 * that happens whenever you use a date function without the timezone being
592 * explicitly set. Inspired by phpMyAdmin's treatment of the problem.
594 if ( is_null( $wgLocaltimezone ) ) {
595 MediaWiki\
suppressWarnings();
596 $wgLocaltimezone = date_default_timezone_get();
597 MediaWiki\restoreWarnings
();
600 date_default_timezone_set( $wgLocaltimezone );
601 if ( is_null( $wgLocalTZoffset ) ) {
602 $wgLocalTZoffset = date( 'Z' ) / 60;
605 if ( !$wgDBerrorLogTZ ) {
606 $wgDBerrorLogTZ = $wgLocaltimezone;
609 // Useful debug output
610 if ( $wgCommandLineMode ) {
611 $wgRequest = new FauxRequest( array() );
613 wfDebug( "\n\nStart command line script $self\n" );
615 // Can't stub this one, it sets up $_GET and $_REQUEST in its constructor
616 $wgRequest = new WebRequest
;
618 $debug = "\n\nStart request {$wgRequest->getMethod()} {$wgRequest->getRequestURL()}\n";
620 if ( $wgDebugPrintHttpHeaders ) {
621 $debug .= "HTTP HEADERS:\n";
623 foreach ( $wgRequest->getAllHeaders() as $name => $value ) {
624 $debug .= "$name: $value\n";
630 Profiler
::instance()->scopedProfileOut( $ps_misc );
631 $ps_memcached = Profiler
::instance()->scopedProfileIn( $fname . '-memcached' );
633 $wgMemc = wfGetMainCache();
634 $messageMemc = wfGetMessageCacheStorage();
635 $parserMemc = wfGetParserCacheStorage();
637 wfDebugLog( 'caches',
638 'cluster: ' . get_class( $wgMemc ) .
639 ', WAN: ' . $wgMainWANCache .
640 ', stash: ' . $wgMainStash .
641 ', message: ' . get_class( $messageMemc ) .
642 ', parser: ' . get_class( $parserMemc ) );
644 Profiler
::instance()->scopedProfileOut( $ps_memcached );
646 // Most of the config is out, some might want to run hooks here.
647 Hooks
::run( 'SetupAfterCache' );
649 $ps_session = Profiler
::instance()->scopedProfileIn( $fname . '-session' );
651 if ( !defined( 'MW_NO_SESSION' ) && !$wgCommandLineMode ) {
652 // If session.auto_start is there, we can't touch session name
653 if ( !wfIniGetBool( 'session.auto_start' ) ) {
654 session_name( $wgSessionName ?
$wgSessionName : $wgCookiePrefix . '_session' );
657 if ( $wgRequest->checkSessionCookie() ||
isset( $_COOKIE[$wgCookiePrefix . 'Token'] ) ) {
662 Profiler
::instance()->scopedProfileOut( $ps_session );
663 $ps_globals = Profiler
::instance()->scopedProfileIn( $fname . '-globals' );
666 * @var Language $wgContLang
668 $wgContLang = Language
::factory( $wgLanguageCode );
669 $wgContLang->initEncoding();
670 $wgContLang->initContLang();
672 // Now that variant lists may be available...
673 $wgRequest->interpolateTitle();
678 $wgUser = RequestContext
::getMain()->getUser(); // BackCompat
681 * @var Language $wgLang
683 $wgLang = new StubUserLang
;
686 * @var OutputPage $wgOut
688 $wgOut = RequestContext
::getMain()->getOutput(); // BackCompat
691 * @var Parser $wgParser
693 $wgParser = new StubObject( 'wgParser', $wgParserConf['class'], array( $wgParserConf ) );
695 if ( !is_object( $wgAuth ) ) {
696 $wgAuth = new AuthPlugin
;
697 Hooks
::run( 'AuthPluginSetup', array( &$wgAuth ) );
701 * @var Title $wgTitle
705 Profiler
::instance()->scopedProfileOut( $ps_globals );
706 $ps_extensions = Profiler
::instance()->scopedProfileIn( $fname . '-extensions' );
708 // Extension setup functions
709 // Entries should be added to this variable during the inclusion
710 // of the extension file. This allows the extension to perform
711 // any necessary initialisation in the fully initialised environment
712 foreach ( $wgExtensionFunctions as $func ) {
713 // Allow closures in PHP 5.3+
714 if ( is_object( $func ) && $func instanceof Closure
) {
715 $profName = $fname . '-extensions-closure';
716 } elseif ( is_array( $func ) ) {
717 if ( is_object( $func[0] ) ) {
718 $profName = $fname . '-extensions-' . get_class( $func[0] ) . '::' . $func[1];
720 $profName = $fname . '-extensions-' . implode( '::', $func );
723 $profName = $fname . '-extensions-' . strval( $func );
726 $ps_ext_func = Profiler
::instance()->scopedProfileIn( $profName );
727 call_user_func( $func );
728 Profiler
::instance()->scopedProfileOut( $ps_ext_func );
731 wfDebug( "Fully initialised\n" );
732 $wgFullyInitialised = true;
734 Profiler
::instance()->scopedProfileOut( $ps_extensions );
735 Profiler
::instance()->scopedProfileOut( $ps_setup );