Go to the documentation of this file.
53 use Psr\Log\LoggerInterface;
56 use Wikimedia\RequestTimeout\RequestTimeout;
66 if ( !defined(
'MEDIAWIKI' ) ) {
72 if ( !isset( $GLOBALS[
'wgScopeTest'] ) || $GLOBALS[
'wgScopeTest'] !==
$wgScopeTest ) {
73 echo
"Error, Setup.php must be included from the file scope.\n";
80 if ( ini_get(
'mbstring.func_overload' ) ) {
81 die(
'MediaWiki does not support installations where mbstring.func_overload is non-zero.' );
87 if ( !defined(
'MW_ENTRY_POINT' ) ) {
93 define(
'MW_ENTRY_POINT',
'unknown' );
102 require_once
"$IP/includes/AutoLoader.php";
103 require_once
"$IP/includes/Defines.php";
104 require_once
"$IP/includes/DefaultSettings.php";
105 require_once
"$IP/includes/GlobalFunctions.php";
108 if ( is_readable(
"$IP/vendor/autoload.php" ) ) {
109 require_once
"$IP/vendor/autoload.php";
110 } elseif ( file_exists(
"$IP/vendor/autoload.php" ) ) {
111 die(
"$IP/vendor/autoload.php exists but is not readable" );
115 if ( !interface_exists( LoggerInterface::class ) ) {
117 'MediaWiki requires the <a href="https://github.com/php-fig/log">PSR-3 logging ' .
118 "library</a> to be present. This library is not embedded directly in MediaWiki's " .
119 "git repository and must be installed separately by the end user.\n\n" .
120 'Please see <a href="https://www.mediawiki.org/wiki/Download_from_Git' .
121 '#Fetch_external_libraries">mediawiki.org</a> for help on installing ' .
122 'the required components.'
125 trigger_error( $message, E_USER_ERROR );
129 HeaderCallback::register();
133 mb_internal_encoding(
'UTF-8' );
139 if ( defined(
'MW_CONFIG_CALLBACK' ) ) {
142 if ( !defined(
'MW_CONFIG_FILE' ) ) {
143 define(
'MW_CONFIG_FILE',
"$IP/LocalSettings.php" );
145 require_once MW_CONFIG_FILE;
155 if ( defined(
'MW_SETUP_CALLBACK' ) ) {
156 call_user_func( MW_SETUP_CALLBACK );
174 putenv(
"LC_ALL=$wgShellLocale" );
218 $wgLogo =
"$wgResourceBasePath/resources/assets/wiki.png";
255 "{$wgStylePath}/common/images/",
256 "{$wgResourceBasePath}/resources/assets/licenses/",
278 "$wgResourceBasePath/resources/assets/poweredby_mediawiki_88x31.png";
280 "$wgResourceBasePath/resources/assets/poweredby_mediawiki_132x47.png 1.5x, " .
281 "$wgResourceBasePath/resources/assets/poweredby_mediawiki_176x62.png 2x";
297 'name' =>
'fsLockManager',
298 'class' => FSLockManager::class,
299 'lockDirectory' =>
"{$wgUploadDirectory}/lockdir",
302 'name' =>
'nullLockManager',
303 'class' => NullLockManager::class,
313 'imageHeight' => 120,
314 'captionLength' =>
true,
316 'showDimensions' =>
true,
317 'mode' =>
'traditional',
325 'class' => LocalRepo::class,
350 'class' => ForeignDBRepo::class,
370 'class' => FileRepo::class,
384 'class' => ForeignAPIRepo::class,
385 'name' =>
'wikimediacommons',
386 'apibase' =>
'https://commons.wikimedia.org/w/api.php',
387 'url' =>
'https://upload.wikimedia.org/wikipedia/commons',
388 'thumbUrl' =>
'https://upload.wikimedia.org/wikipedia/commons/thumb',
390 'transformVia404' =>
true,
391 'fetchDescription' =>
true,
392 'descriptionCacheExpiry' => 43200,
393 'apiThumbCacheExpiry' => 0,
397 if ( !isset( $repo[
'directory'] ) && $repo[
'class'] === ForeignAPIRepo::class ) {
400 if ( !isset( $repo[
'backend'] ) ) {
401 $repo[
'backend'] = $repo[
'name'] .
'-backend';
477 $bcp47 = strtolower( $bcp47 );
486 Wikimedia\suppressWarnings();
488 Wikimedia\restoreWarnings();
533 if ( defined(
'MW_NO_SESSION' ) ) {
542 MediaWikiServices::allowGlobalInstance();
546 define(
'MW_SERVICE_BOOTSTRAP_COMPLETE', 1 );
554 '$wgServer must be set in LocalSettings.php. ' .
555 'See <a href="https://www.mediawiki.org/wiki/Manual:$wgServer">' .
556 'https://www.mediawiki.org/wiki/Manual:$wgServer</a>.'
567 wfWarn(
'$wgServerName should be derived from $wgCanonicalServer, '
568 .
'not customized. Overwriting $wgServerName.' );
588 wfWarn(
'Secure login was enabled on a server that only supports '
589 .
'HTTP or HTTPS. Disabling secure login.' );
603 'class' => WANObjectCache::class,
610 MediaWikiServices::getInstance()->getDBLoadBalancer()->setTableAliases(
633 Wikimedia\suppressWarnings();
635 Wikimedia\restoreWarnings();
657 time() - ChronologyProtector::POSITION_COOKIE_TTL
659 MediaWikiServices::getInstance()->getDBLoadBalancerFactory()->setRequestInfo( [
661 'UserAgent' =>
$wgRequest->getHeader(
'User-Agent' ),
662 'ChronologyProtection' =>
$wgRequest->getHeader(
'MediaWiki-Chronology-Protection' ),
664 'ChronologyClientId' =>
$cpPosInfo[
'clientId']
665 ??
$wgRequest->getHeader(
'MediaWiki-Chronology-Client-Id' )
669 if (
$wgRequest->getCookie(
'UseDC',
'' ) ===
'master' ) {
673 MediaWikiServices::getInstance()->getMainWANObjectCache()->useInterimHoldOffCaching(
false );
677 (
static function () {
679 $logger = LoggerFactory::getInstance(
'wfDebug' );
681 $self = $_SERVER[
'PHP_SELF'] ??
'';
682 $logger->debug(
"\n\nStart command line script $self" );
684 $debug =
"\n\nStart request {$wgRequest->getMethod()} {$wgRequest->getRequestURL()}\n";
686 $debug .=
"HTTP HEADERS:\n";
687 foreach (
$wgRequest->getAllHeaders() as $name => $value ) {
688 $debug .=
"$name: $value\n";
690 $debug .=
"(end headers)";
708 HeaderCallback::warnIfHeadersSent();
714 if ( !defined(
'MW_NO_SESSION_HANDLER' ) ) {
716 MediaWiki\Session\SessionManager::singleton()
720 $contLang = MediaWikiServices::getInstance()->getContentLanguage();
725 }
catch (
MediaWiki\Session\SessionOverflowException $ex ) {
729 foreach ( $ex->getSessionInfos() as $info ) {
730 $list[] = $info->getProvider()->describe( $contLang );
732 $list = $contLang->listToText( $list );
740 if ( $session->isPersistent() ) {
745 if (
MediaWiki\Session\PHPSessionHandler::isEnabled() &&
746 ( $session->isPersistent() || $session->shouldRememberUser() ) &&
747 session_id() !== $session->getId()
750 if ( session_id() !==
'' ) {
751 wfDebugLog(
'session',
'PHP session {old_id} was already started, changing to {new_id}',
'all', [
752 'old_id' => session_id(),
753 'new_id' => $session->getId(),
755 session_write_close();
757 session_id( $session->getId() );
765 if ( !defined(
'MW_NO_SESSION_HANDLER' ) ) {
767 MediaWiki\Session\SessionManager::singleton()
794 return MediaWikiServices::getInstance()->getParser();
807 call_user_func( $func );
815 if ( $sessionUser->getId() === 0 &&
816 MediaWikiServices::getInstance()->getUserNameUtils()->isValid( $sessionUser->getName() )
818 $res = MediaWikiServices::getInstance()->getAuthManager()->autoCreateUser(
820 MediaWiki\Auth\AuthManager::AUTOCREATE_SOURCE_SESSION,
824 'event' =>
'autocreate',
829 unset( $sessionUser );
$wgCanonicalNamespaceNames
Definitions of the NS_ constants are in Defines.php.
string $wgSharedUploadDirectory
Shortcut for the 'directory' setting of $wgForeignFileRepos.
static getDeprecatedCodeMapping()
Returns a mapping of deprecated language codes that were used in previous versions of MediaWiki to up...
$wgUsersNotifiedOnAllChanges
$wgMaximalPasswordLength
Specifies the maximal length of a user password (T64685).
$wgDBserver
Database host name or IP address.
$wgFileBlacklist
Files with these extensions will never be allowed as uploads.
if( $wgServer===false) if( $wgCanonicalServer===false) $serverParts
$wgPageCreationLog
Maintain a log of page creations at Special:Log/create?
$wgInvalidateCacheOnLocalSettingsChange
Invalidate various caches when LocalSettings.php changes.
$wgRestPath
The URL path to the REST API Defaults to "{$wgScriptPath}/rest.php".
$wgGalleryOptions
Default parameters for the "<gallery>" tag.
$wgTmpDirectory
The local filesystem path to a temporary directory.
$wgRightsText
If either $wgRightsUrl or $wgRightsPage is specified then this variable gives the text for the link.
$wgDBname
Current wiki database name.
$wgDefaultUserOptions['rcdays']
$wgLogHeaders
Lists the message key string for descriptive text to be shown at the top of each log type.
$wgScript
The URL path to index.php.
$wgSharedDB
Shared database for multiple wikis.
$wgLocalFileRepo
File repository structures.
$wgWANObjectCaches
Advanced WAN object cache configuration.
bool string $wgSharedUploadDBname
Shortcut for the ForeignDBRepo 'dbName' setting in $wgForeignFileRepos.
wfMemoryLimit( $newLimit)
Raise PHP's memory limit (if needed).
$wgDBmwschema
Current wiki database schema name.
if(! $wgEmergencyContact) if(! $wgPasswordSender) if(! $wgNoReplyAddress) if( $wgSecureLogin &&substr( $wgServer, 0, 2) !=='//') $wgVirtualRestConfig['global']['domain']
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...
int null $wgRequestTimeLimit
Set a limit on server request wall clock time.
const CANONICAL_NAMES
Definitions of the NS_ constants are in Defines.php.
$wgExtensionAssetsPath
The URL path of the extensions directory.
static installHandler()
Install handlers with PHP.
static detectProtocol()
Detect the protocol from $_SERVER.
if(!defined( 'MEDIAWIKI')) $wgScopeTest
Environment checks.
$wgCacheDirectory
Directory for caching data in the local filesystem.
string $wgSharedThumbnailScriptPath
Shortcut for the 'thumbScriptUrl' setting of $wgForeignFileRepos.
$wgLogo
The URL path of the wiki logo.
wfDebugLog( $logGroup, $text, $dest='all', array $context=[])
Send a line to a supplementary debug log file, if configured, or main debug log if not.
$wgMetaNamespace
Name of the project namespace.
Show an error that looks like an HTTP server error.
$wgDBpassword
Database user's password.
$wgDBprefix
Current wiki database table name prefix.
bool $wgFetchCommonsDescriptions
Shortcut for the 'fetchDescription' setting of $wgForeignFileRepos.
$wgStylePath
The URL path of the skins directory.
$wgRepositoryBaseUrl
Shortcut for the 'descBaseUrl' setting of $wgForeignFileRepos.
$wgUseInstantCommons
Use Wikimedia Commons as a foreign file repository.
wfParseUrl( $url)
parse_url() work-alike, but non-broken.
bool $wgHashedSharedUploadDirectory
Shortcut for the 'hashLevels' setting of $wgForeignFileRepos.
$wgNoReplyAddress
Reply-To address for e-mail notifications.
$wgEmergencyContact
Site admin email address.
wfDeprecated( $function, $version=false, $component=false, $callerOffset=2)
Logs a warning that $function is deprecated.
$wgFooterIcons
Abstract list of footer icons for skins in place of old copyrightico and poweredbyico code You can ad...
$wgMainCacheType
Main cache type.
global $wgCommandLineMode
if(!defined( 'MW_NO_SESSION') &&! $wgCommandLineMode) if(! $wgCommandLineMode) $wgFullyInitialised
if( $wgScript===false) if( $wgLoadScript===false) if( $wgRestPath===false) if( $wgArticlePath===false) if( $wgResourceBasePath===null) if( $wgStylePath===false) if( $wgLocalStylePath===false) if( $wgExtensionAssetsPath===false) if( $wgLogos !==false &&isset( $wgLogos['1x'])) if( $wgLogo===false) if( $wgUploadPath===false) if( $wgUploadDirectory===false) if( $wgReadOnlyFile===false) if( $wgFileCacheDirectory===false) if( $wgDeletedDirectory===false) if( $wgGitInfoCacheDirectory===false && $wgCacheDirectory !==false) if( $wgSharedPrefix===false) if( $wgSharedSchema===false) if( $wgMetaNamespace===false) $wgFileExtensions
Expand dynamic defaults and shortcuts.
if(is_array( $wgExtraNamespaces)) if(count( $wgDummyLanguageCodes) !==0) $wgDummyLanguageCodes
$wgLoadScript
The URL path to load.php.
$wgLogTypes
The logging system has two levels: an event type, which describes the general category and can be vie...
$wgEnableEmail
Set to true to enable the e-mail basic features: Password reminders, etc.
array false $wgLogos
Specification for different versions of the wiki logo.
if(! $wgCookiePrefix) $wgCookiePrefix
$wgSessionName
Override to customise the session name.
$wgCanonicalServer
Canonical URL of the server, to use in IRC feeds and notification e-mails.
bool $wgHashedUploadDirectory
Shortcut for setting hashLevels=2 in $wgLocalFileRepo.
$wgEnotifRevealEditorAddress
$wgMemoryLimit
The minimum amount of memory that MediaWiki "needs"; MediaWiki will try to raise PHP's memory limit i...
$wgLockManagers[]
Initialise $wgLockManagers to include basic FS version.
bool $wgUseSharedUploads
Shortcut for adding an entry to $wgForeignFileRepos.
bool $wgPageLanguageUseDB
Enable page language feature Allows setting page language in database.
$wgLocalTZoffset
Set an offset from UTC in minutes to use for the default timezone setting for anonymous users and new...
bool $wgForceHTTPS
If this is true, when an insecure HTTP request is received, always redirect to HTTPS.
$wgDeletedDirectory
What directory to place deleted uploads in.
bool $wgCacheSharedUploads
Shortcut for the ForeignDBRepo 'hasSharedCache' setting in $wgForeignFileRepos.
Stub object for the user language.
$wgServer
URL of the server.
Class to allow throwing wfDeprecated warnings when people use globals that we do not want them to.
static runner()
Get a HookRunner instance for calling hooks using the new interfaces.
$wgRCMaxAge
Recentchanges items are periodically purged; entries older than this many seconds will go.
$wgSitename
Name of the site.
$wgRightsIcon
Override for copyright metadata.
$wgExtensionFunctions
A list of callback functions which are called once MediaWiki is fully initialised.
$wgUploadBaseUrl
If set, this URL is added to the start of $wgUploadPath to form a complete upload URL.
$wgUploadDirectory
The filesystem path of the images directory.
$wgAllowHTMLEmail
For parts of the system that have been updated to provide HTML email content, send both text and HTML...
static getMain()
Get the RequestContext object associated with the main request.
$wgLogActionsHandlers
The same as above, but here values are names of classes, not messages.
wfIniGetBool( $setting)
Safety wrapper around ini_get() for boolean settings.
$wgResourceBasePath
The default 'remoteBasePath' value for instances of ResourceLoaderFileModule.
$wgArticlePath
The URL path for primary article page views.
$wgCacheEpoch
Set this to current time to invalidate all prior cached pages.
$wgGitInfoCacheDirectory
Directory where GitInfo will look for pre-computed cache files.
static newFromKey( $key,... $params)
Factory function that is just wrapper for the real constructor.
wfTempDir()
Tries to get the system directory for temporary files.
$wgReadOnlyFile
If this lock file exists (size > 0), the wiki will be forced into read-only mode.
$wgThumbnailScriptPath
Give a path here to use thumb.php for thumbnail generation on client request, instead of generating t...
$wgGroupPermissions
Permission keys given to users in each group.
Abort the web request with a custom HTML string that will represent the entire response.
MediaWiki Session SessionId null $wgInitialSessionId
The persistent session ID (if any) loaded at startup.
$wgLocaltimezone
Fake out the timezone that the server thinks it's in.
string $wgSharedUploadDBprefix
Shortcut for the ForeignDBRepo 'tablePrefix' setting in $wgForeignFileRepos.
$wgCookieSecure
Whether the "secure" flag should be set on the cookie.
$wgShellLocale
Locale for LC_ALL, to provide a known environment for locale-sensitive operations.
$wgLogNames
Lists the message key string for each log type.
$wgFileCacheDirectory
Directory where the cached page will be saved.
$wgUploadPath
The URL path for the images directory.
wfWarn( $msg, $callerOffset=1, $level=E_USER_NOTICE)
Send a warning either to the debug log or in a PHP error depending on $wgDevelopmentWarnings.
$wgDBuser
Database username.
$wgDBerrorLogTZ
Timezone to use in the error log.
$wgPasswordPolicy
Password policy for the wiki.
$wgDebugDumpSql
Write SQL queries to the debug log.
if(! $wgDBerrorLogTZ) $wgRequest
static schedulePingback()
Schedule a deferred callable that will check if a pingback should be sent and (if so) proceed to send...
$wgMinimalPasswordLength
Specifies the minimal length of a user password.
if( $wgServerName !==false) $wgServerName
$wgPasswordSender
Sender email address for e-mail notifications.
string $wgPHPSessionHandling
Whether to use PHP session handling ($_SESSION and session_*() functions)
$wgExtraLanguageCodes
List of mappings from one language code to another.
$wgScriptPath
The path we should point to.
static getNonstandardLanguageCodeMapping()
Returns a mapping of non-standard language codes used by (current and previous version of) MediaWiki,...
$wgForeignFileRepos
Enable the use of files from one or more other wikis.
$wgLocalStylePath
The URL path of the skins directory.
$wgSecureLogin
This is to let user authenticate using https when they come from http.
bool $wgGenerateThumbnailOnParse
Render thumbnails while parsing wikitext.
$wgExtraNamespaces
Additional namespaces.
$wgNewUserLog
Maintain a log of newusers at Special:Log/newusers?
$wgMainWANCache
Main Wide-Area-Network cache type.
wfExpandUrl( $url, $defaultProto=PROTO_CURRENT)
Expand a potentially local URL to a fully-qualified URL.
$wgRightsUrl
Set this to specify an external URL containing details about the content license used on your wiki.
$wgUsePathInfo
Whether to support URLs like index.php/Page_title These often break when PHP is set up in CGI mode.
string $wgSharedUploadPath
Shortcut for the 'url' setting of $wgForeignFileRepos.