MediaWiki REL1_36
Setup.php
Go to the documentation of this file.
1<?php
53use Psr\Log\LoggerInterface;
56use Wikimedia\RequestTimeout\RequestTimeout;
57
65// This file must be included from a valid entry point (e.g. WebStart.php, Maintenance.php)
66if ( !defined( 'MEDIAWIKI' ) ) {
67 exit( 1 );
68}
69
70// This file must have global scope.
71$wgScopeTest = 'MediaWiki Setup.php scope test';
72if ( !isset( $GLOBALS['wgScopeTest'] ) || $GLOBALS['wgScopeTest'] !== $wgScopeTest ) {
73 echo "Error, Setup.php must be included from the file scope.\n";
74 die( 1 );
75}
76unset( $wgScopeTest );
77
78// PHP must not be configured to overload mbstring functions. (T5782, T122807)
79// This was deprecated by upstream in PHP 7.2, likely to be removed in PHP 8.0.
80if ( ini_get( 'mbstring.func_overload' ) ) {
81 die( 'MediaWiki does not support installations where mbstring.func_overload is non-zero.' );
82}
83
84// The MW_ENTRY_POINT constant must always exists, to make it safe to access.
85// For compat, we do support older and custom MW entryoints that don't set this,
86// in which case we assign a default here.
87if ( !defined( 'MW_ENTRY_POINT' ) ) {
93 define( 'MW_ENTRY_POINT', 'unknown' );
94}
95
102require_once "$IP/includes/AutoLoader.php";
103require_once "$IP/includes/Defines.php";
104require_once "$IP/includes/DefaultSettings.php";
105require_once "$IP/includes/GlobalFunctions.php";
106
107// Load composer's autoloader if present
108if ( is_readable( "$IP/vendor/autoload.php" ) ) {
109 require_once "$IP/vendor/autoload.php";
110} elseif ( file_exists( "$IP/vendor/autoload.php" ) ) {
111 die( "$IP/vendor/autoload.php exists but is not readable" );
112}
113
114// Assert that composer dependencies were successfully loaded
115if ( !interface_exists( LoggerInterface::class ) ) {
116 $message = (
117 'MediaWiki requires the <a href="https://github.com/php-fig/log">PSR-3 logging ' .
118 "library</a> to be present. This library is not embedded directly in MediaWiki's " .
119 "git repository and must be installed separately by the end user.\n\n" .
120 'Please see the <a href="https://www.mediawiki.org/wiki/Download_from_Git' .
121 '#Fetch_external_libraries">instructions for installing libraries</a> on mediawiki.org ' .
122 'for help on installing the required components.'
123 );
124 echo $message;
125 trigger_error( $message, E_USER_ERROR );
126 die( 1 );
127}
128
129HeaderCallback::register();
130
131// Set the encoding used by PHP for reading HTTP input, and writing output.
132// This is also the default for mbstring functions.
133mb_internal_encoding( 'UTF-8' );
134
139if ( defined( 'MW_CONFIG_CALLBACK' ) ) {
140 call_user_func( MW_CONFIG_CALLBACK );
141} else {
142 if ( !defined( 'MW_CONFIG_FILE' ) ) {
143 define( 'MW_CONFIG_FILE', "$IP/LocalSettings.php" );
144 }
145 require_once MW_CONFIG_FILE;
146}
147
155if ( defined( 'MW_SETUP_CALLBACK' ) ) {
156 call_user_func( MW_SETUP_CALLBACK );
157}
158
159// Start time limit
161 RequestTimeout::singleton()->setWallTimeLimit( $wgRequestTimeLimit );
162}
163
168ExtensionRegistry::getInstance()->loadFromQueue();
169// Don't let any other extensions load
171
172// Set the configured locale on all requests for consistency
173// This must be after LocalSettings.php (and is informed by the installer).
174putenv( "LC_ALL=$wgShellLocale" );
175setlocale( LC_ALL, $wgShellLocale );
176
181if ( $wgScript === false ) {
182 $wgScript = "$wgScriptPath/index.php";
183}
184if ( $wgLoadScript === false ) {
185 $wgLoadScript = "$wgScriptPath/load.php";
186}
187if ( $wgRestPath === false ) {
188 $wgRestPath = "$wgScriptPath/rest.php";
189}
190if ( $wgArticlePath === false ) {
191 if ( $wgUsePathInfo ) {
192 $wgArticlePath = "$wgScript/$1";
193 } else {
194 $wgArticlePath = "$wgScript?title=$1";
195 }
196}
197if ( $wgResourceBasePath === null ) {
199}
200if ( $wgStylePath === false ) {
201 $wgStylePath = "$wgResourceBasePath/skins";
202}
203if ( $wgLocalStylePath === false ) {
204 // Avoid wgResourceBasePath here since that may point to a different domain (e.g. CDN)
205 $wgLocalStylePath = "$wgScriptPath/skins";
206}
207if ( $wgExtensionAssetsPath === false ) {
208 $wgExtensionAssetsPath = "$wgResourceBasePath/extensions";
209}
210
211// For backwards compatibility, the value of wgLogos is copied to wgLogo.
212// This is because some extensions/skins may be using $config->get('Logo')
213// to access the value.
214if ( $wgLogos !== false && isset( $wgLogos['1x'] ) ) {
215 $wgLogo = $wgLogos['1x'];
216}
217if ( $wgLogo === false ) {
218 $wgLogo = "$wgResourceBasePath/resources/assets/wiki.png";
219}
220
221if ( $wgUploadPath === false ) {
222 $wgUploadPath = "$wgScriptPath/images";
223}
224if ( $wgUploadDirectory === false ) {
225 $wgUploadDirectory = "$IP/images";
226}
227if ( $wgReadOnlyFile === false ) {
228 $wgReadOnlyFile = "{$wgUploadDirectory}/lock_yBgMBwiR";
229}
230if ( $wgFileCacheDirectory === false ) {
231 $wgFileCacheDirectory = "{$wgUploadDirectory}/cache";
232}
233if ( $wgDeletedDirectory === false ) {
234 $wgDeletedDirectory = "{$wgUploadDirectory}/deleted";
235}
236if ( $wgGitInfoCacheDirectory === false && $wgCacheDirectory !== false ) {
237 $wgGitInfoCacheDirectory = "{$wgCacheDirectory}/gitinfo";
238}
239if ( $wgSharedPrefix === false ) {
241}
242if ( $wgSharedSchema === false ) {
244}
245if ( $wgMetaNamespace === false ) {
246 $wgMetaNamespace = str_replace( ' ', '_', $wgSitename );
247}
248
249// Blacklisted file extensions shouldn't appear on the "allowed" list
250$wgFileExtensions = array_values( array_diff( $wgFileExtensions, $wgFileBlacklist ) );
251
252// Fix path to icon images after they were moved in 1.24
253if ( $wgRightsIcon ) {
254 $wgRightsIcon = str_replace(
255 "{$wgStylePath}/common/images/",
256 "{$wgResourceBasePath}/resources/assets/licenses/",
258 );
259}
260
261if ( isset( $wgFooterIcons['copyright']['copyright'] )
262 && $wgFooterIcons['copyright']['copyright'] === []
263) {
264 if ( $wgRightsIcon || $wgRightsText ) {
265 $wgFooterIcons['copyright']['copyright'] = [
266 'url' => $wgRightsUrl,
267 'src' => $wgRightsIcon,
268 'alt' => $wgRightsText,
269 ];
270 }
271}
272
273if ( isset( $wgFooterIcons['poweredby'] )
274 && isset( $wgFooterIcons['poweredby']['mediawiki'] )
275 && $wgFooterIcons['poweredby']['mediawiki']['src'] === null
276) {
277 $wgFooterIcons['poweredby']['mediawiki']['src'] =
278 "$wgResourceBasePath/resources/assets/poweredby_mediawiki_88x31.png";
279 $wgFooterIcons['poweredby']['mediawiki']['srcset'] =
280 "$wgResourceBasePath/resources/assets/poweredby_mediawiki_132x47.png 1.5x, " .
281 "$wgResourceBasePath/resources/assets/poweredby_mediawiki_176x62.png 2x";
282}
283
292
297 'name' => 'fsLockManager',
298 'class' => FSLockManager::class,
299 'lockDirectory' => "{$wgUploadDirectory}/lockdir",
300];
301$wgLockManagers[] = [
302 'name' => 'nullLockManager',
303 'class' => NullLockManager::class,
304];
305
311 'imagesPerRow' => 0,
312 'imageWidth' => 120,
313 'imageHeight' => 120,
314 'captionLength' => true,
315 'showBytes' => true,
316 'showDimensions' => true,
317 'mode' => 'traditional',
318];
319
323if ( !$wgLocalFileRepo ) {
325 'class' => LocalRepo::class,
326 'name' => 'local',
327 'directory' => $wgUploadDirectory,
328 'scriptDirUrl' => $wgScriptPath,
330 'hashLevels' => $wgHashedUploadDirectory ? 2 : 0,
331 'thumbScriptUrl' => $wgThumbnailScriptPath,
332 'transformVia404' => !$wgGenerateThumbnailOnParse,
333 'deletedDir' => $wgDeletedDirectory,
334 'deletedHashLevels' => $wgHashedUploadDirectory ? 3 : 0
335 ];
336}
337
338if ( !isset( $wgLocalFileRepo['backend'] ) ) {
339 // Create a default FileBackend name.
340 // FileBackendGroup will register a default, if absent from $wgFileBackends.
341 $wgLocalFileRepo['backend'] = $wgLocalFileRepo['name'] . '-backend';
342}
343
347if ( $wgUseSharedUploads ) {
348 if ( $wgSharedUploadDBname ) {
350 'class' => ForeignDBRepo::class,
351 'name' => 'shared',
352 'directory' => $wgSharedUploadDirectory,
353 'url' => $wgSharedUploadPath,
354 'hashLevels' => $wgHashedSharedUploadDirectory ? 2 : 0,
355 'thumbScriptUrl' => $wgSharedThumbnailScriptPath,
356 'transformVia404' => !$wgGenerateThumbnailOnParse,
357 'dbType' => $wgDBtype,
358 'dbServer' => $wgDBserver,
359 'dbUser' => $wgDBuser,
360 'dbPassword' => $wgDBpassword,
361 'dbName' => $wgSharedUploadDBname,
362 'dbFlags' => ( $wgDebugDumpSql ? DBO_DEBUG : 0 ) | DBO_DEFAULT,
363 'tablePrefix' => $wgSharedUploadDBprefix,
364 'hasSharedCache' => $wgCacheSharedUploads,
365 'descBaseUrl' => $wgRepositoryBaseUrl,
366 'fetchDescription' => $wgFetchCommonsDescriptions,
367 ];
368 } else {
370 'class' => FileRepo::class,
371 'name' => 'shared',
372 'directory' => $wgSharedUploadDirectory,
373 'url' => $wgSharedUploadPath,
374 'hashLevels' => $wgHashedSharedUploadDirectory ? 2 : 0,
375 'thumbScriptUrl' => $wgSharedThumbnailScriptPath,
376 'transformVia404' => !$wgGenerateThumbnailOnParse,
377 'descBaseUrl' => $wgRepositoryBaseUrl,
378 'fetchDescription' => $wgFetchCommonsDescriptions,
379 ];
380 }
381}
384 'class' => ForeignAPIRepo::class,
385 'name' => 'wikimediacommons',
386 'apibase' => 'https://commons.wikimedia.org/w/api.php',
387 'url' => 'https://upload.wikimedia.org/wikipedia/commons',
388 'thumbUrl' => 'https://upload.wikimedia.org/wikipedia/commons/thumb',
389 'hashLevels' => 2,
390 'transformVia404' => true,
391 'fetchDescription' => true,
392 'descriptionCacheExpiry' => 43200,
393 'apiThumbCacheExpiry' => 0,
394 ];
395}
396foreach ( $wgForeignFileRepos as &$repo ) {
397 if ( !isset( $repo['directory'] ) && $repo['class'] === ForeignAPIRepo::class ) {
398 $repo['directory'] = $wgUploadDirectory; // b/c
399 }
400 if ( !isset( $repo['backend'] ) ) {
401 $repo['backend'] = $repo['name'] . '-backend';
402 }
403}
404unset( $repo ); // no global pollution; destroy reference
405
406$rcMaxAgeDays = $wgRCMaxAge / ( 3600 * 24 );
407// Ensure that default user options are not invalid, since that breaks Special:Preferences
408$wgDefaultUserOptions['rcdays'] = min(
409 $wgDefaultUserOptions['rcdays'],
410 ceil( $rcMaxAgeDays )
411);
412$wgDefaultUserOptions['watchlistdays'] = min(
413 $wgDefaultUserOptions['watchlistdays'],
414 ceil( $rcMaxAgeDays )
415);
416unset( $rcMaxAgeDays );
417
418if ( !$wgCookiePrefix ) {
419 if ( $wgSharedDB && $wgSharedPrefix && in_array( 'user', $wgSharedTables ) ) {
421 } elseif ( $wgSharedDB && in_array( 'user', $wgSharedTables ) ) {
423 } elseif ( $wgDBprefix ) {
425 } else {
427 }
428}
429$wgCookiePrefix = strtr( $wgCookiePrefix, '=,; +."\'\\[', '__________' );
430
431if ( $wgEnableEmail ) {
433} else {
434 // Disable all other email settings automatically if $wgEnableEmail
435 // is set to false. - T65678
436 $wgAllowHTMLEmail = false;
437 $wgEmailAuthentication = false; // do not require auth if you're not sending email anyway
447 unset( $wgGroupPermissions['user']['sendemail'] );
451}
452
457$wgCanonicalNamespaceNames = NamespaceInfo::CANONICAL_NAMES;
458
459// @todo UGLY UGLY
460if ( is_array( $wgExtraNamespaces ) ) {
462}
463
464// Hard-deprecate setting $wgDummyLanguageCodes in LocalSettings.php
465if ( count( $wgDummyLanguageCodes ) !== 0 ) {
466 wfDeprecated( '$wgDummyLanguageCodes', '1.29' );
467}
468// Merge in the legacy language codes, incorporating overrides from the config
470 // Internal language codes of the private-use area which get mapped to
471 // themselves.
472 'qqq' => 'qqq', // Used for message documentation
473 'qqx' => 'qqx', // Used for viewing message keys
474] + $wgExtraLanguageCodes + LanguageCode::getDeprecatedCodeMapping();
475// Merge in (inverted) BCP 47 mappings
476foreach ( LanguageCode::getNonstandardLanguageCodeMapping() as $code => $bcp47 ) {
477 $bcp47 = strtolower( $bcp47 ); // force case-insensitivity
478 if ( !isset( $wgDummyLanguageCodes[$bcp47] ) ) {
479 $wgDummyLanguageCodes[$bcp47] = $wgDummyLanguageCodes[$code] ?? $code;
480 }
481}
482unset( $code ); // no global pollution; destroy reference
483unset( $bcp47 ); // no global pollution; destroy reference
484
485// Temporary backwards-compatibility reading of old replica lag settings as of MediaWiki 1.36,
486// to support sysadmins who fail to update their settings immediately:
487
488if ( isset( $wgSlaveLagWarning ) ) {
489 // If the old value is set to something other than the default, use it.
490 if ( $wgDatabaseReplicaLagWarning === 10 && $wgSlaveLagWarning !== 10 ) {
491 $wgDatabaseReplicaLagWarning = $wgSlaveLagWarning;
493 '$wgSlaveLagWarning set but $wgDatabaseReplicaLagWarning unchanged; using $wgSlaveLagWarning',
494 '1.36'
495 );
496 }
497} else {
498 // Backwards-compatibility for extensions that read this value.
499 $wgSlaveLagWarning = $wgDatabaseReplicaLagWarning;
500}
501
502if ( isset( $wgSlaveLagCritical ) ) {
503 // If the old value is set to something other than the default, use it.
504 if ( $wgDatabaseReplicaLagCritical === 30 && $wgSlaveLagCritical !== 30 ) {
505 $wgDatabaseReplicaLagCritical = $wgSlaveLagCritical;
507 '$wgSlaveLagCritical set but $wgDatabaseReplicaLagCritical unchanged; using $wgSlaveLagCritical',
508 '1.36'
509 );
510 }
511} else {
512 // Backwards-compatibility for extensions that read this value.
513 $wgSlaveLagCritical = $wgDatabaseReplicaLagCritical;
514}
515
517 Wikimedia\suppressWarnings();
518 $wgCacheEpoch = max( $wgCacheEpoch, gmdate( 'YmdHis', filemtime( "$IP/LocalSettings.php" ) ) );
519 Wikimedia\restoreWarnings();
520}
521
522if ( $wgNewUserLog ) {
523 // Add new user log type
524 $wgLogTypes[] = 'newusers';
525 $wgLogNames['newusers'] = 'newuserlogpage';
526 $wgLogHeaders['newusers'] = 'newuserlogpagetext';
527 $wgLogActionsHandlers['newusers/newusers'] = NewUsersLogFormatter::class;
528 $wgLogActionsHandlers['newusers/create'] = NewUsersLogFormatter::class;
529 $wgLogActionsHandlers['newusers/create2'] = NewUsersLogFormatter::class;
530 $wgLogActionsHandlers['newusers/byemail'] = NewUsersLogFormatter::class;
531 $wgLogActionsHandlers['newusers/autocreate'] = NewUsersLogFormatter::class;
532}
533
534if ( $wgPageCreationLog ) {
535 // Add page creation log type
536 $wgLogTypes[] = 'create';
537 $wgLogActionsHandlers['create/create'] = LogFormatter::class;
538}
539
541 $wgLogTypes[] = 'pagelang';
542 $wgLogActionsHandlers['pagelang/pagelang'] = PageLangLogFormatter::class;
543}
544
545if ( $wgCookieSecure === 'detect' ) {
547}
548
549// Backwards compatibility with old password limits
550if ( $wgMinimalPasswordLength !== false ) {
551 $wgPasswordPolicy['policies']['default']['MinimalPasswordLength'] = $wgMinimalPasswordLength;
552}
553
554if ( $wgMaximalPasswordLength !== false ) {
555 $wgPasswordPolicy['policies']['default']['MaximalPasswordLength'] = $wgMaximalPasswordLength;
556}
557
558if ( $wgPHPSessionHandling !== 'enable' &&
559 $wgPHPSessionHandling !== 'warn' &&
560 $wgPHPSessionHandling !== 'disable'
561) {
562 $wgPHPSessionHandling = 'warn';
563}
564if ( defined( 'MW_NO_SESSION' ) ) {
565 // If the entry point wants no session, force 'disable' here unless they
566 // specifically set it to the (undocumented) 'warn'.
567 $wgPHPSessionHandling = MW_NO_SESSION === 'warn' ? 'warn' : 'disable';
568}
569
571
572// Enable the global service locator.
573MediaWikiServices::allowGlobalInstance();
574
575// Define a constant that indicates that the bootstrapping of the service locator
576// is complete.
577define( 'MW_SERVICE_BOOTSTRAP_COMPLETE', 1 );
578
579MWExceptionHandler::installHandler();
580
581// T30798: $wgServer must be explicitly set
582// @phan-suppress-next-line PhanSuspiciousValueComparisonInGlobalScope
583if ( $wgServer === false ) {
584 throw new FatalError(
585 '$wgServer must be set in LocalSettings.php. ' .
586 'See <a href="https://www.mediawiki.org/wiki/Manual:$wgServer">' .
587 'https://www.mediawiki.org/wiki/Manual:$wgServer</a>.'
588 );
589}
590
591if ( $wgCanonicalServer === false ) {
593}
594
595// Set server name
597if ( $wgServerName !== false ) {
598 wfWarn( '$wgServerName should be derived from $wgCanonicalServer, '
599 . 'not customized. Overwriting $wgServerName.' );
600}
602unset( $serverParts );
603
604// Set defaults for configuration variables
605// that are derived from the server name by default
606// Note: $wgEmergencyContact and $wgPasswordSender may be false or empty string (T104142)
607if ( !$wgEmergencyContact ) {
608 $wgEmergencyContact = 'wikiadmin@' . $wgServerName;
609}
610if ( !$wgPasswordSender ) {
611 $wgPasswordSender = 'apache@' . $wgServerName;
612}
613if ( !$wgNoReplyAddress ) {
615}
616
617if ( $wgSecureLogin && substr( $wgServer, 0, 2 ) !== '//' ) {
618 $wgSecureLogin = false;
619 wfWarn( 'Secure login was enabled on a server that only supports '
620 . 'HTTP or HTTPS. Disabling secure login.' );
621}
622
624
625// Now that GlobalFunctions is loaded, set defaults that depend on it.
626if ( $wgTmpDirectory === false ) {
628}
629
630if ( $wgMainWANCache === false ) {
631 // Setup a WAN cache from $wgMainCacheType
632 $wgMainWANCache = 'mediawiki-main-default';
634 'class' => WANObjectCache::class,
635 'cacheId' => $wgMainCacheType,
636 ];
637}
638
640 // Apply $wgSharedDB table aliases for the local LB (all non-foreign DB connections)
641 MediaWikiServices::getInstance()->getDBLoadBalancer()->setTableAliases(
642 array_fill_keys(
644 [
645 'dbname' => $wgSharedDB,
646 'schema' => $wgSharedSchema,
647 'prefix' => $wgSharedPrefix
648 ]
649 )
650 );
651}
652
653// Raise the memory limit if it's too low
654// Note, this makes use of wfDebug, and thus should not be before
655// MWDebug::init() is called.
657
663if ( $wgLocaltimezone === null ) {
664 Wikimedia\suppressWarnings();
665 $wgLocaltimezone = date_default_timezone_get();
666 Wikimedia\restoreWarnings();
667}
668
669date_default_timezone_set( $wgLocaltimezone );
670if ( $wgLocalTZoffset === null ) {
671 $wgLocalTZoffset = (int)date( 'Z' ) / 60;
672}
673// The part after the System| is ignored, but rest of MW fills it
674// out as the local offset.
675$wgDefaultUserOptions['timecorrection'] = "System|$wgLocalTZoffset";
676
677if ( !$wgDBerrorLogTZ ) {
679}
680
681// Initialize the request object in $wgRequest
682$wgRequest = RequestContext::getMain()->getRequest(); // BackCompat
683// Set user IP/agent information for agent session consistency purposes
684$cpPosInfo = LBFactory::getCPInfoFromCookieValue(
685 // The cookie has no prefix and is set by MediaWiki::preOutputCommit()
686 $wgRequest->getCookie( 'cpPosIndex', '' ),
687 // Mitigate broken client-side cookie expiration handling (T190082)
688 time() - ChronologyProtector::POSITION_COOKIE_TTL
689);
690MediaWikiServices::getInstance()->getDBLoadBalancerFactory()->setRequestInfo( [
691 'IPAddress' => $wgRequest->getIP(),
692 'UserAgent' => $wgRequest->getHeader( 'User-Agent' ),
693 'ChronologyProtection' => $wgRequest->getHeader( 'MediaWiki-Chronology-Protection' ),
694 'ChronologyPositionIndex' => $wgRequest->getInt( 'cpPosIndex', $cpPosInfo['index'] ),
695 'ChronologyClientId' => $cpPosInfo['clientId']
696 ?? $wgRequest->getHeader( 'MediaWiki-Chronology-Client-Id' )
697] );
698unset( $cpPosInfo );
699// Make sure that object caching does not undermine the ChronologyProtector improvements
700if ( $wgRequest->getCookie( 'UseDC', '' ) === 'master' ) {
701 // The user is pinned to the primary DC, meaning that they made recent changes which should
702 // be reflected in their subsequent web requests. Avoid the use of interim cache keys because
703 // they use a blind TTL and could be stale if an object changes twice in a short time span.
704 MediaWikiServices::getInstance()->getMainWANObjectCache()->useInterimHoldOffCaching( false );
705}
706
707// Useful debug output
708( static function () {
710 $logger = LoggerFactory::getInstance( 'wfDebug' );
711 if ( $wgCommandLineMode ) {
712 $self = $_SERVER['PHP_SELF'] ?? '';
713 $logger->debug( "\n\nStart command line script $self" );
714 } else {
715 $debug = "\n\nStart request {$wgRequest->getMethod()} {$wgRequest->getRequestURL()}\n";
716 $debug .= "IP: " . $wgRequest->getIP() . "\n";
717 $debug .= "HTTP HEADERS:\n";
718 foreach ( $wgRequest->getAllHeaders() as $name => $value ) {
719 $debug .= "$name: $value\n";
720 }
721 $debug .= "(end headers)";
722 $logger->debug( $debug );
723 }
724} )();
725
726// Most of the config is out, some might want to run hooks here.
727Hooks::runner()->onSetupAfterCache();
728
729// Now that variant lists may be available...
730$wgRequest->interpolateTitle();
731
736if ( !defined( 'MW_NO_SESSION' ) && !$wgCommandLineMode ) {
737 // If session.auto_start is there, we can't touch session name
738 if ( $wgPHPSessionHandling !== 'disable' && !wfIniGetBool( 'session.auto_start' ) ) {
739 HeaderCallback::warnIfHeadersSent();
740 session_name( $wgSessionName ?: $wgCookiePrefix . '_session' );
741 }
742
743 // Create the SessionManager singleton and set up our session handler,
744 // unless we're specifically asked not to.
745 if ( !defined( 'MW_NO_SESSION_HANDLER' ) ) {
746 MediaWiki\Session\PHPSessionHandler::install(
747 MediaWiki\Session\SessionManager::singleton()
748 );
749 }
750
751 $contLang = MediaWikiServices::getInstance()->getContentLanguage();
752
753 // Initialize the session
754 try {
755 $session = MediaWiki\Session\SessionManager::getGlobalSession();
756 } catch ( MediaWiki\Session\SessionOverflowException $ex ) {
757 // The exception is because the request had multiple possible
758 // sessions tied for top priority. Report this to the user.
759 $list = [];
760 foreach ( $ex->getSessionInfos() as $info ) {
761 $list[] = $info->getProvider()->describe( $contLang );
762 }
763 $list = $contLang->listToText( $list );
764 throw new HttpError( 400,
765 Message::newFromKey( 'sessionmanager-tie', $list )->inLanguage( $contLang )
766 );
767 }
768
769 unset( $contLang );
770
771 if ( $session->isPersistent() ) {
772 $wgInitialSessionId = $session->getSessionId();
773 }
774
775 $session->renew();
776 if ( MediaWiki\Session\PHPSessionHandler::isEnabled() &&
777 ( $session->isPersistent() || $session->shouldRememberUser() ) &&
778 session_id() !== $session->getId()
779 ) {
780 // Start the PHP-session for backwards compatibility
781 if ( session_id() !== '' ) {
782 wfDebugLog( 'session', 'PHP session {old_id} was already started, changing to {new_id}', 'all', [
783 'old_id' => session_id(),
784 'new_id' => $session->getId(),
785 ] );
786 session_write_close();
787 }
788 session_id( $session->getId() );
789 session_start();
790 }
791
792 unset( $session );
793} else {
794 // Even if we didn't set up a global Session, still install our session
795 // handler unless specifically requested not to.
796 if ( !defined( 'MW_NO_SESSION_HANDLER' ) ) {
797 MediaWiki\Session\PHPSessionHandler::install(
798 MediaWiki\Session\SessionManager::singleton()
799 );
800 }
801}
802
808$wgUser = RequestContext::getMain()->getUser(); // BackCompat
809
814
818$wgOut = RequestContext::getMain()->getOutput(); // BackCompat
819
824$wgParser = new DeprecatedGlobal( 'wgParser', static function () {
825 return MediaWikiServices::getInstance()->getParser();
826}, '1.32' );
827
831$wgTitle = null;
832
833// Extension setup functions
834// Entries should be added to this variable during the inclusion
835// of the extension file. This allows the extension to perform
836// any necessary initialisation in the fully initialised environment
837foreach ( $wgExtensionFunctions as $func ) {
838 call_user_func( $func );
839}
840unset( $func ); // no global pollution; destroy reference
841
842// If the session user has a 0 id but a valid name, that means we need to
843// autocreate it.
844if ( !defined( 'MW_NO_SESSION' ) && !$wgCommandLineMode ) {
845 $sessionUser = MediaWiki\Session\SessionManager::getGlobalSession()->getUser();
846 if ( $sessionUser->getId() === 0 &&
847 MediaWikiServices::getInstance()->getUserNameUtils()->isValid( $sessionUser->getName() )
848 ) {
849 $res = MediaWikiServices::getInstance()->getAuthManager()->autoCreateUser(
850 $sessionUser,
851 MediaWiki\Auth\AuthManager::AUTOCREATE_SOURCE_SESSION,
852 true
853 );
854 \MediaWiki\Logger\LoggerFactory::getInstance( 'authevents' )->info( 'Autocreation attempt', [
855 'event' => 'autocreate',
856 'status' => strval( $res ),
857 ] );
858 unset( $res );
859 }
860 unset( $sessionUser );
861}
862
863if ( !$wgCommandLineMode ) {
865}
866
868
869// T264370
870if ( !defined( 'MW_NO_SESSION' ) && !$wgCommandLineMode ) {
871 MediaWiki\Session\SessionManager::singleton()->logPotentialSessionLeakage();
872}
$wgRightsIcon
Override for copyright metadata.
$wgCacheEpoch
Set this to current time to invalidate all prior cached pages.
bool $wgPageLanguageUseDB
Enable page language feature Allows setting page language in database.
string $wgSharedUploadDirectory
Shortcut for the 'directory' setting of $wgForeignFileRepos.
$wgUsePathInfo
Whether to support URLs like index.php/Page_title These often break when PHP is set up in CGI mode.
$wgMemoryLimit
The minimum amount of memory that MediaWiki "needs"; MediaWiki will try to raise PHP's memory limit i...
$wgEmergencyContact
Site admin email address.
$wgDBprefix
Current wiki database table name prefix.
$wgDBuser
Database username.
string $wgPHPSessionHandling
Whether to use PHP session handling ($_SESSION and session_*() functions)
bool $wgCacheSharedUploads
Shortcut for the ForeignDBRepo 'hasSharedCache' setting in $wgForeignFileRepos.
bool string $wgSharedUploadDBname
Shortcut for the ForeignDBRepo 'dbName' setting in $wgForeignFileRepos.
$wgScript
The URL path to index.php.
$wgUseInstantCommons
Use Wikimedia Commons as a foreign file repository.
bool $wgHashedSharedUploadDirectory
Shortcut for the 'hashLevels' setting of $wgForeignFileRepos.
$wgCacheDirectory
Directory for caching data in the local filesystem.
$wgRightsUrl
Set this to specify an external URL containing details about the content license used on your wiki.
$wgSharedTables
$wgSessionName
Override to customise the session name.
$wgMainCacheType
Main cache type.
$wgPasswordPolicy
Password policy for the wiki.
$wgLogNames
Lists the message key string for each log type.
$wgInvalidateCacheOnLocalSettingsChange
Invalidate various caches when LocalSettings.php changes.
$wgLocalStylePath
The URL path of the skins directory.
$wgThumbnailScriptPath
Give a path here to use thumb.php for thumbnail generation on client request, instead of generating t...
$wgExtraNamespaces
Additional namespaces.
$wgTmpDirectory
The local filesystem path to a temporary directory.
bool $wgGenerateThumbnailOnParse
Render thumbnails while parsing wikitext.
bool $wgUseSharedUploads
Shortcut for adding an entry to $wgForeignFileRepos.
string $wgSharedUploadDBprefix
Shortcut for the ForeignDBRepo 'tablePrefix' setting in $wgForeignFileRepos.
$wgDBtype
Database type.
$wgDBmwschema
Current wiki database schema name.
$wgNoReplyAddress
Reply-To address for e-mail notifications.
$wgDBname
Current wiki database name.
$wgDBerrorLogTZ
Timezone to use in the error log.
$wgUploadDirectory
The filesystem path of the images directory.
$wgLogTypes
The logging system has two levels: an event type, which describes the general category and can be vie...
$wgMaximalPasswordLength
Specifies the maximal length of a user password (T64685).
$wgSitename
Name of the site.
$wgReadOnlyFile
If this lock file exists (size > 0), the wiki will be forced into read-only mode.
$wgFileCacheDirectory
Directory where the cached page will be saved.
$wgRightsText
If either $wgRightsUrl or $wgRightsPage is specified then this variable gives the text for the link.
$wgGitInfoCacheDirectory
Directory where GitInfo will look for pre-computed cache files.
$wgPageCreationLog
Maintain a log of page creations at Special:Log/create?
$wgDatabaseReplicaLagCritical
$wgResourceBasePath
The default 'remoteBasePath' value for instances of ResourceLoaderFileModule.
$wgFooterIcons
Abstract list of footer icons for skins in place of old copyrightico and poweredbyico code You can ad...
$wgArticlePath
The URL path for primary article page views.
$wgUploadPath
The URL path for the images directory.
$wgFileBlacklist
Files with these extensions will never be allowed as uploads.
$wgEnableEmail
Set to true to enable the e-mail basic features: Password reminders, etc.
$wgExtensionFunctions
A list of callback functions which are called once MediaWiki is fully initialised.
$wgShellLocale
Locale for LC_ALL, to provide a known environment for locale-sensitive operations.
$wgSecureLogin
This is to let user authenticate using https when they come from http.
$wgRCMaxAge
Recentchanges items are periodically purged; entries older than this many seconds will go.
bool $wgHashedUploadDirectory
Shortcut for setting hashLevels=2 in $wgLocalFileRepo.
$wgLocaltimezone
Fake out the timezone that the server thinks it's in.
$wgUploadBaseUrl
If set, this URL is added to the start of $wgUploadPath to form a complete upload URL.
bool $wgFetchCommonsDescriptions
Shortcut for the 'fetchDescription' setting of $wgForeignFileRepos.
$wgGroupPermissions
Permission keys given to users in each group.
$wgRestPath
The URL path to the REST API Defaults to "{$wgScriptPath}/rest.php".
string $wgSharedThumbnailScriptPath
Shortcut for the 'thumbScriptUrl' setting of $wgForeignFileRepos.
$wgLocalFileRepo
File repository structures.
$wgDeletedDirectory
What directory to place deleted uploads in.
$wgScriptPath
The path we should point to.
$wgWANObjectCaches
Advanced WAN object cache configuration.
$wgAllowHTMLEmail
For parts of the system that have been updated to provide HTML email content, send both text and HTML...
array false $wgLogos
Specification for different versions of the wiki logo.
$wgExtensionAssetsPath
The URL path of the extensions directory.
$wgForeignFileRepos
Enable the use of files from one or more other wikis.
$wgRepositoryBaseUrl
Shortcut for the 'descBaseUrl' setting of $wgForeignFileRepos.
$wgLogHeaders
Lists the message key string for descriptive text to be shown at the top of each log type.
int null $wgRequestTimeLimit
Set a limit on server request wall clock time.
$wgSharedDB
Shared database for multiple wikis.
$wgDebugDumpSql
Write SQL queries to the debug log.
$wgDatabaseReplicaLagWarning
If lag is higher than $wgDatabaseReplicaLagWarning, show a warning in some special pages (like watchl...
$wgDBserver
Database host name or IP address.
bool $wgForceHTTPS
If this is true, when an insecure HTTP request is received, always redirect to HTTPS.
$wgLoadScript
The URL path to load.php.
$wgCookieSecure
Whether the "secure" flag should be set on the cookie.
$wgExtraLanguageCodes
List of mappings from one language code to another.
$wgCanonicalServer
Canonical URL of the server, to use in IRC feeds and notification e-mails.
$wgStylePath
The URL path of the skins directory.
$wgServer
URL of the server.
$wgMinimalPasswordLength
Specifies the minimal length of a user password.
$wgMetaNamespace
Name of the project namespace.
$wgLogo
The URL path of the wiki logo.
$wgSharedSchema
$wgPasswordSender
Sender email address for e-mail notifications.
$wgLogActionsHandlers
The same as above, but here values are names of classes, not messages.
string $wgSharedUploadPath
Shortcut for the 'url' setting of $wgForeignFileRepos.
$wgLocalTZoffset
Set an offset from UTC in minutes to use for the default timezone setting for anonymous users and new...
$wgSharedPrefix
$wgMainWANCache
Main Wide-Area-Network cache type.
$wgDBpassword
Database user's password.
$wgNewUserLog
Maintain a log of newusers at Special:Log/newusers?
const NS_MEDIAWIKI
Definition Defines.php:72
const PROTO_HTTP
Definition Defines.php:203
global $wgCommandLineMode
wfParseUrl( $url)
parse_url() work-alike, but non-broken.
wfTempDir()
Tries to get the system directory for temporary files.
wfWarn( $msg, $callerOffset=1, $level=E_USER_NOTICE)
Send a warning either to the debug log or in a PHP error depending on $wgDevelopmentWarnings.
wfMemoryLimit( $newLimit)
Raise PHP's memory limit (if needed).
wfIniGetBool( $setting)
Safety wrapper around ini_get() for boolean settings.
wfExpandUrl( $url, $defaultProto=PROTO_CURRENT)
Expand a potentially local URL to a fully-qualified URL.
wfDebugLog( $logGroup, $text, $dest='all', array $context=[])
Send a line to a supplementary debug log file, if configured, or main debug log if not.
wfDeprecated( $function, $version=false, $component=false, $callerOffset=2)
Logs a warning that $function is deprecated.
$wgGalleryOptions
Default parameters for the "<gallery>" tag.
Definition Setup.php:310
if( $wgScript===false) if($wgLoadScript===false) if( $wgRestPath===false) if($wgArticlePath===false) if( $wgResourceBasePath===null) if($wgStylePath===false) if( $wgLocalStylePath===false) if($wgExtensionAssetsPath===false) if( $wgLogos !==false &&isset( $wgLogos['1x'])) if($wgLogo===false) if( $wgUploadPath===false) if($wgUploadDirectory===false) if( $wgReadOnlyFile===false) if($wgFileCacheDirectory===false) if( $wgDeletedDirectory===false) if($wgGitInfoCacheDirectory===false &&$wgCacheDirectory !==false) if( $wgSharedPrefix===false) if($wgSharedSchema===false) if( $wgMetaNamespace===false) $wgFileExtensions
Expand dynamic defaults and shortcuts.
Definition Setup.php:250
if(is_array($wgExtraNamespaces)) if(count( $wgDummyLanguageCodes) !==0) $wgDummyLanguageCodes
Definition Setup.php:469
$wgEnotifWatchlist
Definition Setup.php:446
$wgEnotifMaxRecips
Definition Setup.php:441
$wgEnotifUserTalk
Definition Setup.php:445
$cpPosInfo
Definition Setup.php:684
$wgEnableUserEmail
Definition Setup.php:438
$rcMaxAgeDays
Definition Setup.php:406
$wgOut
Definition Setup.php:818
$wgCanonicalNamespaceNames
Definitions of the NS_ constants are in Defines.php.
Definition Setup.php:457
$wgParser
Definition Setup.php:824
if(!defined('MW_NO_SESSION') &&! $wgCommandLineMode) if(! $wgCommandLineMode) $wgFullyInitialised
Definition Setup.php:867
$wgEnotifFromEditor
Definition Setup.php:439
$wgUseEnotif
Definition Setup.php:448
$wgEnotifRevealEditorAddress
Definition Setup.php:443
if(!defined( 'MEDIAWIKI')) $wgScopeTest
Environment checks.
Definition Setup.php:71
if(! $wgCookiePrefix) $wgCookiePrefix
Definition Setup.php:429
$wgEnotifImpersonal
Definition Setup.php:440
$wgUsersNotifiedOnAllChanges
Definition Setup.php:450
if( $wgRightsIcon) if(isset($wgFooterIcons[ 'copyright'][ 'copyright']) &&$wgFooterIcons[ 'copyright'][ 'copyright']===[]) if(isset( $wgFooterIcons['poweredby']) &&isset( $wgFooterIcons['poweredby']['mediawiki']) && $wgFooterIcons['poweredby']['mediawiki']['src']===null) $wgNamespaceProtection[NS_MEDIAWIKI]
Unconditional protection for NS_MEDIAWIKI since otherwise it's too easy for a sysadmin to set $wgName...
Definition Setup.php:291
$wgUserEmailUseReplyTo
Definition Setup.php:449
if(! $wgDBerrorLogTZ) $wgRequest
Definition Setup.php:682
$wgLang
Definition Setup.php:813
if($wgServer===false) if( $wgCanonicalServer===false) $serverParts
Definition Setup.php:596
MediaWiki Session SessionId null $wgInitialSessionId
The persistent session ID (if any) loaded at startup.
Definition Setup.php:735
if( $wgServerName !==false) $wgServerName
Definition Setup.php:601
$wgEnotifMinorEdits
Definition Setup.php:442
$wgLockManagers[]
Initialise $wgLockManagers to include basic FS version.
Definition Setup.php:296
$wgDefaultUserOptions['rcdays']
Definition Setup.php:408
$wgTitle
Definition Setup.php:831
$wgEmailAuthentication
Definition Setup.php:437
if(! $wgEmergencyContact) if(! $wgPasswordSender) if(! $wgNoReplyAddress) if( $wgSecureLogin &&substr( $wgServer, 0, 2) !=='//') $wgVirtualRestConfig['global']['domain']
Definition Setup.php:623
$wgEnotifUseRealName
Definition Setup.php:444
Class to allow throwing wfDeprecated warnings when people use globals that we do not want them to.
Abort the web request with a custom HTML string that will represent the entire response.
static runner()
Get a HookRunner instance for calling hooks using the new interfaces.
Definition Hooks.php:172
Show an error that looks like an HTTP server error.
Definition HttpError.php:32
static setup()
Definition MWDebug.php:78
PSR-3 logger instance factory.
MediaWikiServices is the service locator for the application scope of MediaWiki.
static newFromKey( $key,... $params)
Factory function that is just wrapper for the real constructor.
Definition Message.php:397
static schedulePingback()
Schedule a deferred callable that will check if a pingback should be sent and (if so) proceed to send...
Definition Pingback.php:290
static getMain()
Get the RequestContext object associated with the main request.
Stub object for the user language.
static detectProtocol()
Detect the protocol from $_SERVER.
Provide a given client with protection against visible database lag.
An interface for generating database load balancers.
Definition LBFactory.php:41
const MW_CONFIG_CALLBACK
Definition install.php:28
const MW_NO_SESSION
Definition load.php:32
$debug
Definition mcc.php:31
A helper class for throttling authentication attempts.
const DBO_DEFAULT
Definition defines.php:13
const DBO_DEBUG
Definition defines.php:9