Go to the documentation of this file.
32 if ( !defined(
'MEDIAWIKI' ) ) {
46 echo
"Error, Setup.php must be included from the file scope, after DefaultSettings.php\n";
50 mb_internal_encoding(
'UTF-8' );
76 if ( $wgResourceBasePath ===
null ) {
91 $wgLogo =
"$wgResourceBasePath/resources/assets/wiki.png";
100 if ( $wgReadOnlyFile ===
false ) {
101 $wgReadOnlyFile =
"{$wgUploadDirectory}/lock_yBgMBwiR";
119 if ( $wgRightsIcon ) {
120 $wgRightsIcon = str_replace(
121 "{$wgStylePath}/common/images/",
122 "{$wgResourceBasePath}/resources/assets/licenses/",
127 if ( isset( $wgFooterIcons[
'copyright'][
'copyright'] )
128 && $wgFooterIcons[
'copyright'][
'copyright'] === []
130 if ( $wgRightsIcon || $wgRightsText ) {
131 $wgFooterIcons[
'copyright'][
'copyright'] = [
132 'url' => $wgRightsUrl,
133 'src' => $wgRightsIcon,
134 'alt' => $wgRightsText,
139 if ( isset( $wgFooterIcons[
'poweredby'] )
140 && isset( $wgFooterIcons[
'poweredby'][
'mediawiki'] )
141 && $wgFooterIcons[
'poweredby'][
'mediawiki'][
'src'] ===
null
143 $wgFooterIcons[
'poweredby'][
'mediawiki'][
'src'] =
144 "$wgResourceBasePath/resources/assets/poweredby_mediawiki_88x31.png";
145 $wgFooterIcons[
'poweredby'][
'mediawiki'][
'srcset'] =
146 "$wgResourceBasePath/resources/assets/poweredby_mediawiki_132x47.png 1.5x, " .
147 "$wgResourceBasePath/resources/assets/poweredby_mediawiki_176x62.png 2x";
171 'name' =>
'fsLockManager',
172 'class' =>
'FSLockManager',
173 'lockDirectory' =>
"{$wgUploadDirectory}/lockdir",
176 'name' =>
'nullLockManager',
177 'class' =>
'NullLockManager',
185 'class' =>
'LocalRepo',
189 'scriptExtension' =>
'.php',
204 'class' =>
'ForeignDBRepo',
224 'class' =>
'FileRepo',
238 'class' =>
'ForeignAPIRepo',
239 'name' =>
'wikimediacommons',
240 'apibase' =>
'https://commons.wikimedia.org/w/api.php',
241 'url' =>
'https://upload.wikimedia.org/wikipedia/commons',
242 'thumbUrl' =>
'https://upload.wikimedia.org/wikipedia/commons/thumb',
244 'transformVia404' =>
true,
245 'fetchDescription' =>
true,
246 'descriptionCacheExpiry' => 43200,
247 'apiThumbCacheExpiry' => 0,
258 if ( !isset( $repo[
'directory'] ) && $repo[
'class'] ===
'ForeignAPIRepo' ) {
261 if ( !isset( $repo[
'backend'] ) ) {
262 $repo[
'backend'] = $repo[
'name'] .
'-backend';
268 if ( $wgRCFilterByAge ) {
272 sort( $wgRCLinkDays );
275 for ( $i = 0; $i <
count( $wgRCLinkDays ); $i++ ) {
278 $wgRCLinkDays = array_slice( $wgRCLinkDays, 0, $i + 1,
false );
301 if ( $wgLocalInterwiki ) {
302 array_unshift( $wgLocalInterwikis, $wgLocalInterwiki );
344 unset( $wgGroupPermissions[
'user'][
'sendemail'] );
350 if ( $wgMetaNamespace ===
false ) {
351 $wgMetaNamespace = str_replace(
' ',
'_',
$wgSitename );
355 if ( $wgResourceLoaderMaxQueryLength ===
false ) {
356 $suhosinMaxValueLength = (int)ini_get(
'suhosin.get.max_value_length' );
357 if ( $suhosinMaxValueLength > 0 && $suhosinMaxValueLength < 2000 ) {
358 $wgResourceLoaderMaxQueryLength = $suhosinMaxValueLength;
360 $wgResourceLoaderMaxQueryLength = 2000;
362 unset( $suhosinMaxValueLength );
369 UploadBase::getMaxUploadSize(
'file' ),
370 UploadBase::getMaxPhpUploadSize(),
372 ini_get(
'post_max_size' ) ?: ini_get(
'hhvm.server.max_post_size' ),
374 ) ?: PHP_INT_MAX ) - 1024
402 if ( is_array( $wgExtraNamespaces ) ) {
419 $wgDebugToolbar =
false;
432 MediaWiki\suppressWarnings();
434 MediaWiki\restoreWarnings();
437 if ( $wgNewUserLog ) {
439 $wgLogTypes[] =
'newusers';
440 $wgLogNames[
'newusers'] =
'newuserlogpage';
441 $wgLogHeaders[
'newusers'] =
'newuserlogpagetext';
442 $wgLogActionsHandlers[
'newusers/newusers'] =
'NewUsersLogFormatter';
443 $wgLogActionsHandlers[
'newusers/create'] =
'NewUsersLogFormatter';
444 $wgLogActionsHandlers[
'newusers/create2'] =
'NewUsersLogFormatter';
445 $wgLogActionsHandlers[
'newusers/byemail'] =
'NewUsersLogFormatter';
446 $wgLogActionsHandlers[
'newusers/autocreate'] =
'NewUsersLogFormatter';
449 if ( $wgPageLanguageUseDB ) {
450 $wgLogTypes[] =
'pagelang';
451 $wgLogActionsHandlers[
'pagelang/pagelang'] =
'PageLangLogFormatter';
454 if ( $wgCookieSecure ===
'detect' ) {
458 if ( $wgProfileOnly ) {
459 $wgDebugLogGroups[
'profileoutput'] = $wgDebugLogFile;
460 $wgDebugLogFile =
'';
464 if ( $wgMinimalPasswordLength !==
false ) {
465 $wgPasswordPolicy[
'policies'][
'default'][
'MinimalPasswordLength'] = $wgMinimalPasswordLength;
468 if ( $wgMaximalPasswordLength !==
false ) {
469 $wgPasswordPolicy[
'policies'][
'default'][
'MaximalPasswordLength'] = $wgMaximalPasswordLength;
474 wfDeprecated(
'$wgSessionsInObjectCache = false',
'1.27' );
481 "Session data will be stored in \"$cacheType\" cache with " .
482 "expiry $wgObjectCacheSessionExpiry seconds"
493 if ( defined(
'MW_NO_SESSION' ) ) {
510 MediaWikiServices::resetGlobalInstance(
new GlobalVarConfig(),
'quick' );
514 MediaWikiServices::getInstance()->getDBLoadBalancer()->setTableAliases(
528 define(
'MW_SERVICE_BOOTSTRAP_COMPLETE', 1 );
532 require_once
"$IP/includes/compat/normal/UtfNormalUtil.php";
537 foreach ( [
'wgArticlePath',
'wgVariantArticlePath' ]
as $varName ) {
538 if ( $$varName && !preg_match(
'/^(https?:\/\/|\/)/', $$varName ) ) {
540 "If you use a relative URL for \$$varName, it must start " .
541 'with a slash (<code>/</code>).<br><br>See ' .
542 "<a href=\"https://www.mediawiki.org/wiki/Manual:\$$varName\">" .
543 "https://www.mediawiki.org/wiki/Manual:\$$varName</a>."
559 wfWarn(
'$wgServerName should be derived from $wgCanonicalServer, '
560 .
'not customized. Overwriting $wgServerName.' );
578 if ( $wgSecureLogin && substr(
$wgServer, 0, 2 ) !==
'//' ) {
579 $wgSecureLogin =
false;
580 wfWarn(
'Secure login was enabled on a server that only supports '
581 .
'HTTP or HTTPS. Disabling secure login.' );
593 if ( !isset( $wgDisableCounters ) ) {
594 $wgDisableCounters =
true;
602 'class' =>
'WANObjectCache',
604 'channels' => [
'purge' =>
'wancache-main-default-purge' ]
620 if ( is_null( $wgLocaltimezone ) ) {
621 MediaWiki\suppressWarnings();
622 $wgLocaltimezone = date_default_timezone_get();
623 MediaWiki\restoreWarnings();
626 date_default_timezone_set( $wgLocaltimezone );
627 if ( is_null( $wgLocalTZoffset ) ) {
628 $wgLocalTZoffset = date(
'Z' ) / 60;
641 MediaWikiServices::getInstance()->getDBLoadBalancerFactory()->setRequestInfo( [
643 'UserAgent' =>
$wgRequest->getHeader(
'User-Agent' ),
644 'ChronologyProtection' =>
$wgRequest->getHeader(
'ChronologyProtection' )
649 wfDebug(
"\n\nStart command line script $self\n" );
651 $debug =
"\n\nStart request {$wgRequest->getMethod()} {$wgRequest->getRequestURL()}\n";
653 if ( $wgDebugPrintHttpHeaders ) {
654 $debug .=
"HTTP HEADERS:\n";
657 $debug .=
"$name: $value\n";
671 'cluster: ' . get_class(
$wgMemc ) .
695 if ( !is_object( $wgAuth ) ) {
697 Hooks::run(
'AuthPluginSetup', [ &$wgAuth ] );
699 if ( $wgAuth && !$wgAuth instanceof
MediaWiki\Auth\AuthManagerAuthPlugin ) {
701 new MediaWiki\Auth\TemporaryPasswordPrimaryAuthenticationProvider( [
702 'authoritative' =>
false,
704 new MediaWiki\Auth\AuthPluginPrimaryAuthenticationProvider( $wgAuth ),
705 new MediaWiki\Auth\LocalPasswordPrimaryAuthenticationProvider( [
706 'authoritative' =>
true,
708 ],
'$wgAuth is ' . get_class( $wgAuth ) );
721 session_name( $wgSessionName ? $wgSessionName :
$wgCookiePrefix .
'_session' );
726 if ( !defined(
'MW_NO_SESSION_HANDLER' ) ) {
728 MediaWiki\Session\SessionManager::singleton()
735 }
catch ( OverflowException $ex ) {
736 if ( isset( $ex->sessionInfos ) &&
count( $ex->sessionInfos ) >= 2 ) {
740 foreach ( $ex->sessionInfos
as $info ) {
741 $list[] = $info->getProvider()->describe(
$wgContLang );
745 Message::newFromKey(
'sessionmanager-tie', $list )->inLanguage(
$wgContLang )->
plain()
753 if ( $session->isPersistent() ) {
758 if (
MediaWiki\Session\PHPSessionHandler::isEnabled() &&
759 ( $session->isPersistent() || $session->shouldRememberUser() )
762 session_id( $session->getId() );
763 MediaWiki\quietCall(
'session_start' );
770 if ( !defined(
'MW_NO_SESSION_HANDLER' ) ) {
772 MediaWiki\Session\SessionManager::singleton()
797 return MediaWikiServices::getInstance()->getParser();
812 foreach ( $wgExtensionFunctions
as $func ) {
814 if ( is_object( $func ) && $func instanceof Closure ) {
815 $profName =
$fname .
'-extensions-closure';
816 } elseif ( is_array( $func ) ) {
817 if ( is_object( $func[0] ) ) {
818 $profName =
$fname .
'-extensions-' . get_class( $func[0] ) .
'::' . $func[1];
820 $profName =
$fname .
'-extensions-' . implode(
'::', $func );
823 $profName =
$fname .
'-extensions-' . strval( $func );
827 call_user_func( $func );
839 MediaWiki\Auth\AuthManager::AUTOCREATE_SOURCE_SESSION,
844 'event' =>
'autocreate',
849 unset( $sessionUser );
$wgCanonicalNamespaceNames
Definitions of the NS_ constants are in Defines.php.
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
$wgDBserver
Database host name or IP address.
$wgFileBlacklist
Files with these extensions will never be allowed as uploads.
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
$wgInvalidateCacheOnLocalSettingsChange
Invalidate various caches when LocalSettings.php changes.
$wgTmpDirectory
The local filesystem path to a temporary directory.
static instance()
Singleton.
Class to implement stub globals, which are globals that delay loading the their associated module cod...
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.
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
$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.
if(!defined( 'MEDIAWIKI')) $fname
This file is not a valid entry point, perform no further processing unless MEDIAWIKI is defined.
$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.
$wgHashedSharedUploadDirectory
Set the following to false especially if you have a set of files that need to be accessible by all wi...
Allows to change the fields on the form that will be generated $name
$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.
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.
$wgUseFileCache
This will cache static pages for non-logged-in users to reduce database traffic on public sites.
global $wgCommandLineMode
$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?
$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.
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.
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
$wgNamespaceAliases['Image']
The canonical names of namespaces 6 and 7 are, as of v1.14, "File" and "File_talk".
$wgDeletedDirectory
What directory to place deleted uploads in.
Stub object for the user language.
$wgServer
URL of the server.
$wgLanguageCode
Site language code.
$wgSitename
Name of the site.
static init()
Enabled the debugger and load resource module.
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.
wfGetParserCacheStorage()
Get the cache object used by the parser cache.
$wgAllowHTMLEmail
For parts of the system that have been updated to provide HTML email content, send both text and HTML...
static getMain()
Static methods.
wfIniGetBool( $setting)
Safety wrapper around ini_get() for boolean settings.
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.
$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.
if( $wgSkipSkin) $wgSkipSkins[]
$wgThumbnailScriptPath
Give a path here to use thumb.php for thumbnail generation on client request, instead of generating t...
Exception class which takes an HTML error message, and does not produce a backtrace.
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
$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.
$wgDBuser
Database username.
$wgDBerrorLogTZ
Timezone to use in the error 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...
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 run( $event, array $args=[], $deprecatedVersion=null)
Call hook functions defined in Hooks::register and $wgHooks.
$wgLocalStylePath
The URL path of the skins directory.
$wgMainStash
Main object stash type.
$wgMainWANCache
Main Wide-Area-Network cache type.
wfExpandUrl( $url, $defaultProto=PROTO_CURRENT)
Expand a potentially local URL to a fully-qualified URL.
$wgUsePathInfo
Whether to support URLs like index.php/Page_title These often break when PHP is set up in CGI mode.
$wgSharedThumbnailScriptPath