Go to the documentation of this file.
34 if ( !defined(
'MEDIAWIKI' ) ) {
41 echo
"Error, Setup.php must be included from the file scope.\n";
51 if ( ini_get(
'mbstring.func_overload' ) ) {
52 die(
'MediaWiki does not support installations where mbstring.func_overload is non-zero.' );
56 require_once
"$IP/includes/AutoLoader.php";
59 require_once
"$IP/includes/Defines.php";
62 require_once
"$IP/includes/DefaultSettings.php";
65 require_once
"$IP/includes/GlobalFunctions.php";
68 if ( is_readable(
"$IP/vendor/autoload.php" ) ) {
69 require_once
"$IP/vendor/autoload.php";
76 if ( !interface_exists(
'Psr\Log\LoggerInterface' ) ) {
78 'MediaWiki requires the <a href="https://github.com/php-fig/log">PSR-3 logging ' .
79 "library</a> to be present. This library is not embedded directly in MediaWiki's " .
80 "git repository and must be installed separately by the end user.\n\n" .
81 'Please see <a href="https://www.mediawiki.org/wiki/Download_from_Git' .
82 '#Fetch_external_libraries">mediawiki.org</a> for help on installing ' .
83 'the required components.'
86 trigger_error( $message, E_USER_ERROR );
97 if ( defined(
'MW_CONFIG_CALLBACK' ) ) {
100 if ( !defined(
'MW_CONFIG_FILE' ) ) {
101 define(
'MW_CONFIG_FILE',
"$IP/LocalSettings.php" );
103 require_once MW_CONFIG_FILE;
113 if ( defined(
'MW_SETUP_CALLBACK' ) ) {
114 call_user_func( MW_SETUP_CALLBACK );
129 mb_internal_encoding(
'UTF-8' );
132 putenv(
"LC_ALL=$wgShellLocale" );
174 $wgLogo =
"$wgResourceBasePath/resources/assets/wiki.png";
204 "{$wgStylePath}/common/images/",
205 "{$wgResourceBasePath}/resources/assets/licenses/",
227 "$wgResourceBasePath/resources/assets/poweredby_mediawiki_88x31.png";
229 "$wgResourceBasePath/resources/assets/poweredby_mediawiki_132x47.png 1.5x, " .
230 "$wgResourceBasePath/resources/assets/poweredby_mediawiki_176x62.png 2x";
254 'name' =>
'fsLockManager',
256 'lockDirectory' =>
"{$wgUploadDirectory}/lockdir",
259 'name' =>
'nullLockManager',
270 'imageHeight' => 120,
271 'captionLength' =>
true,
273 'showDimensions' =>
true,
274 'mode' =>
'traditional',
342 'name' =>
'wikimediacommons',
343 'apibase' =>
'https://commons.wikimedia.org/w/api.php',
344 'url' =>
'https://upload.wikimedia.org/wikipedia/commons',
345 'thumbUrl' =>
'https://upload.wikimedia.org/wikipedia/commons/thumb',
347 'transformVia404' =>
true,
348 'fetchDescription' =>
true,
349 'descriptionCacheExpiry' => 43200,
350 'apiThumbCacheExpiry' => 0,
357 if ( !isset( $repo[
'backend'] ) ) {
358 $repo[
'backend'] = $repo[
'name'] .
'-backend';
451 $suhosinMaxValueLength = (int)ini_get(
'suhosin.get.max_value_length' );
452 if ( $suhosinMaxValueLength > 0 && $suhosinMaxValueLength < 2000 ) {
457 unset( $suhosinMaxValueLength );
464 UploadBase::getMaxUploadSize(
'file' ),
465 UploadBase::getMaxPhpUploadSize(),
467 ini_get(
'post_max_size' ) ?: ini_get(
'hhvm.server.max_post_size' ),
469 ) ?: PHP_INT_MAX ) - 1024
514 $bcp47 = strtolower( $bcp47 );
540 Wikimedia\suppressWarnings();
542 Wikimedia\restoreWarnings();
588 wfDeprecated(
'$wgSessionsInObjectCache = false',
'1.27' );
595 "Session data will be stored in \"$cacheType\" cache with " .
596 "expiry $wgObjectCacheSessionExpiry seconds"
607 if ( defined(
'MW_NO_SESSION' ) ) {
624 MediaWikiServices::resetGlobalInstance(
new GlobalVarConfig(),
'quick' );
628 MediaWikiServices::getInstance()->getDBLoadBalancer()->setTableAliases(
642 define(
'MW_SERVICE_BOOTSTRAP_COMPLETE', 1 );
647 foreach ( [
'wgArticlePath',
'wgVariantArticlePath' ]
as $varName ) {
648 if ( $$varName && !preg_match(
'/^(https?:\/\/|\/)/', $$varName ) ) {
650 "If you use a relative URL for \$$varName, it must start " .
651 'with a slash (<code>/</code>).<br><br>See ' .
652 "<a href=\"https://www.mediawiki.org/wiki/Manual:\$$varName\">" .
653 "https://www.mediawiki.org/wiki/Manual:\$$varName</a>."
667 wfWarn(
'$wgServerName should be derived from $wgCanonicalServer, '
668 .
'not customized. Overwriting $wgServerName.' );
688 wfWarn(
'Secure login was enabled on a server that only supports '
689 .
'HTTP or HTTPS. Disabling secure login.' );
701 if ( !isset( $wgDisableCounters ) ) {
702 $wgDisableCounters =
true;
712 'channels' => [
'purge' =>
'wancache-main-default-purge' ]
729 Wikimedia\suppressWarnings();
731 Wikimedia\restoreWarnings();
753 time() - ChronologyProtector::POSITION_COOKIE_TTL
755 MediaWikiServices::getInstance()->getDBLoadBalancerFactory()->setRequestInfo( [
757 'UserAgent' =>
$wgRequest->getHeader(
'User-Agent' ),
758 'ChronologyProtection' =>
$wgRequest->getHeader(
'ChronologyProtection' ),
760 'ChronologyClientId' =>
$cpPosInfo[
'clientId']
764 if (
$wgRequest->getCookie(
'UseDC',
'' ) ===
'master' ) {
768 MediaWikiServices::getInstance()->getMainWANObjectCache()->useInterimHoldOffCaching(
false );
773 wfDebug(
"\n\nStart command line script $self\n" );
775 $debug =
"\n\nStart request {$wgRequest->getMethod()} {$wgRequest->getRequestURL()}\n";
778 $debug .=
"HTTP HEADERS:\n";
781 $debug .=
"$name: $value\n";
791 'cluster: ' . get_class(
$wgMemc ) .
809 $wgContLang = MediaWikiServices::getInstance()->getContentLanguage();
820 new MediaWiki\Auth\TemporaryPasswordPrimaryAuthenticationProvider( [
821 'authoritative' =>
false,
824 new MediaWiki\Auth\LocalPasswordPrimaryAuthenticationProvider( [
825 'authoritative' =>
true,
827 ],
'$wgAuth is ' . get_class(
$wgAuth ) );
843 if ( !defined(
'MW_NO_SESSION_HANDLER' ) ) {
845 MediaWiki\Session\SessionManager::singleton()
852 }
catch ( OverflowException $ex ) {
853 if ( isset( $ex->sessionInfos ) &&
count( $ex->sessionInfos ) >= 2 ) {
857 foreach ( $ex->sessionInfos
as $info ) {
858 $list[] = $info->getProvider()->describe(
$wgContLang );
862 Message::newFromKey(
'sessionmanager-tie', $list )->inLanguage(
$wgContLang )->
plain()
870 if ( $session->isPersistent() ) {
875 if (
MediaWiki\Session\PHPSessionHandler::isEnabled() &&
876 ( $session->isPersistent() || $session->shouldRememberUser() ) &&
877 session_id() !== $session->getId()
880 if ( session_id() !==
'' ) {
881 wfDebugLog(
'session',
'PHP session {old_id} was already started, changing to {new_id}',
'all', [
882 'old_id' => session_id(),
883 'new_id' => $session->getId(),
885 session_write_close();
887 session_id( $session->getId() );
895 if ( !defined(
'MW_NO_SESSION_HANDLER' ) ) {
897 MediaWiki\Session\SessionManager::singleton()
922 return MediaWikiServices::getInstance()->getParser();
938 call_user_func( $func );
948 MediaWiki\Auth\AuthManager::AUTOCREATE_SOURCE_SESSION,
952 'event' =>
'autocreate',
957 unset( $sessionUser );
$wgCanonicalNamespaceNames
Definitions of the NS_ constants are in Defines.php.
string $wgSharedUploadDirectory
Shortcut for the 'directory' setting of $wgForeignFileRepos.
$wgLocalInterwiki
The interwiki prefix of the current wiki, or false if it doesn't have one.
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.
controlled by the following MediaWiki still creates a BagOStuff but calls it to it are no ops If the cache daemon can t be it should also disable itself fairly $wgDBname
static getLocalClusterInstance()
Get the main cluster-local cache object.
$wgRCLinkDays
List of Days options to list in the Special:Recentchanges and Special:Recentchangeslinked pages.
$wgResourceLoaderMaxQueryLength
If set to a positive number, ResourceLoader will not generate URLs whose query string is more than th...
$wgProfileOnly
Don't put non-profiling info into log file.
if( $wgScript===false) if( $wgLoadScript===false) if( $wgArticlePath===false) if(!empty( $wgActionPaths) &&!isset( $wgActionPaths['view'])) if( $wgResourceBasePath===null) if( $wgStylePath===false) if( $wgLocalStylePath===false) if( $wgExtensionAssetsPath===false) if( $wgLogo===false) if( $wgUploadPath===false) if( $wgUploadDirectory===false) if( $wgReadOnlyFile===false) if( $wgFileCacheDirectory===false) if( $wgDeletedDirectory===false) if( $wgGitInfoCacheDirectory===false && $wgCacheDirectory !==false) if( $wgEnableParserCache===false) 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( $wgLocalInterwiki) if( $wgSharedPrefix===false) if( $wgSharedSchema===false) if(! $wgCookiePrefix) $wgCookiePrefix
if( $wgMetaNamespace===false) if( $wgResourceLoaderMaxQueryLength===false) $wgMinUploadChunkSize
$wgPageCreationLog
Maintain a log of page creations at Special:Log/create?
$wgInvalidateCacheOnLocalSettingsChange
Invalidate various caches when LocalSettings.php changes.
$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.
static instance()
Singleton.
Class to implement stub globals, which are globals that delay loading the their associated module cod...
$wgLogHeaders
Lists the message key string for descriptive text to be shown at the top of each log type.
if( $wgRCFilterByAge) $wgDefaultUserOptions['rcdays']
$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.
if( $wgUseFileCache|| $wgUseSquid) $wgHtml5
$wgDBmwschema
Mediawiki schema.
if(! $wgEmergencyContact) if(! $wgPasswordSender) if(! $wgNoReplyAddress) if( $wgSecureLogin &&substr( $wgServer, 0, 2) !=='//') $wgVirtualRestConfig['global']['domain']
$wgGenerateThumbnailOnParse
Allow thumbnail rendering on page view.
$wgExtensionAssetsPath
The URL path of the extensions directory.
static installHandler()
Install handlers with PHP.
static detectProtocol()
Detect the protocol from $_SERVER.
$wgUseSquid
Enable/disable CDN.
if(!defined( 'MEDIAWIKI')) $wgScopeTest
This file is not a valid entry point, perform no further processing unless MEDIAWIKI is defined.
$wgCacheDirectory
Directory for caching data in the local filesystem.
static isValidUserName( $name)
Is the input a valid username?
string $wgSharedThumbnailScriptPath
Shortcut for the 'thumbScriptUrl' setting of $wgForeignFileRepos.
$wgLogo
The URL path of the wiki logo.
$wgEnableParserCache
Kept for extension compatibility; see $wgParserCacheType.
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
Table name prefix.
bool $wgFetchCommonsDescriptions
Shortcut for the 'fetchDescription' setting of $wgForeignFileRepos.
$wgStylePath
The URL path of the skins directory.
injection txt This is an overview of how MediaWiki makes use of dependency injection The design described here grew from the discussion of RFC T384 The term dependency this means that anything an object needs to operate should be injected from the the object itself should only know narrow no concrete implementation of the logic it relies on The requirement to inject everything typically results in an architecture that based on two main types of and essentially stateless service objects that use other service objects to operate on the value objects As of the beginning MediaWiki is only starting to use the DI approach Much of the code still relies on global state or direct resulting in a highly cyclical dependency which acts as the top level factory for services in MediaWiki which can be used to gain access to default instances of various services MediaWikiServices however also allows new services to be defined and default services to be redefined Services are defined or redefined by providing a callback the instantiator that will return a new instance of the service When it will create an instance of MediaWikiServices and populate it with the services defined in the files listed by thereby bootstrapping the DI framework Per $wgServiceWiringFiles lists includes ServiceWiring php
foreach([ 'wgArticlePath', 'wgVariantArticlePath'] as $varName) $ps_default2
$wgRepositoryBaseUrl
Shortcut for the 'descBaseUrl' setting of $wgForeignFileRepos.
$wgUseInstantCommons
Use Wikimedia Commons as a foreign file repository.
$wgHashedUploadDirectory
Set this to false if you do not want MediaWiki to divide your images directory into many subdirectori...
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)
Throws 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...
$wgUseFileCache
This will cache static pages for non-logged-in users to reduce database traffic on public sites.
global $wgCommandLineMode
$wgDebugLogGroups
Map of string log group names to log destinations.
if(is_array( $wgExtraNamespaces)) if(count( $wgDummyLanguageCodes) !==0) $wgDummyLanguageCodes
$wgLoadScript
The URL path to load.php.
static getInstance( $id)
Get a cached instance of the specified type of cache object.
as see the revision history and available at free of to any person obtaining a copy of this software and associated documentation to deal in the Software without including without limitation the rights to use
this hook is for auditing only or null if authentication failed before getting that far or null if we can t even determine that probably a stub it is not rendered in wiki pages or galleries in category pages allow injecting custom HTML after the section Any uses of the hook need to handle escaping see BaseTemplate::getToolbox and BaseTemplate::makeListItem for details on the format of individual items inside of this array or by returning and letting standard HTTP rendering take place modifiable or by returning false and taking over the output modifiable & $code
$wgLogTypes
The logging system has two levels: an event type, which describes the general category and can be vie...
$wgParserCacheType
The cache type for storing article HTML.
$wgEnableEmail
Set to true to enable the e-mail basic features: Password reminders, etc.
Accesses configuration settings from $GLOBALS.
$wgSessionName
Override to customise the session name.
wfMemoryLimit()
Set PHP's memory limit to the larger of php.ini or $wgMemoryLimit.
$wgDebugLogFile
Filename for debug logging.
wfDebug( $text, $dest='all', array $context=[])
Sends a line to the debug log if enabled or, optionally, to a comment in output.
$wgCanonicalServer
Canonical URL of the server, to use in IRC feeds and notification e-mails.
$wgEnotifRevealEditorAddress
$wgLockManagers[]
Initialise $wgLockManagers to include basic FS version.
bool $wgUseSharedUploads
Shortcut for adding an entry to $wgForeignFileRepos.
foreach( $wgExtensionFunctions as $func) if(!defined( 'MW_NO_SESSION') &&! $wgCommandLineMode) if(! $wgCommandLineMode) $wgFullyInitialised
if(defined( 'MW_SETUP_CALLBACK')) $fname
Customization point after all loading (constants, functions, classes, DefaultSettings,...
bool $wgPageLanguageUseDB
Enable page language feature Allows setting page language in database.
Allows to change the fields on the form that will be generated $name
if( $wgInvalidateCacheOnLocalSettingsChange) if( $wgNewUserLog) if( $wgPageCreationLog) if( $wgPageLanguageUseDB) if( $wgCookieSecure==='detect') if( $wgProfileOnly) if( $wgMinimalPasswordLength !==false) if( $wgMaximalPasswordLength !==false) if(! $wgSessionsInObjectCache) $wgSessionsInObjectCache
$wgDebugPrintHttpHeaders
Print HTTP headers for every request in the debug information.
$wgLocalTZoffset
Set an offset from UTC in minutes to use for the default timezone setting for anonymous users and new...
$wgNamespaceAliases['Image']
The canonical names of namespaces 6 and 7 are, as of v1.14, "File" and "File_talk".
$wgLocalInterwikis
Array for multiple $wgLocalInterwiki values, in case there are several interwiki prefixes that point ...
$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.
$wgRCMaxAge
Recentchanges items are periodically purged; entries older than this many seconds will go.
$wgLanguageCode
Site language code.
$wgSitename
Name of the site.
$wgRightsIcon
Override for copyright metadata.
static init()
Enabled the debugger and load resource module.
$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.
if( $wgCanonicalServer===false) $serverParts
$wgSessionCacheType
The cache type for storing session data.
wfGetMessageCacheStorage()
Get the cache object used by the message cache.
$wgCacheEpoch
Set this to current time to invalidate all prior cached pages.
wfShorthandToInteger( $string='', $default=-1)
Converts shorthand byte notation to integer form.
$wgGitInfoCacheDirectory
Directory where GitInfo will look for pre-computed cache files.
wfTempDir()
Tries to get the system directory for temporary files.
CACHE_MEMCACHED $wgMainCacheType
$wgReadOnlyFile
If this lock file exists (size > 0), the wiki will be forced into read-only mode.
if( $wgSkipSkin) $wgSkipSkins[]
$wgThumbnailScriptPath
Give a path here to use thumb.php for thumbnail generation on client request, instead of generating t...
foreach(LanguageCode::getNonstandardLanguageCodeMapping() as $code=> $bcp47) $wgContLanguageCode
Exception class which takes an HTML error message, and does not produce a backtrace.
$wgLocaltimezone
Fake out the timezone that the server thinks it's in.
This document is intended to provide useful advice for parties seeking to redistribute MediaWiki to end users It s targeted particularly at maintainers for Linux since it s been observed that distribution packages of MediaWiki often break We ve consistently had to recommend that users seeking support use official tarballs instead of their distribution s and this often solves whatever problem the user is having It would be nice if this could such as
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.
$wgGroupPermissions['sysop']['replacetext']
you have access to all of the normal MediaWiki so you can get a DB use the etc For full docs on the Maintenance class
$wgDBuser
Database username.
$wgAuth $wgAuth
Authentication plugin.
$wgDBerrorLogTZ
Timezone to use in the error log.
$wgPasswordPolicy
Password policy for local wiki users.
$wgDebugDumpSql
Write SQL queries to the debug log.
if(! $wgDBerrorLogTZ) $wgRequest
injection txt This is an overview of how MediaWiki makes use of dependency injection The design described here grew from the discussion of RFC T384 The term dependency this means that anything an object needs to operate should be injected from the the object itself should only know narrow no concrete implementation of the logic it relies on The requirement to inject everything typically results in an architecture that based on two main types of and essentially stateless service objects that use other service objects to operate on the value objects As of the beginning MediaWiki is only starting to use the DI approach Much of the code still relies on global state or direct resulting in a highly cyclical dependency MediaWikiServices
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.
$wgRCFilterByAge
Filter $wgRCLinkDays by $wgRCMaxAge to avoid showing links for numbers higher than what will be store...
if( $wgServerName !==false) $wgServerName
$wgDebugToolbar
Display the new debugging toolbar.
$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 run( $event, array $args=[], $deprecatedVersion=null)
Call hook functions defined in Hooks::register and $wgHooks.
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.
$wgMainStash
Main object stash type.
$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.