34if ( !defined(
'MEDIAWIKI' ) ) {
41 echo
"Error, Setup.php must be included from the file scope.\n";
51if ( ini_get(
'mbstring.func_overload' ) ) {
52 die(
'MediaWiki does not support installations where mbstring.func_overload is non-zero.' );
57if ( !defined(
'MW_ENTRY_POINT' ) ) {
63 define(
'MW_ENTRY_POINT',
'unknown' );
67require_once
"$IP/includes/AutoLoader.php";
70require_once
"$IP/includes/Defines.php";
73require_once
"$IP/includes/DefaultSettings.php";
76require_once
"$IP/includes/GlobalFunctions.php";
79if ( is_readable(
"$IP/vendor/autoload.php" ) ) {
80 require_once
"$IP/vendor/autoload.php";
81} elseif ( file_exists(
"$IP/vendor/autoload.php" ) ) {
82 die(
"$IP/vendor/autoload.php exists but is not readable" );
89if ( !interface_exists(
'Psr\Log\LoggerInterface' ) ) {
91 'MediaWiki requires the <a href="https://github.com/php-fig/log">PSR-3 logging ' .
92 "library</a> to be present. This library is not embedded directly in MediaWiki's " .
93 "git repository and must be installed separately by the end user.\n\n" .
94 'Please see <a href="https://www.mediawiki.org/wiki/Download_from_Git' .
95 '#Fetch_external_libraries">mediawiki.org</a> for help on installing ' .
96 'the required components.'
99 trigger_error( $message, E_USER_ERROR );
108MediaWiki\HeaderCallback::register();
112mb_internal_encoding(
'UTF-8' );
118if ( defined(
'MW_CONFIG_CALLBACK' ) ) {
121 if ( !defined(
'MW_CONFIG_FILE' ) ) {
122 define(
'MW_CONFIG_FILE',
"$IP/LocalSettings.php" );
124 require_once MW_CONFIG_FILE;
134if ( defined(
'MW_SETUP_CALLBACK' ) ) {
135 call_user_func( MW_SETUP_CALLBACK );
148putenv(
"LC_ALL=$wgShellLocale" );
185 $wgLogo =
"$wgResourceBasePath/resources/assets/wiki.png";
211 "{$wgStylePath}/common/images/",
212 "{$wgResourceBasePath}/resources/assets/licenses/",
234 "$wgResourceBasePath/resources/assets/poweredby_mediawiki_88x31.png";
236 "$wgResourceBasePath/resources/assets/poweredby_mediawiki_132x47.png 1.5x, " .
237 "$wgResourceBasePath/resources/assets/poweredby_mediawiki_176x62.png 2x";
261 'name' =>
'fsLockManager',
262 'class' => FSLockManager::class,
263 'lockDirectory' =>
"{$wgUploadDirectory}/lockdir",
266 'name' =>
'nullLockManager',
267 'class' => NullLockManager::class,
277 'imageHeight' => 120,
278 'captionLength' =>
true,
280 'showDimensions' =>
true,
281 'mode' =>
'traditional',
289 'class' => LocalRepo::class,
314 'class' => ForeignDBRepo::class,
334 'class' => FileRepo::class,
348 'class' => ForeignAPIRepo::class,
349 'name' =>
'wikimediacommons',
350 'apibase' =>
'https://commons.wikimedia.org/w/api.php',
351 'url' =>
'https://upload.wikimedia.org/wikipedia/commons',
352 'thumbUrl' =>
'https://upload.wikimedia.org/wikipedia/commons/thumb',
354 'transformVia404' =>
true,
355 'fetchDescription' =>
true,
356 'descriptionCacheExpiry' => 43200,
357 'apiThumbCacheExpiry' => 0,
361 if ( !isset( $repo[
'directory'] ) && $repo[
'class'] === ForeignAPIRepo::class ) {
364 if ( !isset( $repo[
'backend'] ) ) {
365 $repo[
'backend'] = $repo[
'name'] .
'-backend';
384 wfDeprecated(
'$wgSkipSkin – use $wgSkipSkins instead',
'1.23' );
393 wfDeprecated(
'$wgLocalInterwiki – use $wgLocalInterwikis instead',
'1.23' );
461 ini_get(
'post_max_size' ) ?: ini_get(
'hhvm.server.max_post_size' ),
463 ) ?: PHP_INT_MAX ) - 1024
489foreach ( LanguageCode::getNonstandardLanguageCodeMapping() as $code => $bcp47 ) {
490 $bcp47 = strtolower( $bcp47 );
503if ( isset( $wgUseSquid ) ) {
508 wfDeprecated(
'$wgUseSquid enabled but $wgUseCdn disabled; enabling CDN functions',
'1.34' );
515if ( isset( $wgSquidServers ) ) {
520 wfDeprecated(
'$wgSquidServers set, $wgCdnServers empty; using them',
'1.34' );
527if ( isset( $wgSquidServersNoPurge ) ) {
533 wfDeprecated(
'$wgSquidServersNoPurge set, $wgCdnServersNoPurge empty; using them',
'1.34' );
540if ( isset( $wgSquidMaxage ) ) {
545 wfDeprecated(
'$wgSquidMaxage set higher than $wgCdnMaxAge; using the higher value',
'1.34' );
556 Wikimedia\suppressWarnings();
558 Wikimedia\restoreWarnings();
591 '$wgProfileOnly set the log file in $wgDebugLogGroups[\'profileoutput\'] instead',
613if ( defined(
'MW_NO_SESSION' ) ) {
624MediaWikiServices::resetGlobalInstance(
new GlobalVarConfig(),
'quick' );
628define(
'MW_SERVICE_BOOTSTRAP_COMPLETE', 1 );
630MWExceptionHandler::installHandler();
635 '$wgServer must be set in LocalSettings.php. ' .
636 'See <a href="https://www.mediawiki.org/wiki/Manual:$wgServer">' .
637 'https://www.mediawiki.org/wiki/Manual:$wgServer</a>.'
642foreach ( [
'wgArticlePath',
'wgVariantArticlePath' ] as $varName ) {
643 if ( $$varName && !preg_match(
'/^(https?:\/\/|\/)/', $$varName ) ) {
645 "If you use a relative URL for \$$varName, it must start " .
646 'with a slash (<code>/</code>).<br><br>See ' .
647 "<a href=\"https://www.mediawiki.org/wiki/Manual:\$$varName\">" .
648 "https://www.mediawiki.org/wiki/Manual:\$$varName</a>."
660 wfWarn(
'$wgServerName should be derived from $wgCanonicalServer, '
661 .
'not customized. Overwriting $wgServerName.' );
681 wfWarn(
'Secure login was enabled on a server that only supports '
682 .
'HTTP or HTTPS. Disabling secure login.' );
694if ( !isset( $wgDisableCounters ) ) {
695 $wgDisableCounters =
true;
703 'class' => WANObjectCache::class,
710 MediaWikiServices::getInstance()->getDBLoadBalancer()->setTableAliases(
733 Wikimedia\suppressWarnings();
735 Wikimedia\restoreWarnings();
757 time() - ChronologyProtector::POSITION_COOKIE_TTL
759MediaWikiServices::getInstance()->getDBLoadBalancerFactory()->setRequestInfo( [
761 'UserAgent' =>
$wgRequest->getHeader(
'User-Agent' ),
762 'ChronologyProtection' =>
$wgRequest->getHeader(
'MediaWiki-Chronology-Protection' ),
764 'ChronologyClientId' =>
$cpPosInfo[
'clientId']
765 ??
$wgRequest->getHeader(
'MediaWiki-Chronology-Client-Id' )
769if (
$wgRequest->getCookie(
'UseDC',
'' ) ===
'master' ) {
773 MediaWikiServices::getInstance()->getMainWANObjectCache()->useInterimHoldOffCaching(
false );
778 if ( isset(
$self ) ) {
779 wfDebug(
"\n\nStart command line script $self\n" );
782 $debug =
"\n\nStart request {$wgRequest->getMethod()} {$wgRequest->getRequestURL()}\n";
784 foreach (
$wgRequest->getAllHeaders() as $name => $value ) {
785 $debug .=
"$name: $value\n";
790$wgMemc = ObjectCache::getLocalClusterInstance();
794Hooks::run(
'SetupAfterCache' );
800$wgContLang = MediaWikiServices::getInstance()->getContentLanguage();
818 if ( !defined(
'MW_NO_SESSION_HANDLER' ) ) {
819 MediaWiki\Session\PHPSessionHandler::install(
820 MediaWiki\Session\SessionManager::singleton()
826 $session = MediaWiki\Session\SessionManager::getGlobalSession();
827 }
catch (
MediaWiki\Session\SessionOverflowException $ex ) {
831 foreach ( $ex->getSessionInfos() as $info ) {
832 $list[] = $info->getProvider()->describe(
$wgContLang );
840 if ( $session->isPersistent() ) {
845 if (
MediaWiki\Session\PHPSessionHandler::isEnabled() &&
846 ( $session->isPersistent() || $session->shouldRememberUser() ) &&
847 session_id() !== $session->getId()
850 if ( session_id() !==
'' ) {
851 wfDebugLog(
'session',
'PHP session {old_id} was already started, changing to {new_id}',
'all', [
852 'old_id' => session_id(),
853 'new_id' => $session->getId(),
855 session_write_close();
857 session_id( $session->getId() );
865 if ( !defined(
'MW_NO_SESSION_HANDLER' ) ) {
866 MediaWiki\Session\PHPSessionHandler::install(
867 MediaWiki\Session\SessionManager::singleton()
885$wgOut = RequestContext::getMain()->getOutput();
892 return MediaWikiServices::getInstance()->getParser();
905 call_user_func( $func );
911 $sessionUser = MediaWiki\Session\SessionManager::getGlobalSession()->getUser();
913 $res = MediaWiki\Auth\AuthManager::singleton()->autoCreateUser(
915 MediaWiki\Auth\AuthManager::AUTOCREATE_SOURCE_SESSION,
918 \MediaWiki\Logger\LoggerFactory::getInstance(
'authevents' )->info(
'Autocreation attempt', [
919 'event' =>
'autocreate',
924 unset( $sessionUser );
$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.
string $wgSharedUploadDirectory
Shortcut for the 'directory' setting of $wgForeignFileRepos.
$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.
$wgUseCdn
Enable/disable CDN.
$wgMemoryLimit
The minimum amount of memory that MediaWiki "needs"; MediaWiki will try to raise PHP's memory limit i...
$wgEmergencyContact
Site admin email address.
$wgDBprefix
Current wiki database table name prefix.
$wgDBuser
Database username.
string $wgPHPSessionHandling
Whether to use PHP session handling ($_SESSION and session_*() functions)
bool $wgCacheSharedUploads
Shortcut for the ForeignDBRepo 'hasSharedCache' setting in $wgForeignFileRepos.
bool string $wgSharedUploadDBname
Shortcut for the ForeignDBRepo 'dbName' setting in $wgForeignFileRepos.
$wgScript
The URL path to index.php.
$wgUseInstantCommons
Use Wikimedia Commons as a foreign file repository.
bool $wgHashedSharedUploadDirectory
Shortcut for the 'hashLevels' setting of $wgForeignFileRepos.
$wgCacheDirectory
Directory for caching data in the local filesystem.
$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.
$wgMainCacheType
Main cache type.
$wgLocalInterwiki
The interwiki prefix of the current wiki, or false if it doesn't have one.
$wgPasswordPolicy
Password policy for the wiki.
$wgLogNames
Lists the message key string for each log type.
$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.
bool $wgUseSharedUploads
Shortcut for adding an entry to $wgForeignFileRepos.
string $wgSharedUploadDBprefix
Shortcut for the ForeignDBRepo 'tablePrefix' setting in $wgForeignFileRepos.
$wgDBmwschema
Current wiki database schema name.
$wgNoReplyAddress
Reply-To address for e-mail notifications.
$wgDBname
Current wiki database name.
$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.
$wgReadOnlyFile
If this lock file exists (size > 0), the wiki will be forced into read-only mode.
$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.
$wgPageCreationLog
Maintain a log of page creations at Special:Log/create?
$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.
$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.
$wgShellLocale
Locale for LC_ALL, to provide a known environment for locale-sensitive operations.
$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.
bool $wgFetchCommonsDescriptions
Shortcut for the 'fetchDescription' setting of $wgForeignFileRepos.
$wgGroupPermissions
Permission keys given to users in each group.
$wgRestPath
The URL path to the REST API Defaults to "{$wgScriptPath}/rest.php".
string $wgSharedThumbnailScriptPath
Shortcut for the 'thumbScriptUrl' setting of $wgForeignFileRepos.
$wgLocalInterwikis
Array for multiple $wgLocalInterwiki values, in case there are several interwiki prefixes that point ...
$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.
$wgAllowHTMLEmail
For parts of the system that have been updated to provide HTML email content, send both text and HTML...
$wgExtensionAssetsPath
The URL path of the extensions directory.
$wgForeignFileRepos
Enable the use of files from one or more other wikis.
$wgRepositoryBaseUrl
Shortcut for the 'descBaseUrl' setting of $wgForeignFileRepos.
$wgLogHeaders
Lists the message key string for descriptive text to be shown at the top of each log type.
$wgCdnMaxAge
Cache TTL for the CDN sent as s-maxage (without ESI) or Surrogate-Control (with ESI).
$wgDebugLogGroups
Map of string log group names to log destinations.
$wgSharedDB
Shared database for multiple wikis.
$wgDebugDumpSql
Write SQL queries to the debug log.
$wgDBserver
Database host name or IP address.
bool $wgForceHTTPS
If this is true, when an insecure HTTP request is received, always redirect to HTTPS.
$wgLoadScript
The URL path to load.php.
$wgCookieSecure
Whether the "secure" flag should be set on the cookie.
$wgExtraLanguageCodes
List of mappings from one language code to another.
$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.
$wgMinimalPasswordLength
Specifies the minimal length of a user password.
$wgMetaNamespace
Name of the project namespace.
$wgLogo
The URL path of the wiki logo.
$wgCdnServersNoPurge
As with $wgCdnServers, except these servers aren't purged on page changes; use to set a list of trust...
$wgSysopEmailBans
Allow sysops to ban users from accessing Emailuser.
$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.
$wgCdnServers
List of proxy servers to purge on changes; default port is 80.
string $wgSharedUploadPath
Shortcut for the 'url' setting of $wgForeignFileRepos.
$wgLocalTZoffset
Set an offset from UTC in minutes to use for the default timezone setting for anonymous users and new...
$wgMainWANCache
Main Wide-Area-Network cache type.
$wgDBpassword
Database user's password.
$wgNewUserLog
Maintain a log of newusers at Special:Log/newusers?
global $wgCommandLineMode
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.
wfMemoryLimit( $newLimit)
Raise PHP's memory limit (if needed).
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.
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.
wfDeprecated( $function, $version=false, $component=false, $callerOffset=2)
Throws a warning that $function is deprecated.
$wgGalleryOptions
Default parameters for the "<gallery>" tag.
if(is_array($wgExtraNamespaces)) if(count( $wgDummyLanguageCodes) !==0) $wgDummyLanguageCodes
if($wgScript===false) if( $wgLoadScript===false) if($wgRestPath===false) if( $wgArticlePath===false) 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...
foreach(LanguageCode::getNonstandardLanguageCodeMapping() as $code=> $bcp47) $wgContLanguageCode
if(isset($wgSysopEmailBans) &&$wgSysopEmailBans===false) if( $wgMetaNamespace===false) $wgMinUploadChunkSize
$wgCanonicalNamespaceNames
Definitions of the NS_ constants are in Defines.php.
foreach( $wgExtensionFunctions as $func) if(!defined('MW_NO_SESSION') &&! $wgCommandLineMode) if(! $wgCommandLineMode) $wgFullyInitialised
$wgEnotifRevealEditorAddress
if(!defined( 'MEDIAWIKI')) $wgScopeTest
This file is not a valid entry point, perform no further processing unless MEDIAWIKI is defined.
$wgUsersNotifiedOnAllChanges
if(! $wgDBerrorLogTZ) $wgRequest
if( $wgServer===false) foreach(['wgArticlePath', 'wgVariantArticlePath'] as $varName) if( $wgCanonicalServer===false) $serverParts
if($wgLocalInterwiki) if( $wgSharedPrefix===false) if($wgSharedSchema===false) if(! $wgCookiePrefix) $wgCookiePrefix
if( $wgServerName !==false) $wgServerName
$wgLockManagers[]
Initialise $wgLockManagers to include basic FS version.
$wgDefaultUserOptions['rcdays']
$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( $wgSkipSkin) $wgSkipSkins[]
Exception class which takes an HTML error message, and does not produce a backtrace.
Accesses configuration settings from $GLOBALS.
Show an error that looks like an HTTP server error.
static newFromKey( $key,... $params)
Factory function that is just wrapper for the real constructor.
static schedulePingback()
Schedule a deferred callable that will check if a pingback should be sent and (if so) proceed to send...
static getMain()
Get the RequestContext object associated with the main request.
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 isValidUserName( $name)
Is the input a valid username?
static detectProtocol()
Detect the protocol from $_SERVER.