67use Psr\Log\LoggerInterface;
68use Wikimedia\RequestTimeout\RequestTimeout;
78if ( !defined(
'MEDIAWIKI' ) ) {
84if ( ini_get(
'mbstring.func_overload' ) ) {
85 die(
'MediaWiki does not support installations where mbstring.func_overload is non-zero.' );
91if ( !defined(
'MW_ENTRY_POINT' ) ) {
97 define(
'MW_ENTRY_POINT',
'unknown' );
114require_once MW_INSTALL_PATH .
'/includes/AutoLoader.php';
115require_once MW_INSTALL_PATH .
'/includes/Defines.php';
118if ( !interface_exists( LoggerInterface::class ) ) {
120 'MediaWiki requires the <a href="https://github.com/php-fig/log">PSR-3 logging ' .
121 "library</a> to be present. This library is not embedded directly in MediaWiki's " .
122 "git repository and must be installed separately by the end user.\n\n" .
123 'Please see the <a href="https://www.mediawiki.org/wiki/Download_from_Git' .
124 '#Fetch_external_libraries">instructions for installing libraries</a> on mediawiki.org ' .
125 'for help on installing the required components.'
128 trigger_error( $message, E_USER_ERROR );
145 ExtensionRegistry::getInstance(),
150if ( defined(
'MW_USE_CONFIG_SCHEMA_CLASS' ) ) {
155} elseif ( getenv(
'MW_USE_LEGACY_DEFAULT_SETTINGS' ) || defined(
'MW_USE_LEGACY_DEFAULT_SETTINGS' ) ) {
157 require_once MW_INSTALL_PATH .
'/includes/DefaultSettings.php';
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 ) {
203if ( defined(
'MW_CONFIG_CALLBACK' ) ) {
208 if ( getenv(
'MW_USE_LOCAL_SETTINGS_LOADER' ) ) {
212 $localSettingsLoader->loadLocalSettingsFile( MW_CONFIG_FILE );
213 unset( $localSettingsLoader );
215 if ( str_ends_with( MW_CONFIG_FILE,
'.php' ) ) {
218 require_once MW_CONFIG_FILE;
235if ( defined(
'MW_SETUP_CALLBACK' ) ) {
242if (
$wgSettings->getConfig()->get( MainConfigNames::WikiFarmSettingsDirectory ) ) {
244 $wikiFarmSettingsLoader->loadWikiFarmSettings();
245 unset( $wikiFarmSettingsLoader );
258require __DIR__ .
'/SetupDynamicConfig.php';
264 '$wgBaseDirectory must not be modified in settings files! ' .
265 'Use the MW_INSTALL_PATH environment variable to override the installation root directory.'
288putenv(
"LC_ALL=" . setlocale( LC_ALL,
'C.UTF-8',
'C' ) );
298MediaWikiServices::allowGlobalInstance();
302define(
'MW_SERVICE_BOOTSTRAP_COMPLETE', 1 );
312 '$wgServer must be set in LocalSettings.php. ' .
313 'See <a href="https://www.mediawiki.org/wiki/Manual:$wgServer">' .
314 'https://www.mediawiki.org/wiki/Manual:$wgServer</a>.'
322 $wgCanonicalServer = MediaWikiServices::getInstance()->getUrlUtils()->getCanonicalServer();
328 wfWarn(
'$wgServerName should be derived from $wgCanonicalServer, '
329 .
'not customized. Overwriting $wgServerName.' );
349 wfWarn(
'Secure login was enabled on a server that only supports '
350 .
'HTTP or HTTPS. Disabling secure login.' );
360 MediaWikiServices::getInstance()->getDBLoadBalancer()->setTableAliases(
380$wgRequest = RequestContext::getMain()->getRequest();
383if (
$wgRequest->getCookie(
'UseDC',
'' ) ===
'master' ) {
387 MediaWikiServices::getInstance()->getMainWANObjectCache()->useInterimHoldOffCaching(
false );
391(
static function () {
393 $logger = LoggerFactory::getInstance(
'wfDebug' );
395 $self = $_SERVER[
'PHP_SELF'] ??
'';
396 $logger->debug(
"\n\nStart command line script $self" );
398 $debug =
"\n\nStart request {$wgRequest->getMethod()} {$wgRequest->getRequestURL()}\n";
400 $debug .=
"HTTP HEADERS:\n";
401 foreach (
$wgRequest->getAllHeaders() as $name => $value ) {
402 $debug .=
"$name: $value\n";
404 $debug .=
"(end headers)";
432 HeaderCallback::warnIfHeadersSent();
438 if ( !defined(
'MW_NO_SESSION_HANDLER' ) ) {
439 MediaWiki\Session\PHPSessionHandler::install(
440 MediaWiki\Session\SessionManager::singleton()
444 $contLang = MediaWikiServices::getInstance()->getContentLanguage();
448 $session = MediaWiki\Session\SessionManager::getGlobalSession();
449 }
catch (
MediaWiki\Session\SessionOverflowException $ex ) {
453 foreach ( $ex->getSessionInfos() as $info ) {
454 $list[] = $info->getProvider()->describe( $contLang );
456 $list = $contLang->listToText( $list );
464 if ( $session->isPersistent() ) {
469 if (
MediaWiki\Session\PHPSessionHandler::isEnabled() &&
470 ( $session->isPersistent() || $session->shouldRememberUser() ) &&
471 session_id() !== $session->getId()
474 if ( session_id() !==
'' ) {
475 wfDebugLog(
'session',
'PHP session {old_id} was already started, changing to {new_id}',
'all', [
476 'old_id' => session_id(),
477 'new_id' => $session->getId(),
479 session_write_close();
481 session_id( $session->getId() );
489 if ( !defined(
'MW_NO_SESSION_HANDLER' ) ) {
490 MediaWiki\Session\PHPSessionHandler::install(
491 MediaWiki\Session\SessionManager::singleton()
505register_shutdown_function(
static function () {
532 call_user_func( $func );
539 $sessionUser = MediaWiki\Session\SessionManager::getGlobalSession()->getUser();
540 if ( $sessionUser->getId() === 0 &&
541 MediaWikiServices::getInstance()->getUserNameUtils()->isValid( $sessionUser->getName() )
543 $res = MediaWikiServices::getInstance()->getAuthManager()->autoCreateUser(
545 MediaWiki\Auth\AuthManager::AUTOCREATE_SOURCE_SESSION,
548 \MediaWiki\Logger\LoggerFactory::getInstance(
'authevents' )->info(
'Autocreation attempt', [
549 'event' =>
'autocreate',
550 'successful' =>
$res->isGood(),
551 'status' => (
$res->getErrorsArray() ?:
$res->getWarningsArray() )[0][0] ??
'-',
555 unset( $sessionUser );
564 $logger = LoggerFactory::getInstance(
'Settings' );
566 $logger->warning( $msg );
579 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.
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.
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_NO_SESSION') &&! $wgCommandLineMode $wgOut
if(!defined('MW_NO_SESSION') &&! $wgCommandLineMode) if(! $wgCommandLineMode) $settingsWarnings
global $wgInitialSessionId
The persistent session ID (if any) loaded at startup.
if(defined('MW_SETUP_CALLBACK')) if( $wgSettings->getConfig() ->get(MainConfigNames::WikiFarmSettingsDirectory)) $dynamicDefaults
Customization point after all loading (constants, functions, classes, LocalSettings).
if(!defined( 'MW_NO_SESSION') &&! $wgCommandLineMode $wgLang
$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') &&! $wgCommandLineMode $wgTitle
if($wgServer===false) if( $wgCanonicalServer===false) $wgVirtualRestConfig['global']['domain']
global $wgFullyInitialised
global $wgExtensionFunctions
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.
Show an error that looks like an HTTP server error.
A class containing constants representing the names of configuration variables.
This class contains schema declarations for all configuration variables known to MediaWiki core.
static newFromKey( $key,... $params)
Factory function that is just wrapper for the real constructor.
static schedulePingback()
Schedule a deferred callable that will check if a pingback should be sent and (if so) proceed to send...
static getMain()
Get the RequestContext object associated with the main request.
Configuration holder, particularly for multi-wiki sites.
Stub object for the global user ($wgUser) that makes it possible to change the relevant underlying ob...
static bool $destructorDeprecationDisarmed
Stub object for the user language.
$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.
$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.
$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.