52use Psr\Log\LoggerInterface;
64if ( !defined(
'MEDIAWIKI' ) ) {
71 echo
"Error, Setup.php must be included from the file scope.\n";
78if ( ini_get(
'mbstring.func_overload' ) ) {
79 die(
'MediaWiki does not support installations where mbstring.func_overload is non-zero.' );
85if ( !defined(
'MW_ENTRY_POINT' ) ) {
91 define(
'MW_ENTRY_POINT',
'unknown' );
100require_once
"$IP/includes/AutoLoader.php";
101require_once
"$IP/includes/Defines.php";
102require_once
"$IP/includes/DefaultSettings.php";
103require_once
"$IP/includes/GlobalFunctions.php";
106if ( is_readable(
"$IP/vendor/autoload.php" ) ) {
107 require_once
"$IP/vendor/autoload.php";
108} elseif ( file_exists(
"$IP/vendor/autoload.php" ) ) {
109 die(
"$IP/vendor/autoload.php exists but is not readable" );
113if ( !interface_exists( LoggerInterface::class ) ) {
115 'MediaWiki requires the <a href="https://github.com/php-fig/log">PSR-3 logging ' .
116 "library</a> to be present. This library is not embedded directly in MediaWiki's " .
117 "git repository and must be installed separately by the end user.\n\n" .
118 'Please see the <a href="https://www.mediawiki.org/wiki/Download_from_Git' .
119 '#Fetch_external_libraries">instructions for installing libraries</a> on mediawiki.org ' .
120 'for help on installing the required components.'
123 trigger_error( $message, E_USER_ERROR );
127MediaWiki\HeaderCallback::register();
131mb_internal_encoding(
'UTF-8' );
137if ( defined(
'MW_CONFIG_CALLBACK' ) ) {
140 if ( !defined(
'MW_CONFIG_FILE' ) ) {
141 define(
'MW_CONFIG_FILE',
"$IP/LocalSettings.php" );
143 require_once MW_CONFIG_FILE;
153if ( defined(
'MW_SETUP_CALLBACK' ) ) {
154 call_user_func( MW_SETUP_CALLBACK );
167putenv(
"LC_ALL=$wgShellLocale" );
211 $wgLogo =
"$wgResourceBasePath/resources/assets/wiki.png";
248 "{$wgStylePath}/common/images/",
249 "{$wgResourceBasePath}/resources/assets/licenses/",
271 "$wgResourceBasePath/resources/assets/poweredby_mediawiki_88x31.png";
273 "$wgResourceBasePath/resources/assets/poweredby_mediawiki_132x47.png 1.5x, " .
274 "$wgResourceBasePath/resources/assets/poweredby_mediawiki_176x62.png 2x";
290 'name' =>
'fsLockManager',
291 'class' => FSLockManager::class,
292 'lockDirectory' =>
"{$wgUploadDirectory}/lockdir",
295 'name' =>
'nullLockManager',
296 'class' => NullLockManager::class,
306 'imageHeight' => 120,
307 'captionLength' =>
true,
309 'showDimensions' =>
true,
310 'mode' =>
'traditional',
318 'class' => LocalRepo::class,
343 'class' => ForeignDBRepo::class,
363 'class' => FileRepo::class,
377 'class' => ForeignAPIRepo::class,
378 'name' =>
'wikimediacommons',
379 'apibase' =>
'https://commons.wikimedia.org/w/api.php',
380 'url' =>
'https://upload.wikimedia.org/wikipedia/commons',
381 'thumbUrl' =>
'https://upload.wikimedia.org/wikipedia/commons/thumb',
383 'transformVia404' =>
true,
384 'fetchDescription' =>
true,
385 'descriptionCacheExpiry' => 43200,
386 'apiThumbCacheExpiry' => 0,
390 if ( !isset( $repo[
'directory'] ) && $repo[
'class'] === ForeignAPIRepo::class ) {
393 if ( !isset( $repo[
'backend'] ) ) {
394 $repo[
'backend'] = $repo[
'name'] .
'-backend';
469foreach ( LanguageCode::getNonstandardLanguageCodeMapping() as $code => $bcp47 ) {
470 $bcp47 = strtolower( $bcp47 );
477 Wikimedia\suppressWarnings();
479 Wikimedia\restoreWarnings();
524if ( defined(
'MW_NO_SESSION' ) ) {
534MediaWikiServices::resetGlobalInstance(
new GlobalVarConfig(),
'quick' );
538define(
'MW_SERVICE_BOOTSTRAP_COMPLETE', 1 );
540MWExceptionHandler::installHandler();
546 '$wgServer must be set in LocalSettings.php. ' .
547 'See <a href="https://www.mediawiki.org/wiki/Manual:$wgServer">' .
548 'https://www.mediawiki.org/wiki/Manual:$wgServer</a>.'
559 wfWarn(
'$wgServerName should be derived from $wgCanonicalServer, '
560 .
'not customized. Overwriting $wgServerName.' );
580 wfWarn(
'Secure login was enabled on a server that only supports '
581 .
'HTTP or HTTPS. Disabling secure login.' );
595 'class' => WANObjectCache::class,
602 MediaWikiServices::getInstance()->getDBLoadBalancer()->setTableAliases(
625 Wikimedia\suppressWarnings();
627 Wikimedia\restoreWarnings();
649 time() - ChronologyProtector::POSITION_COOKIE_TTL
651MediaWikiServices::getInstance()->getDBLoadBalancerFactory()->setRequestInfo( [
653 'UserAgent' =>
$wgRequest->getHeader(
'User-Agent' ),
654 'ChronologyProtection' =>
$wgRequest->getHeader(
'MediaWiki-Chronology-Protection' ),
656 'ChronologyClientId' =>
$cpPosInfo[
'clientId']
657 ??
$wgRequest->getHeader(
'MediaWiki-Chronology-Client-Id' )
661if (
$wgRequest->getCookie(
'UseDC',
'' ) ===
'master' ) {
665 MediaWikiServices::getInstance()->getMainWANObjectCache()->useInterimHoldOffCaching(
false );
671 $logger = LoggerFactory::getInstance(
'wfDebug' );
673 $self = $_SERVER[
'PHP_SELF'] ??
'';
674 $logger->debug(
"\n\nStart command line script $self" );
676 $debug =
"\n\nStart request {$wgRequest->getMethod()} {$wgRequest->getRequestURL()}\n";
678 $debug .=
"HTTP HEADERS:\n";
679 foreach (
$wgRequest->getAllHeaders() as $name => $value ) {
680 $debug .=
"$name: $value\n";
682 $debug .=
"(end headers)";
691$wgMemc = ObjectCache::getLocalClusterInstance();
694Hooks::runner()->onSetupAfterCache();
700$wgContLang = MediaWikiServices::getInstance()->getContentLanguage();
717 if ( !defined(
'MW_NO_SESSION_HANDLER' ) ) {
718 MediaWiki\Session\PHPSessionHandler::install(
719 MediaWiki\Session\SessionManager::singleton()
725 $session = MediaWiki\Session\SessionManager::getGlobalSession();
726 }
catch (
MediaWiki\Session\SessionOverflowException $ex ) {
730 foreach ( $ex->getSessionInfos() as $info ) {
731 $list[] = $info->getProvider()->describe(
$wgContLang );
739 if ( $session->isPersistent() ) {
744 if (
MediaWiki\Session\PHPSessionHandler::isEnabled() &&
745 ( $session->isPersistent() || $session->shouldRememberUser() ) &&
746 session_id() !== $session->getId()
749 if ( session_id() !==
'' ) {
750 wfDebugLog(
'session',
'PHP session {old_id} was already started, changing to {new_id}',
'all', [
751 'old_id' => session_id(),
752 'new_id' => $session->getId(),
754 session_write_close();
756 session_id( $session->getId() );
764 if ( !defined(
'MW_NO_SESSION_HANDLER' ) ) {
765 MediaWiki\Session\PHPSessionHandler::install(
766 MediaWiki\Session\SessionManager::singleton()
786$wgOut = RequestContext::getMain()->getOutput();
793 return MediaWikiServices::getInstance()->getParser();
806 call_user_func( $func );
812 $sessionUser = MediaWiki\Session\SessionManager::getGlobalSession()->getUser();
814 $res = MediaWikiServices::getInstance()->getAuthManager()->autoCreateUser(
816 MediaWiki\Auth\AuthManager::AUTOCREATE_SOURCE_SESSION,
819 \MediaWiki\Logger\LoggerFactory::getInstance(
'authevents' )->info(
'Autocreation attempt', [
820 'event' =>
'autocreate',
821 'status' => strval(
$res ),
825 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.
$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.
$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.
$wgPasswordPolicy
Password policy for the wiki.
$wgLogNames
Lists the message key string for each log type.
$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 $wgGenerateThumbnailOnParse
Render thumbnails while parsing wikitext.
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.
$wgFooterIcons
Abstract list of footer icons for skins in place of old copyrightico and poweredbyico code You can ad...
$wgArticlePath
The URL path for primary article page views.
$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.
bool $wgHashedUploadDirectory
Shortcut for setting hashLevels=2 in $wgLocalFileRepo.
$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.
$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...
array false $wgLogos
The URL path to various wiki logos.
$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.
$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.
$wgPasswordSender
Sender email address for e-mail notifications.
$wgLogActionsHandlers
The same as above, but here values are names of classes, not messages.
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
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.
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.
wfDeprecated( $function, $version=false, $component=false, $callerOffset=2)
Logs a warning that $function is deprecated.
$wgGalleryOptions
Default parameters for the "<gallery>" tag.
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( $wgLogos !==false &&isset( $wgLogos['1x'])) if($wgLogo===false) if( $wgUploadPath===false) if($wgUploadDirectory===false) if( $wgReadOnlyFile===false) if($wgFileCacheDirectory===false) if( $wgDeletedDirectory===false) if($wgGitInfoCacheDirectory===false &&$wgCacheDirectory !==false) if( $wgSharedPrefix===false) if($wgSharedSchema===false) if( $wgMetaNamespace===false) $wgFileExtensions
Expand dynamic defaults and shortcuts.
if(is_array($wgExtraNamespaces)) if(count( $wgDummyLanguageCodes) !==0) $wgDummyLanguageCodes
$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
Environment checks.
if(! $wgCookiePrefix) $wgCookiePrefix
$wgUsersNotifiedOnAllChanges
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(! $wgDBerrorLogTZ) $wgRequest
if($wgServer===false) if( $wgCanonicalServer===false) $serverParts
MediaWiki Session SessionId null $wgInitialSessionId
The persistent session ID (if any) loaded at startup.
if( $wgServerName !==false) $wgServerName
$wgLockManagers[]
Initialise $wgLockManagers to include basic FS version.
$wgDefaultUserOptions['rcdays']
if(! $wgEmergencyContact) if(! $wgPasswordSender) if(! $wgNoReplyAddress) if( $wgSecureLogin &&substr( $wgServer, 0, 2) !=='//') $wgVirtualRestConfig['global']['domain']
Class to allow throwing wfDeprecated warnings when people use globals that we do not want them to.
Abort the web request with a custom HTML string that will represent the entire response.
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.
Stub object for the user language.
static isValidUserName( $name)
Is the input a valid username?
static detectProtocol()
Detect the protocol from $_SERVER.