MediaWiki REL1_36
Setup.php File Reference

The setup for all MediaWiki processes (both web-based and CLI). More...

Go to the source code of this file.

Variables

 $cpPosInfo
 
 $rcMaxAgeDays = $wgRCMaxAge / ( 3600 * 24 )
 
if($wgServer===false) if( $wgCanonicalServer===false) $serverParts = wfParseUrl( $wgCanonicalServer )
 
 $wgCanonicalNamespaceNames = NamespaceInfo::CANONICAL_NAMES
 Definitions of the NS_ constants are in Defines.php.
 
if(! $wgCookiePrefix) $wgCookiePrefix = strtr( $wgCookiePrefix, '=,; +."\'\\[', '__________' )
 
 $wgDefaultUserOptions ['rcdays']
 
if( $wgLocalTZoffset===null) $wgDefaultUserOptions ['timecorrection'] = "System|$wgLocalTZoffset"
 
 $wgDefaultUserOptions ['watchlistdays']
 
if(is_array($wgExtraNamespaces)) if(count( $wgDummyLanguageCodes) !==0) $wgDummyLanguageCodes
 
 $wgEmailAuthentication = false
 
 $wgEnableUserEmail = false
 
 $wgEnotifFromEditor = false
 
 $wgEnotifImpersonal = false
 
 $wgEnotifMaxRecips = 0
 
 $wgEnotifMinorEdits = false
 
 $wgEnotifRevealEditorAddress = false
 
 $wgEnotifUseRealName = false
 
 $wgEnotifUserTalk = false
 
 $wgEnotifWatchlist = false
 
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 = array_values( array_diff( $wgFileExtensions, $wgFileBlacklist ) )
 Expand dynamic defaults and shortcuts.
 
if(!defined('MW_NO_SESSION') &&! $wgCommandLineMode) if(! $wgCommandLineMode) $wgFullyInitialised = true
 
 $wgGalleryOptions
 Default parameters for the "<gallery>" tag.
 
MediaWiki Session SessionId null $wgInitialSessionId = null
 The persistent session ID (if any) loaded at startup.
 
 $wgLang = new StubUserLang
 
 $wgLockManagers []
 Initialise $wgLockManagers to include basic FS version.
 
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] = 'editinterface'
 Unconditional protection for NS_MEDIAWIKI since otherwise it's too easy for a sysadmin to set $wgNamespaceProtection incorrectly and leave the wiki insecure.
 
 $wgOut = RequestContext::getMain()->getOutput()
 
 $wgParser
 
if(! $wgDBerrorLogTZ) $wgRequest = RequestContext::getMain()->getRequest()
 
if(!defined( 'MEDIAWIKI')) $wgScopeTest = 'MediaWiki Setup.php scope test'
 Environment checks.
 
if( $wgServerName !==false) $wgServerName = $serverParts['host']
 
 $wgTitle = null
 
 $wgUseEnotif = false
 
 $wgUserEmailUseReplyTo = false
 
 $wgUsersNotifiedOnAllChanges = []
 
if(! $wgEmergencyContact) if(! $wgPasswordSender) if(! $wgNoReplyAddress) if( $wgSecureLogin &&substr( $wgServer, 0, 2) !=='//') $wgVirtualRestConfig ['global']['domain'] = $wgCanonicalServer
 
if(defined( 'MW_CONFIG_CALLBACK')) else
 Load LocalSettings.php.
 
if(ini_get('mbstring.func_overload')) if (!defined('MW_ENTRY_POINT'))
 Pre-config setup: Before loading LocalSettings.php.
 
const MW_SERVICE_BOOTSTRAP_COMPLETE 1
 

Detailed Description

The setup for all MediaWiki processes (both web-based and CLI).

This file must be included by all entry points (such as WebStart.php and doMaintenance.php).

  • The entry point MUST do these:
    • define the 'MEDIAWIKI' constant.
    • define the $IP global variable.
  • The entry point SHOULD do these:
    • define the 'MW_ENTRY_POINT' constant.
    • display an error if MW_CONFIG_CALLBACK is not defined and the the file specified in MW_CONFIG_FILE (or the $IP/LocalSettings.php default) does not exist. The error should either be sent before and instead of the Setup.php inclusion, or (if it needs classes and dependencies from core) the erorr can be displayed via a MW_CONFIG_CALLBACK, which must then abort the process to prevent the rest of Setup.php from executing.

