63use Psr\Log\LoggerInterface;
64use Wikimedia\AtEase\AtEase;
65use Wikimedia\RequestTimeout\RequestTimeout;
75if ( !defined(
'MEDIAWIKI' ) ) {
81if ( ini_get(
'mbstring.func_overload' ) ) {
82 die(
'MediaWiki does not support installations where mbstring.func_overload is non-zero.' );
88if ( !defined(
'MW_ENTRY_POINT' ) ) {
94 define(
'MW_ENTRY_POINT',
'unknown' );
97if ( !defined(
'MW_INSTALL_PATH' ) ) {
98 define(
'MW_INSTALL_PATH',
$IP );
101 $IP = MW_INSTALL_PATH;
109require_once
"$IP/includes/AutoLoader.php";
110require_once
"$IP/includes/Defines.php";
111require_once
"$IP/includes/BootstrapHelperFunctions.php";
114if ( is_readable(
"$IP/vendor/autoload.php" ) ) {
115 require_once
"$IP/vendor/autoload.php";
116} elseif ( file_exists(
"$IP/vendor/autoload.php" ) ) {
117 die(
"$IP/vendor/autoload.php exists but is not readable" );
121if ( !interface_exists( LoggerInterface::class ) ) {
123 'MediaWiki requires the <a href="https://github.com/php-fig/log">PSR-3 logging ' .
124 "library</a> to be present. This library is not embedded directly in MediaWiki's " .
125 "git repository and must be installed separately by the end user.\n\n" .
126 'Please see the <a href="https://www.mediawiki.org/wiki/Download_from_Git' .
127 '#Fetch_external_libraries">instructions for installing libraries</a> on mediawiki.org ' .
128 'for help on installing the required components.'
131 trigger_error( $message, E_USER_ERROR );
151 ExtensionRegistry::getInstance(),
156if ( getenv(
'MW_USE_LEGACY_DEFAULT_SETTINGS' ) || defined(
'MW_USE_LEGACY_DEFAULT_SETTINGS' ) ) {
158 require_once
"$IP/includes/DefaultSettings.php";
166require_once
"$IP/includes/GlobalFunctions.php";
168HeaderCallback::register();
172mb_internal_encoding(
'UTF-8' );
181 'BaseDirectory' =>
$IP,
182 'ExtensionDirectory' =>
"{$IP}/extensions",
183 'StyleDirectory' =>
"{$IP}/skins",
184 'ServiceWiringFiles' => [
"{$IP}/includes/ServiceWiring.php" ],
189if ( defined(
'MW_CONFIG_CALLBACK' ) ) {
194 if ( getenv(
'MW_USE_LOCAL_SETTINGS_LOADER' ) ) {
198 $localSettingsLoader->loadLocalSettingsFile( MW_CONFIG_FILE );
199 unset( $localSettingsLoader );
201 if ( str_ends_with( MW_CONFIG_FILE,
'.php' ) ) {
204 require_once MW_CONFIG_FILE;
221if ( defined(
'MW_SETUP_CALLBACK' ) ) {
228if (
$wgSettings->getConfig()->get(
'WikiFarmSettingsDirectory' ) ) {
230 $wikiFarmSettingsLoader->loadWikiFarmSettings();
231 unset( $wikiFarmSettingsLoader );
238 '$wgBaseDirectory must not be modified in settings files! ' .
239 'Use the MW_INSTALL_PATH environment variable to override the installation root directory.'
262putenv(
"LC_ALL=" . setlocale( LC_ALL,
'C.UTF-8',
'C' ) );
284 ( strpos( PHP_SAPI,
'apache2filter' ) === false ) &&
285 ( strpos( PHP_SAPI,
'isapi' ) === false );
315 $wgLogo =
"$wgResourceBasePath/resources/assets/change-your-logo.svg";
350 'class' => WANObjectCache::class,
356if ( isset( $wgFileBlacklist ) ) {
361if ( isset( $wgMimeTypeBlacklist ) ) {
366if ( isset( $wgEnableUserEmailBlacklist ) ) {
371if ( isset( $wgShortPagesNamespaceBlacklist ) ) {
383 "{$wgStylePath}/common/images/",
384 "{$wgResourceBasePath}/resources/assets/licenses/",
406 "$wgResourceBasePath/resources/assets/poweredby_mediawiki_88x31.png";
408 "$wgResourceBasePath/resources/assets/poweredby_mediawiki_132x47.png 1.5x, " .
409 "$wgResourceBasePath/resources/assets/poweredby_mediawiki_176x62.png 2x";
425 'name' =>
'fsLockManager',
426 'class' => FSLockManager::class,
427 'lockDirectory' =>
"{$wgUploadDirectory}/lockdir",
430 'name' =>
'nullLockManager',
431 'class' => NullLockManager::class,
448 'imageHeight' => 120,
449 'captionLength' =>
true,
451 'showDimensions' =>
true,
452 'mode' =>
'traditional',
460 'class' => LocalRepo::class,
488 'class' => ForeignDBRepo::class,
508 'class' => FileRepo::class,
522 'class' => ForeignAPIRepo::class,
523 'name' =>
'wikimediacommons',
524 'apibase' =>
'https://commons.wikimedia.org/w/api.php',
525 'url' =>
'https://upload.wikimedia.org/wikipedia/commons',
526 'thumbUrl' =>
'https://upload.wikimedia.org/wikipedia/commons/thumb',
528 'transformVia404' =>
true,
529 'fetchDescription' =>
true,
530 'descriptionCacheExpiry' => 43200,
531 'apiThumbCacheExpiry' => 0,
535 if ( !isset( $repo[
'directory'] ) && $repo[
'class'] === ForeignAPIRepo::class ) {
538 if ( !isset( $repo[
'backend'] ) ) {
539 $repo[
'backend'] = $repo[
'name'] .
'-backend';
630foreach ( LanguageCode::getNonstandardLanguageCodeMapping() as $code => $bcp47 ) {
631 $bcp47 = strtolower( $bcp47 );
642if ( isset( $wgSlaveLagWarning ) ) {
647 '$wgSlaveLagWarning set but $wgDatabaseReplicaLagWarning unchanged; using $wgSlaveLagWarning',
656if ( isset( $wgSlaveLagCritical ) ) {
661 '$wgSlaveLagCritical set but $wgDatabaseReplicaLagCritical unchanged; using $wgSlaveLagCritical',
671 AtEase::suppressWarnings();
673 AtEase::restoreWarnings();
718if ( defined(
'MW_NO_SESSION' ) ) {
729MediaWikiServices::allowGlobalInstance();
733define(
'MW_SERVICE_BOOTSTRAP_COMPLETE', 1 );
735MWExceptionHandler::installHandler();
742 '$wgServer must be set in LocalSettings.php. ' .
743 'See <a href="https://www.mediawiki.org/wiki/Manual:$wgServer">' .
744 'https://www.mediawiki.org/wiki/Manual:$wgServer</a>.'
758 wfWarn(
'$wgServerName should be derived from $wgCanonicalServer, '
759 .
'not customized. Overwriting $wgServerName.' );
779 wfWarn(
'Secure login was enabled on a server that only supports '
780 .
'HTTP or HTTPS. Disabling secure login.' );
790 MediaWikiServices::getInstance()->getDBLoadBalancer()->setTableAliases(
810$wgRequest = RequestContext::getMain()->getRequest();
813if (
$wgRequest->getCookie(
'UseDC',
'' ) ===
'master' ) {
817 MediaWikiServices::getInstance()->getMainWANObjectCache()->useInterimHoldOffCaching(
false );
821(
static function () {
823 $logger = LoggerFactory::getInstance(
'wfDebug' );
825 $self = $_SERVER[
'PHP_SELF'] ??
'';
826 $logger->debug(
"\n\nStart command line script $self" );
828 $debug =
"\n\nStart request {$wgRequest->getMethod()} {$wgRequest->getRequestURL()}\n";
830 $debug .=
"HTTP HEADERS:\n";
831 foreach (
$wgRequest->getAllHeaders() as $name => $value ) {
832 $debug .=
"$name: $value\n";
834 $debug .=
"(end headers)";
862 HeaderCallback::warnIfHeadersSent();
868 if ( !defined(
'MW_NO_SESSION_HANDLER' ) ) {
869 MediaWiki\Session\PHPSessionHandler::install(
870 MediaWiki\Session\SessionManager::singleton()
874 $contLang = MediaWikiServices::getInstance()->getContentLanguage();
878 $session = MediaWiki\Session\SessionManager::getGlobalSession();
879 }
catch (
MediaWiki\Session\SessionOverflowException $ex ) {
883 foreach ( $ex->getSessionInfos() as $info ) {
884 $list[] = $info->getProvider()->describe( $contLang );
886 $list = $contLang->listToText( $list );
894 if ( $session->isPersistent() ) {
899 if (
MediaWiki\Session\PHPSessionHandler::isEnabled() &&
900 ( $session->isPersistent() || $session->shouldRememberUser() ) &&
901 session_id() !== $session->getId()
904 if ( session_id() !==
'' ) {
905 wfDebugLog(
'session',
'PHP session {old_id} was already started, changing to {new_id}',
'all', [
906 'old_id' => session_id(),
907 'new_id' => $session->getId(),
909 session_write_close();
911 session_id( $session->getId() );
919 if ( !defined(
'MW_NO_SESSION_HANDLER' ) ) {
920 MediaWiki\Session\PHPSessionHandler::install(
921 MediaWiki\Session\SessionManager::singleton()
935register_shutdown_function(
static function () {
954 return MediaWikiServices::getInstance()->getParser();
970 call_user_func( $func );
977 $sessionUser = MediaWiki\Session\SessionManager::getGlobalSession()->getUser();
978 if ( $sessionUser->getId() === 0 &&
979 MediaWikiServices::getInstance()->getUserNameUtils()->isValid( $sessionUser->getName() )
981 $res = MediaWikiServices::getInstance()->getAuthManager()->autoCreateUser(
983 MediaWiki\Auth\AuthManager::AUTOCREATE_SOURCE_SESSION,
986 \MediaWiki\Logger\LoggerFactory::getInstance(
'authevents' )->info(
'Autocreation attempt', [
987 'event' =>
'autocreate',
988 'status' => strval(
$res ),
992 unset( $sessionUser );
1003 MediaWiki\Session\SessionManager::singleton()->logPotentialSessionLeakage();
wfDetectLocalSettingsFile(string $installationPath)
Decide and remember where to load LocalSettings from.
$wgProhibitedFileExtensions
Files with these extensions will never be allowed as uploads.
$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.
$wgUpdateCompatibleMetadata
Shortcut for the 'updateCompatibleMetadata' setting of $wgLocalFileRepo.
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.
$wgEnableUserEmailMuteList
Set to true to enable user-to-user e-mail mutelist.
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.
$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.
$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.
$wgShortPagesNamespaceExclusions
Optional array of namespaces which should be excluded from Special:ShortPages.
$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.
$wgEnableEmail
Set to true to enable the e-mail basic features: Password reminders, etc.
$wgBaseDirectory
Absolute filesystem path of the root directory of the MediaWiki installation.
$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.
$wgMimeTypeExclusions
Files with these MIME types will never be allowed as uploads if $wgVerifyMimeType is enabled.
$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.
$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...
$wgMainWANCache
Main Wide-Area-Network cache type.
$wgDBpassword
Database user's password.
$wgFavicon
The URL path of the shortcut icon.
$wgShowEXIF
Show Exif data, on by default if available.
$wgNewUserLog
Maintain a log of newusers at Special:Log/newusers?
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.
wfDeprecated( $function, $version=false, $component=false, $callerOffset=2)
Logs a warning that a deprecated feature was used.
if(is_array($wgExtraNamespaces)) if(count( $wgDummyLanguageCodes) !==0) $wgDummyLanguageCodes
if( $wgShowEXIF===null) $wgGalleryOptions
Determine whether EXIF info can be shown.
if(!defined( 'MW_NO_SESSION') &&! $wgCommandLineMode) $wgOut
if(!defined( 'MW_NO_SESSION') &&! $wgCommandLineMode) $wgParser
if(is_readable("$IP/vendor/autoload.php")) elseif(file_exists("$IP/vendor/autoload.php")) if(!interface_exists(LoggerInterface::class)) global $wgAutoloadClasses
global $wgFullyInitialised
$wgEnotifRevealEditorAddress
if(! $wgCookiePrefix) $wgCookiePrefix
global $wgInitialSessionId
The persistent session ID (if any) loaded at startup.
$wgUsersNotifiedOnAllChanges
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...
if(! $wgDBerrorLogTZ) $wgCanonicalNamespaceNames
Definitions of the NS_ constants are in Defines.php.
if(!defined( 'MW_NO_SESSION') &&! $wgCommandLineMode) $wgLang
if(is_readable("$IP/vendor/autoload.php")) elseif(file_exists("$IP/vendor/autoload.php")) if(!interface_exists(LoggerInterface::class)) global $wgConf
$wgConf hold the site configuration.
if( $wgServerName !==false) $wgServerName
$wgLockManagers[]
Initialise $wgLockManagers to include basic FS version.
$wgDefaultUserOptions['rcdays']
if(!defined( 'MW_NO_SESSION') &&! $wgCommandLineMode) $wgTitle
if($wgServer===false) if( $wgCanonicalServer===false) $wgVirtualRestConfig['global']['domain']
global $wgExtensionFunctions
if(is_readable("$IP/vendor/autoload.php")) elseif(file_exists("$IP/vendor/autoload.php")) if(!interface_exists(LoggerInterface::class)) global $wgSettings
Pre-config setup: Before loading LocalSettings.php.
if(is_readable("$IP/vendor/autoload.php")) elseif(file_exists("$IP/vendor/autoload.php")) if(!interface_exists(LoggerInterface::class)) global $wgCommandLineMode
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 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.
static detectProtocol()
Detect the protocol from $_SERVER.