72use Psr\Log\LoggerInterface;
73use Wikimedia\RequestTimeout\RequestTimeout;
83if ( !defined(
'MEDIAWIKI' ) ) {
89if ( ini_get(
'mbstring.func_overload' ) ) {
90 die(
'MediaWiki does not support installations where mbstring.func_overload is non-zero.' );
96if ( !defined(
'MW_ENTRY_POINT' ) ) {
102 define(
'MW_ENTRY_POINT',
'unknown' );
119require_once MW_INSTALL_PATH .
'/includes/AutoLoader.php';
120require_once MW_INSTALL_PATH .
'/includes/Defines.php';
123if ( !interface_exists( LoggerInterface::class ) ) {
125 'MediaWiki requires the <a href="https://github.com/php-fig/log">PSR-3 logging ' .
126 "library</a> to be present. This library is not embedded directly in MediaWiki's " .
127 "git repository and must be installed separately by the end user.\n\n" .
128 'Please see the <a href="https://www.mediawiki.org/wiki/Download_from_Git' .
129 '#Fetch_external_libraries">instructions for installing libraries</a> on mediawiki.org ' .
130 'for help on installing the required components.'
133 trigger_error( $message, E_USER_ERROR );
150if ( defined(
'MW_USE_CONFIG_SCHEMA_CLASS' ) ) {
159require_once MW_INSTALL_PATH .
'/includes/GlobalFunctions.php';
161HeaderCallback::register();
165mb_internal_encoding(
'UTF-8' );
174 MainConfigNames::BaseDirectory => MW_INSTALL_PATH,
175 MainConfigNames::ExtensionDirectory => MW_INSTALL_PATH .
'/extensions',
176 MainConfigNames::StyleDirectory => MW_INSTALL_PATH .
'/skins',
177 MainConfigNames::ServiceWiringFiles => [ MW_INSTALL_PATH .
'/includes/ServiceWiring.php' ],
186if ( !isset( $GLOBALS[
'wgScopeTest'] ) || $GLOBALS[
'wgScopeTest'] !==
$wgScopeTest ) {
187 foreach (
$wgSettings->getConfigSchema()->getDefinedKeys() as $key ) {
197 if ( defined(
'MW_CONFIG_CALLBACK' ) ) {
202 if ( getenv(
'MW_USE_LOCAL_SETTINGS_LOADER' ) ) {
206 $localSettingsLoader->loadLocalSettingsFile( MW_CONFIG_FILE );
207 unset( $localSettingsLoader );
209 if ( str_ends_with( MW_CONFIG_FILE,
'.php' ) ) {
212 require_once MW_CONFIG_FILE;
227if (
$wgSettings->getConfig()->get( MainConfigNames::WikiFarmSettingsDirectory ) ) {
229 $wikiFarmSettingsLoader->loadWikiFarmSettings();
230 unset( $wikiFarmSettingsLoader );
243if ( defined(
'MW_SETUP_CALLBACK' ) ) {
259require __DIR__ .
'/SetupDynamicConfig.php';
261if ( defined(
'MW_AUTOLOAD_TEST_CLASSES' ) ) {
262 require_once __DIR__ .
'/../tests/common/TestsAutoLoader.php';
267 '$wgBaseDirectory must not be modified in settings files! ' .
268 'Use the MW_INSTALL_PATH environment variable to override the installation root directory.'
280if ( defined(
'MW_AUTOLOAD_TEST_CLASSES' ) ) {
294if ( defined(
'MW_FINAL_SETUP_CALLBACK' ) ) {
295 call_user_func( MW_FINAL_SETUP_CALLBACK,
$wgSettings );
309putenv(
"LC_ALL=" . setlocale( LC_ALL,
'C.UTF-8',
'C' ) );
319MediaWikiServices::allowGlobalInstance();
323define(
'MW_SERVICE_BOOTSTRAP_COMPLETE', 1 );
326if ( !defined(
'MW_PHPUNIT_TEST' ) ) {
338 '$wgServer must be set in LocalSettings.php. ' .
339 'See <a href="https://www.mediawiki.org/wiki/Manual:$wgServer">' .
340 'https://www.mediawiki.org/wiki/Manual:$wgServer</a>.'
351 MediaWikiServices::getInstance()->getHookContainer(),
359 $wgCanonicalServer = MediaWikiServices::getInstance()->getUrlUtils()->getCanonicalServer();
365 wfWarn(
'$wgServerName should be derived from $wgCanonicalServer, '
366 .
'not customized. Overwriting $wgServerName.' );
386 wfWarn(
'Secure login was enabled on a server that only supports '
387 .
'HTTP or HTTPS. Disabling secure login.' );
397 MediaWikiServices::getInstance()->getDBLoadBalancer()->setTableAliases(
417$wgRequest = RequestContext::getMain()->getRequest();
420if (
$wgRequest->getCookie(
'UseDC',
'' ) ===
'master' ) {
424 MediaWikiServices::getInstance()->getMainWANObjectCache()->useInterimHoldOffCaching(
false );
428(
static function () {
431 $logger = LoggerFactory::getInstance(
'wfDebug' );
433 $self = $_SERVER[
'PHP_SELF'] ??
'';
434 $logger->debug(
"\n\nStart command line script $self" );
436 $debug =
"\n\nStart request {$wgRequest->getMethod()} {$wgRequest->getRequestURL()}\n";
437 $debug .=
"IP: " .
$wgRequest->getIP() .
"\n";
438 $debug .=
"HTTP HEADERS:\n";
439 foreach (
$wgRequest->getAllHeaders() as $name => $value ) {
440 $debug .=
"$name: $value\n";
442 $debug .=
"(end headers)";
443 $logger->debug( $debug );
448(
new HookRunner( MediaWikiServices::getInstance()->getHookContainer() ) )->onSetupAfterCache();
470 HeaderCallback::warnIfHeadersSent();
476 if ( !defined(
'MW_NO_SESSION_HANDLER' ) ) {
477 MediaWiki\Session\PHPSessionHandler::install(
478 MediaWiki\Session\SessionManager::singleton()
482 $contLang = MediaWikiServices::getInstance()->getContentLanguage();
486 $session = MediaWiki\Session\SessionManager::getGlobalSession();
487 }
catch (
MediaWiki\Session\SessionOverflowException $ex ) {
491 foreach ( $ex->getSessionInfos() as $info ) {
492 $list[] = $info->getProvider()->describe( $contLang );
494 $list = $contLang->listToText( $list );
502 if ( $session->isPersistent() ) {
507 if (
MediaWiki\Session\PHPSessionHandler::isEnabled() &&
508 ( $session->isPersistent() || $session->shouldRememberUser() ) &&
509 session_id() !== $session->getId()
512 if ( session_id() !==
'' ) {
513 wfDebugLog(
'session',
'PHP session {old_id} was already started, changing to {new_id}',
'all', [
514 'old_id' => session_id(),
515 'new_id' => $session->getId(),
517 session_write_close();
519 session_id( $session->getId() );
527 if ( !defined(
'MW_NO_SESSION_HANDLER' ) ) {
528 MediaWiki\Session\PHPSessionHandler::install(
529 MediaWiki\Session\SessionManager::singleton()
543register_shutdown_function(
static function () {
544 StubGlobalUser::$destructorDeprecationDisarmed =
true;
570 call_user_func( $func );
577 $sessionUser = MediaWiki\Session\SessionManager::getGlobalSession()->getUser();
578 if ( $sessionUser->getId() === 0 &&
579 MediaWikiServices::getInstance()->getUserNameUtils()->isValid( $sessionUser->getName() )
581 $res = MediaWikiServices::getInstance()->getAuthManager()->autoCreateUser(
583 MediaWiki\Auth\AuthManager::AUTOCREATE_SOURCE_SESSION,
586 \MediaWiki\Logger\LoggerFactory::getInstance(
'authevents' )->info(
'Autocreation attempt', [
587 'event' =>
'autocreate',
588 'successful' => $res->isGood(),
589 'status' => ( $res->getErrorsArray() ?: $res->getWarningsArray() )[0][0] ??
'-',
593 unset( $sessionUser );
605 MediaWikiServices::getInstance()->getPingback()->run();
611 $logger = LoggerFactory::getInstance(
'Settings' );
613 $logger->warning( $msg );
626 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_SETUP_CALLBACK')) $dynamicDefaults
Customization point after most things are loaded (constants, functions, classes, LocalSettings.
if( $wgCanonicalServer===false) $wgVirtualRestConfig['global']['domain']
global $wgInitialSessionId
if( $wgServer===false) global $wgHooks
if(!defined( 'MW_NO_SESSION') &&! $wgCommandLineMode $wgLang
if(!defined('MW_NO_SESSION') &&! $wgCommandLineMode) if(! $wgCommandLineMode && $wgPingback $settingsWarnings)
if(!defined( 'MW_NO_SESSION') &&! $wgCommandLineMode $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') &&! $wgCommandLineMode $wgTitle
global $wgFullyInitialised
global $wgExtensionFunctions
static addCallableUpdate( $callable, $stage=self::POSTSEND, $dbw=null)
Add an update to the pending update queue that invokes the specified callback when run.
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.
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.
Thrown when ExtensionRegistry cannot open the extension.json or skin.json file.
render()
Output an error response and exit.
static init(array $profilerConf)
static getMain()
Get the RequestContext object associated with the main request.
$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.