31if ( !defined(
'MEDIAWIKI' ) ) {
43 echo
"Error, Setup.php must be included from the file scope, after DefaultSettings.php\n";
47mb_internal_encoding(
'UTF-8' );
88 $wgLogo =
"$wgResourceBasePath/resources/assets/wiki.png";
118 "{$wgStylePath}/common/images/",
119 "{$wgResourceBasePath}/resources/assets/licenses/",
141 "$wgResourceBasePath/resources/assets/poweredby_mediawiki_88x31.png";
143 "$wgResourceBasePath/resources/assets/poweredby_mediawiki_132x47.png 1.5x, " .
144 "$wgResourceBasePath/resources/assets/poweredby_mediawiki_176x62.png 2x";
168 'name' =>
'fsLockManager',
169 'class' =>
'FSLockManager',
170 'lockDirectory' =>
"{$wgUploadDirectory}/lockdir",
173 'name' =>
'nullLockManager',
174 'class' =>
'NullLockManager',
182 'class' =>
'LocalRepo',
186 'scriptExtension' =>
'.php',
201 'class' =>
'ForeignDBRepo',
221 'class' =>
'FileRepo',
235 'class' =>
'ForeignAPIRepo',
236 'name' =>
'wikimediacommons',
237 'apibase' =>
'https://commons.wikimedia.org/w/api.php',
238 'url' =>
'https://upload.wikimedia.org/wikipedia/commons',
239 'thumbUrl' =>
'https://upload.wikimedia.org/wikipedia/commons/thumb',
241 'transformVia404' =>
true,
242 'fetchDescription' =>
true,
243 'descriptionCacheExpiry' => 43200,
244 'apiThumbCacheExpiry' => 0,
255 if ( !isset( $repo[
'directory'] ) && $repo[
'class'] ===
'ForeignAPIRepo' ) {
258 if ( !isset( $repo[
'backend'] ) ) {
259 $repo[
'backend'] = $repo[
'name'] .
'-backend';
300 $factory->register( $name, $skin,
function () use ( $name, $skin ) {
301 $class =
"Skin$skin";
302 return new $class( $name );
306 $factory->register(
'fallback',
'Fallback',
function () {
310 $factory->register(
'apioutput',
'ApiOutput',
function () {
372 $suhosinMaxValueLength = (int)ini_get(
'suhosin.get.max_value_length' );
373 if ( $suhosinMaxValueLength > 0 && $suhosinMaxValueLength < 2000 ) {
378 unset( $suhosinMaxValueLength );
388 ini_get(
'post_max_size' ) ?: ini_get(
'hhvm.server.max_post_size' ),
390 ) ?: PHP_INT_MAX ) - 1024
442 MediaWiki\suppressWarnings();
444 MediaWiki\restoreWarnings();
484 wfDeprecated(
'$wgSessionsInObjectCache = false',
'1.27' );
491 "Session data will be stored in \"$cacheType\" cache with " .
492 "expiry $wgObjectCacheSessionExpiry seconds"
503if ( defined(
'MW_NO_SESSION' ) ) {
518if ( !class_exists(
'AutoLoader' ) ) {
519 require_once
"$IP/includes/AutoLoader.php";
524 header_register_callback(
function () {
526 foreach ( headers_list() as $header ) {
527 list( $name,
$value ) = explode(
':', $header, 2 );
528 $headers[strtolower( trim( $name ) )][] = trim(
$value );
531 if ( isset( $headers[
'set-cookie'] ) ) {
532 $cacheControl = isset( $headers[
'cache-control'] )
533 ? implode(
', ', $headers[
'cache-control'] )
536 if ( !preg_match(
'/(?:^|,)\s*(?:private|no-cache|no-store)\s*(?:$|,)/i', $cacheControl ) ) {
537 header(
'Expires: Thu, 01 Jan 1970 00:00:00 GMT' );
538 header(
'Cache-Control: private, max-age=0, s-maxage=0' );
539 MediaWiki\Logger\LoggerFactory::getInstance(
'cache-cookies' )->warning(
540 'Cookies set on {url} with Cache-Control "{cache-control}"', [
541 'url' => WebRequest::getGlobalRequestURL(),
542 'cookies' => $headers[
'set-cookie'],
543 'cache-control' => $cacheControl ?:
'<not set>',
553require_once
"$IP/includes/compat/normal/UtfNormalUtil.php";
558foreach ( [
'wgArticlePath',
'wgVariantArticlePath' ] as $varName ) {
559 if ( $$varName && !preg_match(
'/^(https?:\/\/|\/)/', $$varName ) ) {
561 "If you use a relative URL for \$$varName, it must start " .
562 'with a slash (<code>/</code>).<br><br>See ' .
563 "<a href=\"https://www.mediawiki.org/wiki/Manual:\$$varName\">" .
564 "https://www.mediawiki.org/wiki/Manual:\$$varName</a>."
580 wfWarn(
'$wgServerName should be derived from $wgCanonicalServer, '
581 .
'not customized. Overwriting $wgServerName.' );
601 wfWarn(
'Secure login was enabled on a server that only supports '
602 .
'HTTP or HTTPS. Disabling secure login.' );
614if ( !isset( $wgDisableCounters ) ) {
615 $wgDisableCounters =
true;
623 'class' =>
'WANObjectCache',
625 'channels' => [
'purge' =>
'wancache-main-default-purge' ]
642 MediaWiki\suppressWarnings();
644 MediaWiki\restoreWarnings();
661 wfDebug(
"\n\nStart command line script $self\n" );
663 $debug =
"\n\nStart request {$wgRequest->getMethod()} {$wgRequest->getRequestURL()}\n";
666 $debug .=
"HTTP HEADERS:\n";
669 $debug .=
"$name: $value\n";
683 'cluster: ' . get_class(
$wgMemc ) .
694Hooks::run(
'SetupAfterCache' );
710 Hooks::run(
'AuthPluginSetup', [ &
$wgAuth ] );
713 MediaWiki\Auth\AuthManager::singleton()->forcePrimaryAuthenticationProviders( [
714 new MediaWiki\Auth\TemporaryPasswordPrimaryAuthenticationProvider( [
715 'authoritative' =>
false,
718 new MediaWiki\Auth\LocalPasswordPrimaryAuthenticationProvider( [
719 'authoritative' =>
true,
721 ],
'$wgAuth is ' . get_class(
$wgAuth ) );
739 if ( !defined(
'MW_NO_SESSION_HANDLER' ) ) {
740 MediaWiki\Session\PHPSessionHandler::install(
741 MediaWiki\Session\SessionManager::singleton()
747 $session = MediaWiki\Session\SessionManager::getGlobalSession();
748 }
catch ( OverflowException $ex ) {
749 if ( isset( $ex->sessionInfos ) && count( $ex->sessionInfos ) >= 2 ) {
753 foreach ( $ex->sessionInfos
as $info ) {
754 $list[] = $info->getProvider()->describe(
$wgContLang );
758 Message::newFromKey(
'sessionmanager-tie', $list )->inLanguage(
$wgContLang )->plain()
766 if ( $session->isPersistent() ) {
771 if (
MediaWiki\Session\PHPSessionHandler::isEnabled() &&
772 ( $session->isPersistent() || $session->shouldRememberUser() )
775 session_id( $session->getId() );
776 MediaWiki\quietCall(
'session_start' );
783 if ( !defined(
'MW_NO_SESSION_HANDLER' ) ) {
784 MediaWiki\Session\PHPSessionHandler::install(
785 MediaWiki\Session\SessionManager::singleton()
825 if ( is_object( $func ) && $func instanceof Closure ) {
826 $profName =
$fname .
'-extensions-closure';
827 } elseif ( is_array( $func ) ) {
828 if ( is_object( $func[0] ) ) {
829 $profName =
$fname .
'-extensions-' . get_class( $func[0] ) .
'::' . $func[1];
831 $profName =
$fname .
'-extensions-' . implode(
'::', $func );
834 $profName =
$fname .
'-extensions-' . strval( $func );
838 call_user_func( $func );
845 $sessionUser = MediaWiki\Session\SessionManager::getGlobalSession()->getUser();
846 if ( $sessionUser->getId() === 0 && User::isValidUserName( $sessionUser->getName() ) ) {
848 $res = MediaWiki\Auth\AuthManager::singleton()->autoCreateUser(
850 MediaWiki\Auth\AuthManager::AUTOCREATE_SOURCE_SESSION,
854 \MediaWiki\Logger\LoggerFactory::getInstance(
'authmanager' )->info(
'Autocreation attempt', [
855 'event' =>
'autocreate',
860 unset( $sessionUser );
863wfDebug(
"Fully initialised\n" );
$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.
$wgUsePathInfo
Whether to support URLs like index.php/Page_title These often break when PHP is set up in CGI mode.
$wgLanguageCode
Site language code.
$wgParserCacheType
The cache type for storing article HTML.
$wgSharedThumbnailScriptPath
$wgEmergencyContact
Site admin email address.
$wgDBprefix
Table name prefix.
$wgDBuser
Database username.
string $wgPHPSessionHandling
Whether to use PHP session handling ($_SESSION and session_*() functions)
$wgScript
The URL path to index.php.
$wgUseInstantCommons
Use Commons as a remote file repository.
$wgCacheDirectory
Directory for caching data in the local filesystem.
$wgHashedSharedUploadDirectory
Set the following to false especially if you have a set of files that need to be accessible by all wi...
$wgGenerateThumbnailOnParse
Allow thumbnail rendering on page view.
$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.
$wgLocalInterwiki
The interwiki prefix of the current wiki, or false if it doesn't have one.
$wgPasswordPolicy
Password policy for local wiki users.
$wgLogNames
Lists the message key string for each log type.
$wgSharedUploadPath
Full path on the web server where shared uploads can be found.
$wgHashedUploadDirectory
Set this to false if you do not want MediaWiki to divide your images directory into many subdirectori...
$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.
$wgDBmwschema
Mediawiki schema.
$wgNoReplyAddress
Reply-To address for e-mail notifications.
$wgValidSkinNames
List of valid skin names.
$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.
$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.
$wgResourceLoaderMaxQueryLength
If set to a positive number, ResourceLoader will not generate URLs whose query string is more than th...
$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.
$wgResourceBasePath
The default 'remoteBasePath' value for instances of ResourceLoaderFileModule.
$wgProfileOnly
Don't put non-profiling info into log file.
$wgFooterIcons
Abstract list of footer icons for skins in place of old copyrightico and poweredbyico code You can ad...
$wgUploadPath
The URL path for the images directory.
$wgCacheSharedUploads
Cache shared metadata in memcached.
$wgEnableParserCache
Kept for extension compatibility; see $wgParserCacheType.
$wgFileBlacklist
Files with these extensions will never be allowed as uploads.
$wgEnableEmail
Set to true to enable the e-mail basic features: Password reminders, etc.
$wgExtensionFunctions
A list of callback functions which are called once MediaWiki is fully initialised.
$wgUseSquid
Enable/disable CDN.
$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.
$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.
$wgGroupPermissions
Permission keys given to users in each group.
$wgLocalInterwikis
Array for multiple $wgLocalInterwiki values, in case there are several interwiki prefixes that point ...
$wgVersion
MediaWiki version number.
$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.
$wgAuth $wgAuth
Authentication plugin.
$wgAllowHTMLEmail
For parts of the system that have been updated to provide HTML email content, send both text and HTML...
$wgSharedUploadDBname
DB name with metadata about shared directory.
$wgMainStash
Main object stash type.
$wgParserConf
Parser configuration.
$wgExtensionAssetsPath
The URL path of the extensions directory.
$wgDebugToolbar
Display the new debugging toolbar.
$wgRepositoryBaseUrl
Base URL for a repository wiki.
$wgLogHeaders
Lists the message key string for descriptive text to be shown at the top of each log type.
$wgDebugLogGroups
Map of string log group names to log destinations.
$wgSharedDB
Shared database for multiple wikis.
$wgSessionCacheType
The cache type for storing session data.
$wgSharedUploadDBprefix
Optional table prefix used in database.
$wgDebugDumpSql
Write SQL queries to the debug log.
$wgFetchCommonsDescriptions
Fetch commons image description pages and display them on the local wiki?
$wgDBserver
Database host name or IP address.
$wgLoadScript
The URL path to load.php.
$wgCookieSecure
Whether the "secure" flag should be set on the cookie.
$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.
$wgRCFilterByAge
Filter $wgRCLinkDays by $wgRCMaxAge to avoid showing links for numbers higher than what will be store...
$wgMinimalPasswordLength
Specifies the minimal length of a user password.
$wgMetaNamespace
Name of the project namespace.
$wgLogo
The URL path of the wiki logo.
$wgUseFileCache
This will cache static pages for non-logged-in users to reduce database traffic on public sites.
$wgDebugLogFile
Filename for debug logging.
$wgPasswordSender
Sender email address for e-mail notifications.
$wgLogActionsHandlers
The same as above, but here values are names of classes, not messages.
$wgLocalTZoffset
Set an offset from UTC in minutes to use for the default timezone setting for anonymous users and new...
$wgSessionsInMemcached
Deprecated alias for $wgSessionsInObjectCache.
$wgMainWANCache
Main Wide-Area-Network cache type.
$wgDebugPrintHttpHeaders
Print HTTP headers for every request in the debug information.
$wgUseSharedUploads
If you operate multiple wikis, you can define a shared upload path here.
$wgDBpassword
Database user's password.
$wgRCLinkDays
List of Days options to list in the Special:Recentchanges and Special:Recentchangeslinked pages.
$wgNewUserLog
Maintain a log of newusers at Log/newusers?
wfDebug( $text, $dest='all', array $context=[])
Sends a line to the debug log if enabled or, optionally, to a comment in output.
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.
wfIniGetBool( $setting)
Safety wrapper around ini_get() for boolean settings.
wfGetMessageCacheStorage()
Get the cache object used by the message cache.
wfExpandUrl( $url, $defaultProto=PROTO_CURRENT)
Expand a potentially local URL to a fully-qualified URL.
wfGetMainCache()
Get the main cache object.
wfGetParserCacheStorage()
Get the cache object used by the parser cache.
wfDebugLog( $logGroup, $text, $dest='all', array $context=[])
Send a line to a supplementary debug log file, if configured, or main debug log if not.
wfShorthandToInteger( $string='', $default=-1)
Converts shorthand byte notation to integer form.
wfMemoryLimit()
Set PHP's memory limit to the larger of php.ini or $wgMemoryLimit.
wfDeprecated( $function, $version=false, $component=false, $callerOffset=2)
Throws a warning that $function is deprecated.
if($wgInvalidateCacheOnLocalSettingsChange) if( $wgNewUserLog) if($wgPageLanguageUseDB) if( $wgCookieSecure==='detect') if($wgProfileOnly) if( $wgMinimalPasswordLength !==false) if($wgMaximalPasswordLength !==false) if(! $wgSessionsInObjectCache &&! $wgSessionsInMemcached) $wgSessionsInObjectCache
if( $wgRCFilterByAge) $wgDefaultUserOptions['rcdays']
if(!defined( 'MEDIAWIKI')) $fname
This file is not a valid entry point, perform no further processing unless MEDIAWIKI is defined.
if( $wgUseFileCache|| $wgUseSquid) $wgHtml5
$wgCanonicalNamespaceNames
Definitions of the NS_ constants are in Defines.php.
global $wgCommandLineMode
if(!is_object($wgAuth)) if( $wgAuth &&! $wgAuth instanceof MediaWiki\Auth\AuthManagerAuthPlugin) $ps_session
$wgEnotifRevealEditorAddress
$wgUsersNotifiedOnAllChanges
if($wgLocalInterwiki) if( $wgSharedPrefix===false) if($wgSharedSchema===false) if(! $wgCookiePrefix) $wgCookiePrefix
if( $wgServerName !==false) $wgServerName
if(is_array( $wgExtraNamespaces)) $wgContLanguageCode
if(is_null($wgLocalTZoffset)) if(! $wgDBerrorLogTZ) $wgRequest
$wgLockManagers[]
Initialise $wgLockManagers to include basic FS version.
$wgNamespaceAliases['Image']
The canonical names of namespaces 6 and 7 are, as of v1.14, "File" and "File_talk".
if(! $wgEmergencyContact) if(! $wgPasswordSender) if(! $wgNoReplyAddress) if( $wgSecureLogin &&substr( $wgServer, 0, 2) !=='//') $wgVirtualRestConfig['global']['domain']
if( $wgCanonicalServer===false) $serverParts
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($wgMetaNamespace===false) if( $wgResourceLoaderMaxQueryLength===false) $wgMinUploadChunkSize
Exception class which takes an HTML error message, and does not produce a backtrace.
Show an error that looks like an HTTP server error.
static installHandler()
Install handlers with PHP.
static getInstance( $id)
Get a cached instance of the specified type of cache object.
static instance()
Singleton.
static getMain()
Static methods.
SkinTemplate class for API output.
static getDefaultInstance()
SkinTemplate class for the fallback skin.
Class to implement stub globals, which are globals that delay loading the their associated module cod...
Stub object for the user language.
static getMaxUploadSize( $forType=null)
Get the MediaWiki maximum uploaded file size for given type of upload, based on $wgMaxUploadSize.
static getMaxPhpUploadSize()
Get the PHP maximum uploaded file size, based on ini settings.
static detectProtocol()
Detect the protocol from $_SERVER.
deferred txt A few of the database updates required by various functions here can be deferred until after the result page is displayed to the user For updating the view updating the linked to tables after a etc PHP does not yet have any way to tell the server to actually return and disconnect while still running these but it might have such a feature in the future We handle these by creating a deferred update object and putting those objects on a global list
when a variable name is used in a it is silently declared as a new local masking the global
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
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
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
CACHE_MEMCACHED $wgMainCacheType