It does:

  • run-time environment checks,
  • load autoloaders, constants, default settings, and global functions,
  • load the site configuration (e.g. LocalSettings.php),
  • load the enabled extensions (via ExtensionRegistry),
  • expand any dynamic site configuration defaults and shortcuts
  • initialization of:
    • PHP run-time (setlocale, memory limit, default date timezone)
    • the debug logger (MWDebug)
    • the service container (MediaWikiServices)
    • the exception handler (MWExceptionHandler)
    • the session manager (SessionManager)

This program is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation; either version 2 of the License, or (at your option) any later version.

This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details.

You should have received a copy of the GNU General Public License along with this program; if not, write to the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. http://www.gnu.org/copyleft/gpl.html

Definition in file Setup.php.

Variable Documentation

◆ $cpPosInfo

$cpPosInfo
Initial value:
= LBFactory::getCPInfoFromCookieValue(
$wgRequest->getCookie( 'cpPosIndex', '' ),
time() - ChronologyProtector::POSITION_COOKIE_TTL
)
if(! $wgDBerrorLogTZ) $wgRequest
Definition Setup.php:682

Definition at line 684 of file Setup.php.

◆ $rcMaxAgeDays

$rcMaxAgeDays = $wgRCMaxAge / ( 3600 * 24 )

Definition at line 406 of file Setup.php.

◆ $serverParts

if( $wgServer===false) if ($wgCanonicalServer===false) $serverParts = wfParseUrl( $wgCanonicalServer )

Definition at line 596 of file Setup.php.

◆ $wgCanonicalNamespaceNames

$wgCanonicalNamespaceNames = NamespaceInfo::CANONICAL_NAMES

Definitions of the NS_ constants are in Defines.php.

Access: internal

Definition at line 457 of file Setup.php.

Referenced by wfInstallerMain().

◆ $wgCookiePrefix

if (! $wgCookiePrefix) $wgCookiePrefix = strtr( $wgCookiePrefix, '=,; +."\'\\[', '__________' )

Definition at line 429 of file Setup.php.

◆ $wgDefaultUserOptions [1/3]

$wgDefaultUserOptions[ 'rcdays']
Initial value:
= min(
ceil( $rcMaxAgeDays )
)
$rcMaxAgeDays
Definition Setup.php:406
$wgDefaultUserOptions['rcdays']
Definition Setup.php:408

Definition at line 408 of file Setup.php.

◆ $wgDefaultUserOptions [2/3]

if ($wgLocalTZoffset===null) $wgDefaultUserOptions[ 'timecorrection'] = "System|$wgLocalTZoffset"

Definition at line 675 of file Setup.php.

◆ $wgDefaultUserOptions [3/3]

$wgDefaultUserOptions[ 'watchlistdays']
Initial value:
= min(
$wgDefaultUserOptions['watchlistdays'],
ceil( $rcMaxAgeDays )
)

Definition at line 412 of file Setup.php.

◆ $wgDummyLanguageCodes

if(is_array( $wgExtraNamespaces)) if (count($wgDummyLanguageCodes) !==0) $wgDummyLanguageCodes
Initial value:
= [
'qqq' => 'qqq',
'qqx' => 'qqx',
] + $wgExtraLanguageCodes + LanguageCode::getDeprecatedCodeMapping()
$wgExtraLanguageCodes
List of mappings from one language code to another.

Definition at line 469 of file Setup.php.

◆ $wgEmailAuthentication

$wgEmailAuthentication = false

Definition at line 437 of file Setup.php.

◆ $wgEnableUserEmail

$wgEnableUserEmail = false

Definition at line 438 of file Setup.php.

◆ $wgEnotifFromEditor

$wgEnotifFromEditor = false

Definition at line 439 of file Setup.php.

◆ $wgEnotifImpersonal

$wgEnotifImpersonal = false

Definition at line 440 of file Setup.php.

◆ $wgEnotifMaxRecips

$wgEnotifMaxRecips = 0

Definition at line 441 of file Setup.php.

◆ $wgEnotifMinorEdits

$wgEnotifMinorEdits = false

Definition at line 442 of file Setup.php.

◆ $wgEnotifRevealEditorAddress

$wgEnotifRevealEditorAddress = false

Definition at line 443 of file Setup.php.

◆ $wgEnotifUseRealName

$wgEnotifUseRealName = false

Definition at line 444 of file Setup.php.

◆ $wgEnotifUserTalk

$wgEnotifUserTalk = false

Definition at line 445 of file Setup.php.

◆ $wgEnotifWatchlist

$wgEnotifWatchlist = false

Definition at line 446 of file Setup.php.

