Go to the documentation of this file.
32 if ( !defined(
'MEDIAWIKI' ) ) {
42 if ( file_exists(
"$IP/StartProfiler.php" ) ) {
43 require
"$IP/StartProfiler.php";
47 require_once
"$IP/includes/AutoLoader.php";
50 require_once
"$IP/includes/Defines.php";
53 require_once
"$IP/includes/DefaultSettings.php";
56 require_once
"$IP/includes/GlobalFunctions.php";
59 if ( is_readable(
"$IP/vendor/autoload.php" ) ) {
60 require_once
"$IP/vendor/autoload.php";
67 if ( !interface_exists(
'Psr\Log\LoggerInterface' ) ) {
69 'MediaWiki requires the <a href="https://github.com/php-fig/log">PSR-3 logging ' .
70 "library</a> to be present. This library is not embedded directly in MediaWiki's " .
71 "git repository and must be installed separately by the end user.\n\n" .
72 'Please see <a href="https://www.mediawiki.org/wiki/Download_from_Git' .
73 '#Fetch_external_libraries">mediawiki.org</a> for help on installing ' .
74 'the required components.'
77 trigger_error( $message, E_USER_ERROR );
88 if ( defined(
'MW_CONFIG_CALLBACK' ) ) {
91 if ( !defined(
'MW_CONFIG_FILE' ) ) {
92 define(
'MW_CONFIG_FILE',
"$IP/LocalSettings.php" );
94 require_once MW_CONFIG_FILE;
104 if ( defined(
'MW_SETUP_CALLBACK' ) ) {
105 call_user_func( MW_SETUP_CALLBACK );
122 echo
"Error, Setup.php must be included from the file scope, after DefaultSettings.php\n";
126 mb_internal_encoding(
'UTF-8' );
129 putenv(
"LC_ALL=$wgShellLocale" );
171 $wgLogo =
"$wgResourceBasePath/resources/assets/wiki.png";
201 "{$wgStylePath}/common/images/",
202 "{$wgResourceBasePath}/resources/assets/licenses/",
224 "$wgResourceBasePath/resources/assets/poweredby_mediawiki_88x31.png";
226 "$wgResourceBasePath/resources/assets/poweredby_mediawiki_132x47.png 1.5x, " .
227 "$wgResourceBasePath/resources/assets/poweredby_mediawiki_176x62.png 2x";
251 'name' =>
'fsLockManager',
253 'lockDirectory' =>
"{$wgUploadDirectory}/lockdir",
256 'name' =>
'nullLockManager',
267 'imageHeight' => 120,
268 'captionLength' =>
true,
270 'showDimensions' =>
true,
271 'mode' =>
'traditional',
332 'name' =>
'wikimediacommons',
333 'apibase' =>
'https://commons.wikimedia.org/w/api.php',
334 'url' =>
'https://upload.wikimedia.org/wikipedia/commons',
335 'thumbUrl' =>
'https://upload.wikimedia.org/wikipedia/commons/thumb',
337 'transformVia404' =>
true,
338 'fetchDescription' =>
true,
339 'descriptionCacheExpiry' => 43200,
340 'apiThumbCacheExpiry' => 0,
354 if ( !isset( $repo[
'backend'] ) ) {
355 $repo[
'backend'] = $repo[
'name'] .
'-backend';
454 $suhosinMaxValueLength = (int)ini_get(
'suhosin.get.max_value_length' );
455 if ( $suhosinMaxValueLength > 0 && $suhosinMaxValueLength < 2000 ) {
460 unset( $suhosinMaxValueLength );
470 ini_get(
'post_max_size' ) ?: ini_get(
'hhvm.server.max_post_size' ),
472 ) ?: PHP_INT_MAX ) - 1024
530 Wikimedia\suppressWarnings();
532 Wikimedia\restoreWarnings();
572 wfDeprecated(
'$wgSessionsInObjectCache = false',
'1.27' );
579 "Session data will be stored in \"$cacheType\" cache with " .
580 "expiry $wgObjectCacheSessionExpiry seconds"
591 if ( defined(
'MW_NO_SESSION' ) ) {
608 MediaWikiServices::resetGlobalInstance(
new GlobalVarConfig(),
'quick' );
612 MediaWikiServices::getInstance()->getDBLoadBalancer()->setTableAliases(
626 define(
'MW_SERVICE_BOOTSTRAP_COMPLETE', 1 );
630 require_once
"$IP/includes/compat/normal/UtfNormalUtil.php";
635 foreach ( [
'wgArticlePath',
'wgVariantArticlePath' ]
as $varName ) {
636 if ( $$varName && !preg_match(
'/^(https?:\/\/|\/)/', $$varName ) ) {
638 "If you use a relative URL for \$$varName, it must start " .
639 'with a slash (<code>/</code>).<br><br>See ' .
640 "<a href=\"https://www.mediawiki.org/wiki/Manual:\$$varName\">" .
641 "https://www.mediawiki.org/wiki/Manual:\$$varName</a>."
657 wfWarn(
'$wgServerName should be derived from $wgCanonicalServer, '
658 .
'not customized. Overwriting $wgServerName.' );
678 wfWarn(
'Secure login was enabled on a server that only supports '
679 .
'HTTP or HTTPS. Disabling secure login.' );
691 if ( !isset( $wgDisableCounters ) ) {
692 $wgDisableCounters =
true;
702 'channels' => [
'purge' =>
'wancache-main-default-purge' ]
719 Wikimedia\suppressWarnings();
721 Wikimedia\restoreWarnings();
739 MediaWikiServices::getInstance()->getDBLoadBalancerFactory()->setRequestInfo( [
741 'UserAgent' =>
$wgRequest->getHeader(
'User-Agent' ),
742 'ChronologyProtection' =>
$wgRequest->getHeader(
'ChronologyProtection' ),
744 'ChronologyPositionIndex' =>
748 if (
$wgRequest->getCookie(
'UseDC',
'' ) ===
'master' ) {
752 MediaWikiServices::getInstance()->getMainWANObjectCache()->useInterimHoldOffCaching(
false );
757 wfDebug(
"\n\nStart command line script $self\n" );
759 $debug =
"\n\nStart request {$wgRequest->getMethod()} {$wgRequest->getRequestURL()}\n";
762 $debug .=
"HTTP HEADERS:\n";
765 $debug .=
"$name: $value\n";
781 return MediaWikiServices::getInstance()->getParserCache()->getCacheStorage();
785 'cluster: ' . get_class(
$wgMemc ) .
814 new MediaWiki\Auth\TemporaryPasswordPrimaryAuthenticationProvider( [
815 'authoritative' =>
false,
818 new MediaWiki\Auth\LocalPasswordPrimaryAuthenticationProvider( [
819 'authoritative' =>
true,
821 ],
'$wgAuth is ' . get_class(
$wgAuth ) );
839 if ( !defined(
'MW_NO_SESSION_HANDLER' ) ) {
841 MediaWiki\Session\SessionManager::singleton()
848 }
catch ( OverflowException $ex ) {
849 if ( isset( $ex->sessionInfos ) && count( $ex->sessionInfos ) >= 2 ) {
853 foreach ( $ex->sessionInfos
as $info ) {
854 $list[] = $info->getProvider()->describe(
$wgContLang );
866 if ( $session->isPersistent() ) {
871 if (
MediaWiki\Session\PHPSessionHandler::isEnabled() &&
872 ( $session->isPersistent() || $session->shouldRememberUser() ) &&
873 session_id() !== $session->getId()
876 if ( session_id() !==
'' ) {
877 wfDebugLog(
'session',
'PHP session {old_id} was already started, changing to {new_id}',
'all', [
878 'old_id' => session_id(),
879 'new_id' => $session->getId(),
881 session_write_close();
883 session_id( $session->getId() );
891 if ( !defined(
'MW_NO_SESSION_HANDLER' ) ) {
893 MediaWiki\Session\SessionManager::singleton()
918 return MediaWikiServices::getInstance()->getParser();
935 if ( is_object( $func ) && $func instanceof Closure ) {
936 $profName =
$fname .
'-extensions-closure';
937 } elseif ( is_array( $func ) ) {
938 if ( is_object( $func[0] ) ) {
939 $profName =
$fname .
'-extensions-' . get_class( $func[0] ) .
'::' . $func[1];
941 $profName =
$fname .
'-extensions-' . implode(
'::', $func );
944 $profName =
$fname .
'-extensions-' . strval( $func );
948 call_user_func( $func );
960 MediaWiki\Auth\AuthManager::AUTOCREATE_SOURCE_SESSION,
965 'event' =>
'autocreate',
970 unset( $sessionUser );
$wgCanonicalNamespaceNames
Definitions of the NS_ constants are in Defines.php.
$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...
if(!is_object( $wgAuth)) if( $wgAuth &&! $wgAuth instanceof MediaWiki\Auth\AuthManagerAuthPlugin) $ps_session
$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.
$wgRCLinkDays
List of Days options to list in the Special:Recentchanges and Special:Recentchangeslinked pages.
Apache License January AND DISTRIBUTION Definitions License shall mean the terms and conditions for use
$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...
$wgExperimentalHtmlIds
Abandoned experiment with HTML5-style ID escaping.
if( $wgLocalInterwiki) if( $wgSharedPrefix===false) if( $wgSharedSchema===false) if(! $wgCookiePrefix) $wgCookiePrefix
if( $wgMetaNamespace===false) if( $wgResourceLoaderMaxQueryLength===false) $wgMinUploadChunkSize
$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.
$wgVersion
MediaWiki version number.
if( $wgUseFileCache|| $wgUseSquid) $wgHtml5
$wgSharedUploadDBprefix
Optional table prefix used in database.
static getMaxPhpUploadSize()
Get the PHP maximum uploaded file size, based on ini settings.
$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.
$wgUseSharedUploads
If you operate multiple wikis, you can define a shared upload path here.
$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.
$wgFragmentMode
How should section IDs be encoded? This array can contain 1 or 2 elements, each of them can be one of...
$wgHashedSharedUploadDirectory
Set the following to false especially if you have a set of files that need to be accessible by all wi...
$wgCacheDirectory
Directory for caching data in the local filesystem.
static isValidUserName( $name)
Is the input a valid username?
$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.
$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
$wgRepositoryBaseUrl
Base URL for a repository wiki.
$wgUseInstantCommons
Use Commons as a remote 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.
$wgNoReplyAddress
Reply-To address for e-mail notifications.
wfGetMainCache()
Get the main cache object.
$wgSharedUploadPath
Full path on the web server where shared uploads can be found.
controlled by $wgMainCacheType controlled by $wgParserCacheType controlled by $wgMessageCacheType If you set CACHE_NONE to one of the three control default value for MediaWiki still create a but requests to it are no ops and we always fall through to the database If the cache daemon can t be it should also disable itself fairly smoothly By $wgMemc is used but when it is $parserMemc or $messageMemc this is mentioned $wgDBname
$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.
$wgLoadScript
The URL path to load.php.
static getInstance( $id)
Get a cached instance of the specified type of cache object.
$wgFetchCommonsDescriptions
Fetch commons image description pages and display them on the local wiki?
$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.
when a variable name is used in a it is silently declared as a new masking the global
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.
if(is_array( $wgExtraNamespaces)) $wgDummyLanguageCodes
$wgCanonicalServer
Canonical URL of the server, to use in IRC feeds and notification e-mails.
$wgEnotifRevealEditorAddress
$wgLockManagers[]
Initialise $wgLockManagers to include basic FS version.
$wgCacheSharedUploads
Cache shared metadata in memcached.
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.
$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...
bool $wgForceHTTPS
If this is true, when an insecure HTTP request is received, always redirect to HTTPS.
$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.
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.
$wgRCMaxAge
Recentchanges items are periodically purged; entries older than this many seconds will go.
$wgLanguageCode
Site language code.
if( $wgExperimentalHtmlIds) $rcMaxAgeDays
$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.
if( $wgInvalidateCacheOnLocalSettingsChange) if( $wgNewUserLog) if( $wgPageLanguageUseDB) if( $wgCookieSecure==='detect') if( $wgProfileOnly) if( $wgMinimalPasswordLength !==false) if( $wgMaximalPasswordLength !==false) if(! $wgSessionsInObjectCache) $wgSessionsInObjectCache
$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...
if(!defined( 'MEDIAWIKI')) $wgProfiler
This file is not a valid entry point, perform no further processing unless MEDIAWIKI is defined.
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.
static getMaxUploadSize( $forType=null)
Get the MediaWiki maximum uploaded file size for given type of upload, based on $wgMaxUploadSize.
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.
Allows to change the fields on the form that will be generated $name
$wgSharedUploadDBname
DB name with metadata about shared directory.
wfTempDir()
Tries to get the system directory for temporary files.
$wgSharedUploadDirectory
Path on the file system where shared uploads can be found.
$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...
$wgGroupPermissions
Permission keys given to users in each group.
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.
CACHE_MEMCACHED $wgMainCacheType
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
$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.
static factory( $code)
Get a cached or new language object for a given language code.
wfWarn( $msg, $callerOffset=1, $level=E_USER_NOTICE)
Send a warning either to the debug log or in a PHP error depending on $wgDevelopmentWarnings.
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 newFromKey( $key)
Factory function that is just wrapper for the real constructor.
$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 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.
$wgSharedThumbnailScriptPath