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";
70 } elseif ( file_exists(
"$IP/vendor/autoload.php" ) ) {
71 die(
"$IP/vendor/autoload.php exists but is not readable" );
78 if ( !interface_exists(
'Psr\Log\LoggerInterface' ) ) {
80 'MediaWiki requires the <a href="https://github.com/php-fig/log">PSR-3 logging ' .
81 "library</a> to be present. This library is not embedded directly in MediaWiki's " .
82 "git repository and must be installed separately by the end user.\n\n" .
83 'Please see <a href="https://www.mediawiki.org/wiki/Download_from_Git' .
84 '#Fetch_external_libraries">mediawiki.org</a> for help on installing ' .
85 'the required components.' 88 trigger_error( $message, E_USER_ERROR );
99 if ( defined(
'MW_CONFIG_CALLBACK' ) ) {
102 if ( !defined(
'MW_CONFIG_FILE' ) ) {
103 define(
'MW_CONFIG_FILE',
"$IP/LocalSettings.php" );
105 require_once MW_CONFIG_FILE;
115 if ( defined(
'MW_SETUP_CALLBACK' ) ) {
116 call_user_func( MW_SETUP_CALLBACK );
131 mb_internal_encoding(
'UTF-8' );
134 putenv(
"LC_ALL=$wgShellLocale" );
176 $wgLogo =
"$wgResourceBasePath/resources/assets/wiki.png";
202 "{$wgStylePath}/common/images/",
203 "{$wgResourceBasePath}/resources/assets/licenses/",
225 "$wgResourceBasePath/resources/assets/poweredby_mediawiki_88x31.png";
227 "$wgResourceBasePath/resources/assets/poweredby_mediawiki_132x47.png 1.5x, " .
228 "$wgResourceBasePath/resources/assets/poweredby_mediawiki_176x62.png 2x";
252 'name' =>
'fsLockManager',
254 'lockDirectory' =>
"{$wgUploadDirectory}/lockdir",
257 'name' =>
'nullLockManager',
268 'imageHeight' => 120,
269 'captionLength' =>
true,
271 'showDimensions' =>
true,
272 'mode' =>
'traditional',
340 'name' =>
'wikimediacommons',
341 'apibase' =>
'https://commons.wikimedia.org/w/api.php',
342 'url' =>
'https://upload.wikimedia.org/wikipedia/commons',
343 'thumbUrl' =>
'https://upload.wikimedia.org/wikipedia/commons/thumb',
345 'transformVia404' =>
true,
346 'fetchDescription' =>
true,
347 'descriptionCacheExpiry' => 43200,
348 'apiThumbCacheExpiry' => 0,
355 if ( !isset( $repo[
'backend'] ) ) {
356 $repo[
'backend'] = $repo[
'name'] .
'-backend';
448 $suhosinMaxValueLength = (int)ini_get(
'suhosin.get.max_value_length' );
449 if ( $suhosinMaxValueLength > 0 && $suhosinMaxValueLength < 2000 ) {
454 unset( $suhosinMaxValueLength );
464 ini_get(
'post_max_size' ) ?: ini_get(
'hhvm.server.max_post_size' ),
466 ) ?: PHP_INT_MAX ) - 1024
511 $bcp47 = strtolower( $bcp47 );
537 Wikimedia\suppressWarnings();
539 Wikimedia\restoreWarnings();
589 if ( defined(
'MW_NO_SESSION' ) ) {
606 MediaWikiServices::resetGlobalInstance(
new GlobalVarConfig(),
'quick' );
610 MediaWikiServices::getInstance()->getDBLoadBalancer()->setTableAliases(
624 define(
'MW_SERVICE_BOOTSTRAP_COMPLETE', 1 );
629 foreach ( [
'wgArticlePath',
'wgVariantArticlePath' ]
as $varName ) {
630 if ( $$varName && !preg_match(
'/^(https?:\/\/|\/)/', $$varName ) ) {
632 "If you use a relative URL for \$$varName, it must start " .
633 'with a slash (<code>/</code>).<br><br>See ' .
634 "<a href=\"https://www.mediawiki.org/wiki/Manual:\$$varName\">" .
635 "https://www.mediawiki.org/wiki/Manual:\$$varName</a>." 649 wfWarn(
'$wgServerName should be derived from $wgCanonicalServer, ' 650 .
'not customized. Overwriting $wgServerName.' );
670 wfWarn(
'Secure login was enabled on a server that only supports ' 671 .
'HTTP or HTTPS. Disabling secure login.' );
683 if ( !isset( $wgDisableCounters ) ) {
684 $wgDisableCounters =
true;
687 if ( $wgMainWANCache ===
false ) {
690 $wgMainWANCache =
'mediawiki-main-default';
710 Wikimedia\suppressWarnings();
712 Wikimedia\restoreWarnings();
734 time() - ChronologyProtector::POSITION_COOKIE_TTL
736 MediaWikiServices::getInstance()->getDBLoadBalancerFactory()->setRequestInfo( [
738 'UserAgent' =>
$wgRequest->getHeader(
'User-Agent' ),
739 'ChronologyProtection' =>
$wgRequest->getHeader(
'ChronologyProtection' ),
741 'ChronologyClientId' =>
$cpPosInfo[
'clientId']
745 if (
$wgRequest->getCookie(
'UseDC',
'' ) ===
'master' ) {
749 MediaWikiServices::getInstance()->getMainWANObjectCache()->useInterimHoldOffCaching(
false );
753 if ( $wgCommandLineMode ) {
754 wfDebug(
"\n\nStart command line script $self\n" );
756 $debug =
"\n\nStart request {$wgRequest->getMethod()} {$wgRequest->getRequestURL()}\n";
759 $debug .=
"HTTP HEADERS:\n";
762 $debug .=
"$name: $value\n";
772 'cluster: ' . get_class(
$wgMemc ) .
773 ', WAN: ' . ( $wgMainWANCache ===
CACHE_NONE ?
'CACHE_NONE' : $wgMainWANCache ) .
790 $wgContLang = MediaWikiServices::getInstance()->getContentLanguage();
800 if ( !defined(
'MW_NO_SESSION' ) && !$wgCommandLineMode ) {
808 if ( !defined(
'MW_NO_SESSION_HANDLER' ) ) {
810 MediaWiki\Session\SessionManager::singleton()
817 }
catch ( OverflowException $ex ) {
818 if ( isset( $ex->sessionInfos ) && count( $ex->sessionInfos ) >= 2 ) {
822 foreach ( $ex->sessionInfos
as $info ) {
823 $list[] = $info->getProvider()->describe(
$wgContLang );
835 if ( $session->isPersistent() ) {
840 if (
MediaWiki\Session\PHPSessionHandler::isEnabled() &&
841 ( $session->isPersistent() || $session->shouldRememberUser() ) &&
842 session_id() !== $session->getId()
845 if ( session_id() !==
'' ) {
846 wfDebugLog(
'session',
'PHP session {old_id} was already started, changing to {new_id}',
'all', [
847 'old_id' => session_id(),
848 'new_id' => $session->getId(),
850 session_write_close();
852 session_id( $session->getId() );
860 if ( !defined(
'MW_NO_SESSION_HANDLER' ) ) {
862 MediaWiki\Session\SessionManager::singleton()
887 return MediaWikiServices::getInstance()->getParser();
903 call_user_func( $func );
908 if ( !defined(
'MW_NO_SESSION' ) && !$wgCommandLineMode ) {
913 MediaWiki\Auth\AuthManager::AUTOCREATE_SOURCE_SESSION,
917 'event' =>
'autocreate',
922 unset( $sessionUser );
925 if ( !$wgCommandLineMode ) {
$wgForeignFileRepos
Enable the use of files from one or more other wikis.
$wgUseInstantCommons
Use Wikimedia Commons as a foreign file repository.
$wgFooterIcons
Abstract list of footer icons for skins in place of old copyrightico and poweredbyico code You can ad...
$wgNewUserLog
Maintain a log of newusers at Special:Log/newusers?
$wgMainStash
Main object stash type.
wfWarn( $msg, $callerOffset=1, $level=E_USER_NOTICE)
Send a warning either to the debug log or in a PHP error depending on $wgDevelopmentWarnings.
$wgCanonicalNamespaceNames
Definitions of the NS_ constants are in Defines.php.
$wgScript
The URL path to index.php.
$wgRightsUrl
Set this to specify an external URL containing details about the content license used on your wiki...
$wgDBerrorLogTZ
Timezone to use in the error log.
if( $wgRCFilterByAge) $wgDefaultUserOptions['rcdays']
static getNonstandardLanguageCodeMapping()
Returns a mapping of non-standard language codes used by (current and previous version of) MediaWiki...
$wgSitename
Name of the site.
$wgUsersNotifiedOnAllChanges
CACHE_MEMCACHED $wgMainCacheType
$wgDebugLogGroups
Map of string log group names to log destinations.
Apache License January AND DISTRIBUTION Definitions License shall mean the terms and conditions for use
if( $wgLocalInterwiki) if( $wgSharedPrefix===false) if( $wgSharedSchema===false) if(! $wgCookiePrefix) $wgCookiePrefix
if( $wgMetaNamespace===false) if( $wgResourceLoaderMaxQueryLength===false) $wgMinUploadChunkSize
$wgGalleryOptions
Default parameters for the "<gallery>" tag.
static instance()
Singleton.
$wgDBpassword
Database user's password.
wfExpandUrl( $url, $defaultProto=PROTO_CURRENT)
Expand a potentially local URL to a fully-qualified URL.
$wgDebugToolbar
Display the new debugging toolbar.
$wgThumbnailScriptPath
Give a path here to use thumb.php for thumbnail generation on client request, instead of generating t...
$wgRepositoryBaseUrl
Shortcut for the 'descBaseUrl' setting of $wgForeignFileRepos.
bool string $wgSharedUploadDBname
Shortcut for the ForeignDBRepo 'dbName' setting in $wgForeignFileRepos.
wfParseUrl( $url)
parse_url() work-alike, but non-broken.
bool $wgCacheSharedUploads
Shortcut for the ForeignDBRepo 'hasSharedCache' setting in $wgForeignFileRepos.
$wgLocalFileRepo
File repository structures.
$wgSecureLogin
This is to let user authenticate using https when they come from http.
$wgDBmwschema
Mediawiki schema; this should be alphanumeric and not contain spaces nor hyphens. ...
$wgMetaNamespace
Name of the project namespace.
static getInstance( $id)
Get a cached instance of the specified type of cache object.
$wgDBserver
Database host name or IP address.
static getLocalClusterInstance()
Get the main cluster-local cache object.
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
if( $wgUseFileCache|| $wgUseSquid) $wgHtml5
$wgDBuser
Database username.
$wgMainWANCache
Main Wide-Area-Network cache type.
if(! $wgEmergencyContact) if(! $wgPasswordSender) if(! $wgNoReplyAddress) if( $wgSecureLogin &&substr( $wgServer, 0, 2) !=='//') $wgVirtualRestConfig['global']['domain']
$wgCookieSecure
Whether the "secure" flag should be set on the cookie.
$wgTmpDirectory
The local filesystem path to a temporary directory.
static getMaxUploadSize( $forType=null)
Get the MediaWiki maximum uploaded file size for given type of upload, based on $wgMaxUploadSize.
$wgWANObjectCaches
Advanced WAN object cache configuration.
string $wgSharedUploadDBprefix
Shortcut for the ForeignDBRepo 'tablePrefix' setting in $wgForeignFileRepos.
$wgLogNames
Lists the message key string for each log type.
wfGetMessageCacheStorage()
Get the cache object used by the message cache.
$wgDebugLogFile
Filename for debug logging.
$wgGenerateThumbnailOnParse
Allow thumbnail rendering on page view.
$wgRCMaxAge
Recentchanges items are periodically purged; entries older than this many seconds will go...
$wgEnableEmail
Set to true to enable the e-mail basic features: Password reminders, etc.
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.
$wgDebugDumpSql
Write SQL queries to the debug log.
$wgInvalidateCacheOnLocalSettingsChange
Invalidate various caches when LocalSettings.php changes.
$wgGroupPermissions
Permission keys given to users in each group.
$wgUseSquid
Enable/disable CDN.
$wgExtraLanguageCodes
List of mappings from one language code to another.
Show an error that looks like an HTTP server error.
$wgLanguageCode
Site language code.
string $wgSharedUploadPath
Shortcut for the 'url' setting of $wgForeignFileRepos.
global $wgCommandLineMode
string $wgSharedThumbnailScriptPath
Shortcut for the 'thumbScriptUrl' setting of $wgForeignFileRepos.
foreach([ 'wgArticlePath', 'wgVariantArticlePath'] as $varName) $ps_default2
$wgStylePath
The URL path of the skins directory.
$wgPasswordPolicy
Password policy for the wiki.
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( $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...
wfTempDir()
Tries to get the system directory for temporary files.
static getMain()
Get the RequestContext object associated with the main request.
$wgUseFileCache
This will cache static pages for non-logged-in users to reduce database traffic on public sites...
$wgDeletedDirectory
What directory to place deleted uploads in.
$wgLocalInterwikis
Array for multiple $wgLocalInterwiki values, in case there are several interwiki prefixes that point ...
wfDebug( $text, $dest='all', array $context=[])
Sends a line to the debug log if enabled or, optionally, to a comment in output.
bool $wgUseSharedUploads
Shortcut for adding an entry to $wgForeignFileRepos.
$wgEnotifRevealEditorAddress
if(is_array( $wgExtraNamespaces)) if(count( $wgDummyLanguageCodes) !==0) $wgDummyLanguageCodes
$wgUsePathInfo
Whether to support URLs like index.php/Page_title These often break when PHP is set up in CGI mode...
$wgResourceBasePath
The default 'remoteBasePath' value for instances of ResourceLoaderFileModule.
$wgMaximalPasswordLength
Specifies the maximal length of a user password (T64685).
static newFromKey( $key)
Factory function that is just wrapper for the real constructor.
$wgProfileOnly
Don't put non-profiling info into log file.
$wgSharedDB
Shared database for multiple wikis.
Class to implement stub globals, which are globals that delay loading the their associated module cod...
this hook is for auditing only or null if authentication failed before getting that far or null if we can t even determine that When $user is not null
$wgRightsText
If either $wgRightsUrl or $wgRightsPage is specified then this variable gives the text for the link...
static schedulePingback()
Schedule a deferred callable that will check if a pingback should be sent and (if so) proceed to send...
$wgSessionName
Override to customise the session name.
static detectProtocol()
Detect the protocol from $_SERVER.
$wgLocaltimezone
Fake out the timezone that the server thinks it's in.
static array static array static getDeprecatedCodeMapping()
Returns a mapping of deprecated language codes that were used in previous versions of MediaWiki to up...
$wgRCFilterByAge
Filter $wgRCLinkDays by $wgRCMaxAge to avoid showing links for numbers higher than what will be store...
$wgLockManagers[]
Initialise $wgLockManagers to include basic FS version.
this hook is for auditing only or null if authentication failed before getting that far or null if we can t even determine that When $user is not it can be in the form of< username >< more info > e g for bot passwords intended to be added to log contexts Fields it might only if the login was with a bot password 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
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
$wgLogActionsHandlers
The same as above, but here values are names of classes, not messages.
if(defined( 'MW_SETUP_CALLBACK')) $fname
Customization point after all loading (constants, functions, classes, DefaultSettings, LocalSettings).
foreach( $wgExtensionFunctions as $func) if(!defined( 'MW_NO_SESSION') &&! $wgCommandLineMode) if(! $wgCommandLineMode) $wgFullyInitialised
$wgPasswordSender
Sender email address for e-mail notifications.
Exception class which takes an HTML error message, and does not produce a backtrace.
bool $wgPageLanguageUseDB
Enable page language feature Allows setting page language in database.
string $wgSharedUploadDirectory
Shortcut for the 'directory' setting of $wgForeignFileRepos.
$wgPageCreationLog
Maintain a log of page creations at Special:Log/create?
$wgShellLocale
Locale for LC_ALL, to provide a known environment for locale-sensitive operations.
$wgSessionCacheType
The cache type for storing session data.
$wgUploadPath
The URL path for the images directory.
$wgEmergencyContact
Site admin email address.
$wgNamespaceAliases['Image']
The canonical names of namespaces 6 and 7 are, as of v1.14, "File" and "File_talk".
$wgExtraNamespaces
Additional namespaces.
$wgReadOnlyFile
If this lock file exists (size > 0), the wiki will be forced into read-only mode. ...
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
if( $wgCanonicalServer===false) $serverParts
$wgLocalStylePath
The URL path of the skins directory.
$wgMinimalPasswordLength
Specifies the minimal length of a user password.
static installHandler()
Install handlers with PHP.
static isValidUserName( $name)
Is the input a valid username?
if( $wgSkipSkin) $wgSkipSkins[]
bool $wgHashedSharedUploadDirectory
Shortcut for the 'hashLevels' setting of $wgForeignFileRepos.
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
$wgScriptPath
The path we should point to.
$wgLocalInterwiki
The interwiki prefix of the current wiki, or false if it doesn't have one.
wfDebugLog( $logGroup, $text, $dest='all', array $context=[])
Send a line to a supplementary debug log file, if configured, or main debug log if not...
Stub object for the user language.
$wgExtensionAssetsPath
The URL path of the extensions directory.
wfDeprecated( $function, $version=false, $component=false, $callerOffset=2)
Throws a warning that $function is deprecated.
$wgDBprefix
Table name prefix; this should be alphanumeric and not contain spaces nor hyphens.
$wgAllowHTMLEmail
For parts of the system that have been updated to provide HTML email content, send both text and HTML...
wfMemoryLimit()
Set PHP's memory limit to the larger of php.ini or $wgMemoryLimit.
$wgLogHeaders
Lists the message key string for descriptive text to be shown at the top of each log type...
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
$wgCanonicalServer
Canonical URL of the server, to use in IRC feeds and notification e-mails.
$wgHashedUploadDirectory
Set this to false if you do not want MediaWiki to divide your images directory into many subdirectori...
$wgLogo
The URL path of the wiki logo.
$wgLocalTZoffset
Set an offset from UTC in minutes to use for the default timezone setting for anonymous users and new...
Allows to change the fields on the form that will be generated $name
static getMaxPhpUploadSize()
Get the PHP maximum uploaded file size, based on ini settings.
if(! $wgDBerrorLogTZ) $wgRequest
$wgServer
URL of the server.
$wgGitInfoCacheDirectory
Directory where GitInfo will look for pre-computed cache files.
if( $wgServerName !==false) $wgServerName
$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...
$wgRCLinkDays
List of Days options to list in the Special:Recentchanges and Special:Recentchangeslinked pages...
$wgLogTypes
The logging system has two levels: an event type, which describes the general category and can be vie...
wfIniGetBool( $setting)
Safety wrapper around ini_get() for boolean settings.
$wgResourceLoaderMaxQueryLength
If set to a positive number, ResourceLoader will not generate URLs whose query string is more than th...
string $wgPHPSessionHandling
Whether to use PHP session handling ($_SESSION and session_*() functions)
$wgDebugPrintHttpHeaders
Print HTTP headers for every request in the debug information.
$wgRightsIcon
Override for copyright metadata.
$wgFileBlacklist
Files with these extensions will never be allowed as uploads.
$wgLoadScript
The URL path to load.php.
$wgNoReplyAddress
Reply-To address for e-mail notifications.
$wgCacheEpoch
Set this to current time to invalidate all prior cached pages.
$wgFileCacheDirectory
Directory where the cached page will be saved.
static init()
Enabled the debugger and load resource module.
bool $wgFetchCommonsDescriptions
Shortcut for the 'fetchDescription' setting of $wgForeignFileRepos.
wfShorthandToInteger( $string='', $default=-1)
Converts shorthand byte notation to integer form.
if(is_array( $wgExtraNamespaces)) if(count( $wgDummyLanguageCodes) !==0) foreach(LanguageCode::getNonstandardLanguageCodeMapping() as $code=> $bcp47) $wgContLanguageCode
$wgUploadDirectory
The filesystem path of the images directory.
static run( $event, array $args=[], $deprecatedVersion=null)
Call hook functions defined in Hooks::register and $wgHooks.