◆ $wgFileExtensions

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 = array_values( array_diff( $wgFileExtensions, $wgFileBlacklist ) )

Expand dynamic defaults and shortcuts.

Definition at line 250 of file Setup.php.

◆ $wgFullyInitialised

if(!defined( 'MW_NO_SESSION') &&! $wgCommandLineMode) if (! $wgCommandLineMode) $wgFullyInitialised = true

◆ $wgGalleryOptions

$wgGalleryOptions
Initial value:
= [
'imagesPerRow' => 0,
'imageWidth' => 120,
'imageHeight' => 120,
'captionLength' => true,
'showBytes' => true,
'showDimensions' => true,
'mode' => 'traditional',
]

Default parameters for the "<gallery>" tag.

See also
DefaultSettings.php for description of the fields.

Definition at line 310 of file Setup.php.

◆ $wgInitialSessionId

MediaWiki Session SessionId null $wgInitialSessionId = null

The persistent session ID (if any) loaded at startup.

Definition at line 735 of file Setup.php.

Referenced by LoginSignupSpecialPage\hasSessionCookie().

◆ $wgLang

◆ $wgLockManagers

$wgLockManagers[]
Initial value:
= [
'name' => 'fsLockManager',
'class' => FSLockManager::class,
'lockDirectory' => "{$wgUploadDirectory}/lockdir",
]

Initialise $wgLockManagers to include basic FS version.

Definition at line 296 of file Setup.php.

◆ $wgNamespaceProtection

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] = 'editinterface'

Unconditional protection for NS_MEDIAWIKI since otherwise it's too easy for a sysadmin to set $wgNamespaceProtection incorrectly and leave the wiki insecure.

Note that this is the definition of editinterface and it can be granted to all users if desired.

Definition at line 291 of file Setup.php.

◆ $wgOut

◆ $wgParser

Parser $wgParser
Initial value:
= new DeprecatedGlobal( 'wgParser', static function () {
return MediaWikiServices::getInstance()->getParser();
}, '1.32' )
Class to allow throwing wfDeprecated warnings when people use globals that we do not want them to.
Deprecated:
since 1.32, use MediaWikiServices::getInstance()->getParser() instead

Definition at line 824 of file Setup.php.

◆ $wgRequest

◆ $wgScopeTest

if (!defined('MEDIAWIKI')) $wgScopeTest = 'MediaWiki Setup.php scope test'

Environment checks.

These are inline checks done before we include any source files, and thus these conditions may be assumed by all source code.

Definition at line 71 of file Setup.php.

◆ $wgServerName

if ($wgServerName !==false) $wgServerName = $serverParts['host']

Definition at line 601 of file Setup.php.

◆ $wgTitle

◆ $wgUseEnotif

$wgUseEnotif = false

Definition at line 448 of file Setup.php.

Referenced by RecentChange\save().

◆ $wgUserEmailUseReplyTo

$wgUserEmailUseReplyTo = false

Definition at line 449 of file Setup.php.

◆ $wgUsersNotifiedOnAllChanges

$wgUsersNotifiedOnAllChanges = []

Definition at line 450 of file Setup.php.

◆ $wgVirtualRestConfig

if(! $wgEmergencyContact) if(! $wgPasswordSender) if(! $wgNoReplyAddress) if ($wgSecureLogin &&substr($wgServer, 0, 2) !=='//') $wgVirtualRestConfig[ 'global'][ 'domain'] = $wgCanonicalServer

Definition at line 623 of file Setup.php.

◆ else

if (!defined('MW_NO_SESSION') &&! $wgCommandLineMode) else
Initial value:
{
if ( !defined( 'MW_CONFIG_FILE' ) ) {
define( 'MW_CONFIG_FILE', "$IP/LocalSettings.php" );
}
require_once MW_CONFIG_FILE

Load LocalSettings.php.

Definition at line 141 of file Setup.php.

◆ if

if ( defined'MW_ENTRY_POINT')
Initial value:
{
$wgAllowHTMLEmail
For parts of the system that have been updated to provide HTML email content, send both text and HTML...

Pre-config setup: Before loading LocalSettings.php.

These are changes and additions to runtime that don't vary on site configuration.

Definition at line 87 of file Setup.php.

Referenced by MediaWiki\Revision\RevisionStore\newRevisionsFromBatch().

◆ MW_SERVICE_BOOTSTRAP_COMPLETE

const MW_SERVICE_BOOTSTRAP_COMPLETE 1

Definition at line 577 of file Setup.php.