78use Psr\Log\LoggerInterface;
79use Wikimedia\RequestTimeout\RequestTimeout;
89if ( !defined(
'MEDIAWIKI' ) ) {
95if ( ini_get(
'mbstring.func_overload' ) ) {
96 die(
'MediaWiki does not support installations where mbstring.func_overload is non-zero.' );
102if ( !defined(
'MW_ENTRY_POINT' ) ) {
108 define(
'MW_ENTRY_POINT',
'unknown' );
125require_once MW_INSTALL_PATH .
'/includes/AutoLoader.php';
126require_once MW_INSTALL_PATH .
'/includes/Defines.php';
129if ( !interface_exists( LoggerInterface::class ) ) {
131 'MediaWiki requires the <a href="https://github.com/php-fig/log">PSR-3 logging ' .
132 "library</a> to be present. This library is not embedded directly in MediaWiki's " .
133 "git repository and must be installed separately by the end user.\n\n" .
134 'Please see the <a href="https://www.mediawiki.org/wiki/Download_from_Git' .
135 '#Fetch_external_libraries">instructions for installing libraries</a> on mediawiki.org ' .
136 'for help on installing the required components.'
139 trigger_error( $message, E_USER_ERROR );
157if ( defined(
'MW_USE_CONFIG_SCHEMA_CLASS' ) ) {
166require_once MW_INSTALL_PATH .
'/includes/GlobalFunctions.php';
168HeaderCallback::register();
172mb_internal_encoding(
'UTF-8' );
181 MainConfigNames::BaseDirectory => MW_INSTALL_PATH,
182 MainConfigNames::ExtensionDirectory => MW_INSTALL_PATH .
'/extensions',
183 MainConfigNames::StyleDirectory => MW_INSTALL_PATH .
'/skins',
184 MainConfigNames::ServiceWiringFiles => [ MW_INSTALL_PATH .
'/includes/ServiceWiring.php' ],
193if ( !isset( $GLOBALS[
'wgScopeTest'] ) || $GLOBALS[
'wgScopeTest'] !==
$wgScopeTest ) {
194 foreach (
$wgSettings->getConfigSchema()->getDefinedKeys() as $key ) {
204 if ( defined(
'MW_CONFIG_CALLBACK' ) ) {
209 if ( getenv(
'MW_USE_LOCAL_SETTINGS_LOADER' ) ) {
213 $localSettingsLoader->loadLocalSettingsFile( MW_CONFIG_FILE );
214 unset( $localSettingsLoader );
216 if ( str_ends_with( MW_CONFIG_FILE,
'.php' ) ) {
219 require_once MW_CONFIG_FILE;
234if (
$wgSettings->getConfig()->get( MainConfigNames::WikiFarmSettingsDirectory ) ) {
236 $wikiFarmSettingsLoader->loadWikiFarmSettings();
237 unset( $wikiFarmSettingsLoader );
250if ( defined(
'MW_SETUP_CALLBACK' ) ) {
266require __DIR__ .
'/SetupDynamicConfig.php';
268if ( defined(
'MW_AUTOLOAD_TEST_CLASSES' ) ) {
269 require_once __DIR__ .
'/../tests/common/TestsAutoLoader.php';
274 '$wgBaseDirectory must not be modified in settings files! ' .
275 'Use the MW_INSTALL_PATH environment variable to override the installation root directory.'
287if ( defined(
'MW_AUTOLOAD_TEST_CLASSES' ) ) {
288 ExtensionRegistry::getInstance()->setLoadTestClassesAndNamespaces(
true );
291ExtensionRegistry::getInstance()->setSettingsBuilder(
$wgSettings );
292ExtensionRegistry::getInstance()->loadFromQueue();
294ExtensionRegistry::getInstance()->finish();
301if ( defined(
'MW_FINAL_SETUP_CALLBACK' ) ) {
302 call_user_func( MW_FINAL_SETUP_CALLBACK,
$wgSettings );
316putenv(
"LC_ALL=" . setlocale( LC_ALL,
'C.UTF-8',
'C' ) );
326MediaWikiServices::allowGlobalInstance();
330define(
'MW_SERVICE_BOOTSTRAP_COMPLETE', 1 );
333if ( !defined(
'MW_PHPUNIT_TEST' ) ) {
345 '$wgServer must be set in LocalSettings.php. ' .
346 'See <a href="https://www.mediawiki.org/wiki/Manual:$wgServer">' .
347 'https://www.mediawiki.org/wiki/Manual:$wgServer</a>.'
358 MediaWikiServices::getInstance()->getHookContainer(),
366 $wgCanonicalServer = MediaWikiServices::getInstance()->getUrlUtils()->getCanonicalServer();
371 wfWarn(
'$wgServerName should be derived from $wgCanonicalServer, '
372 .
'not customized. Overwriting $wgServerName.' );
391 wfWarn(
'Secure login was enabled on a server that only supports '
392 .
'HTTP or HTTPS. Disabling secure login.' );
402 MediaWikiServices::getInstance()->getDBLoadBalancer()->setTableAliases(
422$wgRequest = RequestContext::getMain()->getRequest();
425if (
$wgRequest->getCookie(
'UseDC',
'' ) ===
'master' ) {
429 MediaWikiServices::getInstance()->getMainWANObjectCache()->useInterimHoldOffCaching(
false );
433(
static function () {
436 $logger = LoggerFactory::getInstance(
'wfDebug' );
438 $self = $_SERVER[
'PHP_SELF'] ??
'';
439 $logger->debug(
"\n\nStart command line script $self" );
441 $debug =
"\n\nStart request {$wgRequest->getMethod()} {$wgRequest->getRequestURL()}\n";
442 $debug .=
"IP: " .
$wgRequest->getIP() .
"\n";
443 $debug .=
"HTTP HEADERS:\n";
444 foreach (
$wgRequest->getAllHeaders() as $name => $value ) {
445 $debug .=
"$name: $value\n";
447 $debug .=
"(end headers)";
448 $logger->debug( $debug );
453(
new HookRunner( MediaWikiServices::getInstance()->getHookContainer() ) )->onSetupAfterCache();
475 HeaderCallback::warnIfHeadersSent();
481 if ( !defined(
'MW_NO_SESSION_HANDLER' ) ) {
482 MediaWiki\Session\PHPSessionHandler::install(
483 MediaWiki\Session\SessionManager::singleton()
487 $contLang = MediaWikiServices::getInstance()->getContentLanguage();
491 $session = MediaWiki\Session\SessionManager::getGlobalSession();
492 }
catch (
MediaWiki\Session\SessionOverflowException $ex ) {
496 foreach ( $ex->getSessionInfos() as $info ) {
497 $list[] = $info->getProvider()->describe( $contLang );
499 $list = $contLang->listToText( $list );
501 Message::newFromKey(
'sessionmanager-tie', $list )->inLanguage( $contLang )
507 if ( $session->isPersistent() ) {
512 if (
MediaWiki\Session\PHPSessionHandler::isEnabled() &&
513 ( $session->isPersistent() || $session->shouldRememberUser() ) &&
514 session_id() !== $session->getId()
517 if ( session_id() !==
'' ) {
518 wfDebugLog(
'session',
'PHP session {old_id} was already started, changing to {new_id}',
'all', [
519 'old_id' => session_id(),
520 'new_id' => $session->getId(),
522 session_write_close();
524 session_id( $session->getId() );
532 if ( !defined(
'MW_NO_SESSION_HANDLER' ) ) {
533 MediaWiki\Session\PHPSessionHandler::install(
534 MediaWiki\Session\SessionManager::singleton()
548register_shutdown_function(
static function () {
549 StubGlobalUser::$destructorDeprecationDisarmed =
true;
560$wgOut = RequestContext::getMain()->getOutput();
575 call_user_func( $func );
582 $sessionUser = MediaWiki\Session\SessionManager::getGlobalSession()->getUser();
583 if ( $sessionUser->getId() === 0 &&
584 MediaWikiServices::getInstance()->getUserNameUtils()->isValid( $sessionUser->getName() )
586 $res = MediaWikiServices::getInstance()->getAuthManager()->autoCreateUser(
588 MediaWiki\Auth\AuthManager::AUTOCREATE_SOURCE_SESSION,
593 $firstMessage = $res->getMessages(
'error' )[0] ?? $res->getMessages(
'warning' )[0] ??
null;
594 \MediaWiki\Logger\LoggerFactory::getInstance(
'authevents' )->info(
'Autocreation attempt', [
595 'event' =>
'autocreate',
596 'successful' => $res->isGood(),
597 'status' => $firstMessage ? $firstMessage->getKey() :
'-',
600 unset( $firstMessage );
602 unset( $sessionUser );
613 DeferredUpdates::addCallableUpdate(
static function () {
614 MediaWikiServices::getInstance()->getPingback()->run();
620 $logger = LoggerFactory::getInstance(
'Settings' );
622 $logger->warning( $msg );
635 MediaWiki\Session\SessionManager::singleton()->logPotentialSessionLeakage();
wfDetectLocalSettingsFile(?string $installationPath=null)
Decide and remember where to load LocalSettings from.
wfDetectInstallPath()
Decide and remember where mediawiki is installed.
const MW_VERSION
The running version of MediaWiki.
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.
wfDebugLog( $logGroup, $text, $dest='all', array $context=[])
Send a line to a supplementary debug log file, if configured, or main debug log if not.
if(!defined( 'MEDIAWIKI')) if(ini_get('mbstring.func_overload')) if(!defined( 'MW_ENTRY_POINT')) global $IP
Environment checks.
if(defined( 'MW_SETUP_CALLBACK')) $dynamicDefaults
Customization point after most things are loaded (constants, functions, classes, LocalSettings.
if(!defined('MW_NO_SESSION') &&MW_ENTRY_POINT !=='cli') if(MW_ENTRY_POINT !=='cli' && $wgPingback $settingsWarnings)
if( $wgCanonicalServer===false) $wgVirtualRestConfig['global']['domain']
global $wgInitialSessionId
if( $wgServer===false) global $wgHooks
if(!defined( 'MW_NO_SESSION') &&MW_ENTRY_POINT !=='cli' $wgLang
if(!defined( 'MW_NO_SESSION') &&MW_ENTRY_POINT !=='cli' $wgOut
$wgConf
$wgConf hold the site configuration.
if( $wgServerName !==false) $wgServerName
if(!interface_exists(LoggerInterface::class)) $wgCommandLineMode
Pre-config setup: Before loading LocalSettings.php.
if(!defined( 'MW_NO_SESSION') &&MW_ENTRY_POINT !=='cli' $wgTitle
global $wgFullyInitialised
global $wgExtensionFunctions
Abort the web request with a custom HTML string that will represent the entire response.
Show an error that looks like an HTTP server error.
Group all the pieces relevant to the context of a request into one instance.
A class containing constants representing the names of configuration variables.
This class contains schema declarations for all configuration variables known to MediaWiki core.
static init(array $profilerConf)
$wgMemoryLimit
Config variable stub for the MemoryLimit setting, for use by phpdoc and IDEs.
$wgEmergencyContact
Config variable stub for the EmergencyContact setting, for use by phpdoc and IDEs.
$wgSharedTables
Config variable stub for the SharedTables setting, for use by phpdoc and IDEs.
$wgSessionName
Config variable stub for the SessionName setting, for use by phpdoc and IDEs.
$wgLogExceptionBacktrace
Config variable stub for the LogExceptionBacktrace setting, for use by phpdoc and IDEs.
$wgTmpDirectory
Config variable stub for the TmpDirectory setting, for use by phpdoc and IDEs.
$wgNoReplyAddress
Config variable stub for the NoReplyAddress setting, for use by phpdoc and IDEs.
$wgProfiler
Config variable stub for the Profiler setting, for use by phpdoc and IDEs.
$wgBaseDirectory
Config variable stub for the BaseDirectory setting, for use by phpdoc and IDEs.
$wgSecureLogin
Config variable stub for the SecureLogin setting, for use by phpdoc and IDEs.
$wgLocaltimezone
Config variable stub for the Localtimezone setting, for use by phpdoc and IDEs.
$wgShowExceptionDetails
Config variable stub for the ShowExceptionDetails setting, for use by phpdoc and IDEs.
$wgRequestTimeLimit
Config variable stub for the RequestTimeLimit setting, for use by phpdoc and IDEs.
$wgSharedDB
Config variable stub for the SharedDB setting, for use by phpdoc and IDEs.
$wgCanonicalServer
Config variable stub for the CanonicalServer setting, for use by phpdoc and IDEs.
$wgServer
Config variable stub for the Server setting, for use by phpdoc and IDEs.
$wgPropagateErrors
Config variable stub for the PropagateErrors setting, for use by phpdoc and IDEs.
$wgSharedSchema
Config variable stub for the SharedSchema setting, for use by phpdoc and IDEs.
$wgPasswordSender
Config variable stub for the PasswordSender setting, for use by phpdoc and IDEs.
$wgPingback
Config variable stub for the Pingback setting, for use by phpdoc and IDEs.
$wgCookiePrefix
Config variable stub for the CookiePrefix setting, for use by phpdoc and IDEs.
$wgSharedPrefix
Config variable stub for the SharedPrefix setting, for use by phpdoc and IDEs.
$wgPHPSessionHandling
Config variable stub for the PHPSessionHandling setting, for use by phpdoc and IDEs.