66 use Psr\Log\LoggerInterface;
67 use Wikimedia\RequestTimeout\RequestTimeout;
77 if ( !defined(
'MEDIAWIKI' ) ) {
83 if ( ini_get(
'mbstring.func_overload' ) ) {
84 die(
'MediaWiki does not support installations where mbstring.func_overload is non-zero.' );
90 if ( !defined(
'MW_ENTRY_POINT' ) ) {
96 define(
'MW_ENTRY_POINT',
'unknown' );
113 require_once MW_INSTALL_PATH .
'/includes/AutoLoader.php';
114 require_once MW_INSTALL_PATH .
'/includes/Defines.php';
117 if ( !interface_exists( LoggerInterface::class ) ) {
119 'MediaWiki requires the <a href="https://github.com/php-fig/log">PSR-3 logging ' .
120 "library</a> to be present. This library is not embedded directly in MediaWiki's " .
121 "git repository and must be installed separately by the end user.\n\n" .
122 'Please see the <a href="https://www.mediawiki.org/wiki/Download_from_Git' .
123 '#Fetch_external_libraries">instructions for installing libraries</a> on mediawiki.org ' .
124 'for help on installing the required components.'
127 trigger_error( $message, E_USER_ERROR );
149 if ( defined(
'MW_USE_CONFIG_SCHEMA_CLASS' ) ) {
154 } elseif ( getenv(
'MW_USE_LEGACY_DEFAULT_SETTINGS' ) || defined(
'MW_USE_LEGACY_DEFAULT_SETTINGS' ) ) {
156 require_once MW_INSTALL_PATH .
'/includes/DefaultSettings.php';
165 require_once MW_INSTALL_PATH .
'/includes/GlobalFunctions.php';
167 HeaderCallback::register();
171 mb_internal_encoding(
'UTF-8' );
180 MainConfigNames::BaseDirectory => MW_INSTALL_PATH,
181 MainConfigNames::ExtensionDirectory => MW_INSTALL_PATH .
'/extensions',
182 MainConfigNames::StyleDirectory => MW_INSTALL_PATH .
'/skins',
183 MainConfigNames::ServiceWiringFiles => [ MW_INSTALL_PATH .
'/includes/ServiceWiring.php' ],
192 if ( !isset( $GLOBALS[
'wgScopeTest'] ) || $GLOBALS[
'wgScopeTest'] !==
$wgScopeTest ) {
193 foreach (
$wgSettings->getConfigSchema()->getDefinedKeys() as $key ) {
202 if ( defined(
'MW_CONFIG_CALLBACK' ) ) {
207 if ( getenv(
'MW_USE_LOCAL_SETTINGS_LOADER' ) ) {
211 $localSettingsLoader->loadLocalSettingsFile( MW_CONFIG_FILE );
212 unset( $localSettingsLoader );
214 if ( str_ends_with( MW_CONFIG_FILE,
'.php' ) ) {
217 require_once MW_CONFIG_FILE;
234 if ( defined(
'MW_SETUP_CALLBACK' ) ) {
241 if (
$wgSettings->getConfig()->get( MainConfigNames::WikiFarmSettingsDirectory ) ) {
243 $wikiFarmSettingsLoader->loadWikiFarmSettings();
244 unset( $wikiFarmSettingsLoader );
251 '$wgBaseDirectory must not be modified in settings files! ' .
252 'Use the MW_INSTALL_PATH environment variable to override the installation root directory.'
275 putenv(
"LC_ALL=" . setlocale( LC_ALL,
'C.UTF-8',
'C' ) );
280 require __DIR__ .
'/SetupDynamicConfig.php';
287 MediaWikiServices::allowGlobalInstance();
291 define(
'MW_SERVICE_BOOTSTRAP_COMPLETE', 1 );
301 '$wgServer must be set in LocalSettings.php. ' .
302 'See <a href="https://www.mediawiki.org/wiki/Manual:$wgServer">' .
303 'https://www.mediawiki.org/wiki/Manual:$wgServer</a>.'
317 wfWarn(
'$wgServerName should be derived from $wgCanonicalServer, '
318 .
'not customized. Overwriting $wgServerName.' );
338 wfWarn(
'Secure login was enabled on a server that only supports '
339 .
'HTTP or HTTPS. Disabling secure login.' );
349 MediaWikiServices::getInstance()->getDBLoadBalancer()->setTableAliases(
372 if (
$wgRequest->getCookie(
'UseDC',
'' ) ===
'master' ) {
376 MediaWikiServices::getInstance()->getMainWANObjectCache()->useInterimHoldOffCaching(
false );
380 (
static function () {
382 $logger = LoggerFactory::getInstance(
'wfDebug' );
384 $self = $_SERVER[
'PHP_SELF'] ??
'';
385 $logger->debug(
"\n\nStart command line script $self" );
387 $debug =
"\n\nStart request {$wgRequest->getMethod()} {$wgRequest->getRequestURL()}\n";
389 $debug .=
"HTTP HEADERS:\n";
390 foreach (
$wgRequest->getAllHeaders() as $name => $value ) {
391 $debug .=
"$name: $value\n";
393 $debug .=
"(end headers)";
421 HeaderCallback::warnIfHeadersSent();
427 if ( !defined(
'MW_NO_SESSION_HANDLER' ) ) {
429 MediaWiki\Session\SessionManager::singleton()
433 $contLang = MediaWikiServices::getInstance()->getContentLanguage();
438 }
catch (
MediaWiki\Session\SessionOverflowException $ex ) {
442 foreach ( $ex->getSessionInfos() as $info ) {
443 $list[] = $info->getProvider()->describe( $contLang );
445 $list = $contLang->listToText( $list );
453 if ( $session->isPersistent() ) {
458 if (
MediaWiki\Session\PHPSessionHandler::isEnabled() &&
459 ( $session->isPersistent() || $session->shouldRememberUser() ) &&
460 session_id() !== $session->getId()
463 if ( session_id() !==
'' ) {
464 wfDebugLog(
'session',
'PHP session {old_id} was already started, changing to {new_id}',
'all', [
465 'old_id' => session_id(),
466 'new_id' => $session->getId(),
468 session_write_close();
470 session_id( $session->getId() );
478 if ( !defined(
'MW_NO_SESSION_HANDLER' ) ) {
480 MediaWiki\Session\SessionManager::singleton()
494 register_shutdown_function(
static function () {
513 return MediaWikiServices::getInstance()->getParser();
529 call_user_func( $func );
537 if ( $sessionUser->getId() === 0 &&
538 MediaWikiServices::getInstance()->getUserNameUtils()->isValid( $sessionUser->getName() )
540 $res = MediaWikiServices::getInstance()->getAuthManager()->autoCreateUser(
542 MediaWiki\Auth\AuthManager::AUTOCREATE_SOURCE_SESSION,
546 'event' =>
'autocreate',
547 'status' => strval(
$res ),
551 unset( $sessionUser );
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.
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.
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( $wgServer===false) if( $wgCanonicalServer===false) $wgVirtualRestConfig['global']['domain']
if(!defined( 'MW_NO_SESSION') &&! $wgCommandLineMode) $wgParser
global $wgInitialSessionId
The persistent session ID (if any) loaded at startup.
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
global $wgExtensionFunctions
global $wgFullyInitialised
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.
Show an error that looks like an HTTP server error.
static installHandler(bool $logExceptionBacktrace=true, bool $propagateErrors=true)
Install handlers with PHP.
static setShowExceptionDetails(bool $showDetails)
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.
This is a class for holding configuration settings, 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.
$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.