MediaWiki  master
Setup.php File Reference

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

Go to the source code of this file.


if(defined( 'MW_SETUP_CALLBACK')) $dynamicDefaults = new DynamicDefaultValues( $wgSettings->getConfigSchema() )
 Customization point after most things are loaded (constants, functions, classes, LocalSettings. More...
if(!defined( 'MEDIAWIKI')) if(ini_get( 'mbstring.func_overload')) if(!defined( 'MW_ENTRY_POINT')) global $IP = $IP = wfDetectInstallPath()
 Environment checks. More...
 $serverParts = wfParseUrl( $wgCanonicalServer )
if(!defined( 'MW_NO_SESSION') &&! $wgCommandLineMode) if(! $wgCommandLineMode) $settingsWarnings = $wgSettings->getWarnings()
 $wgAutoloadClasses = []
if(!interface_exists(LoggerInterface::class)) $wgCommandLineMode = false
 Pre-config setup: Before loading LocalSettings.php. More...
 $wgConf = new SiteConfiguration
 $wgConf hold the site configuration. More...
global $wgExtensionFunctions
global $wgFullyInitialised = true
global $wgInitialSessionId = null
 The persistent session ID (if any) loaded at startup. More...
if(!defined( 'MW_NO_SESSION') &&! $wgCommandLineMode) $wgLang = new StubUserLang
if(!defined( 'MW_NO_SESSION') &&! $wgCommandLineMode) $wgOut = RequestContext::getMain()->getOutput()
global $wgRequest = RequestContext::getMain()->getRequest()
 $wgScopeTest = 'MediaWiki Setup.php scope test'
if( $wgServerName !==false) $wgServerName = $serverParts['host']
 $wgSettings = SettingsBuilder::getInstance()
if(!defined( 'MW_NO_SESSION') &&! $wgCommandLineMode) $wgTitle = null
 $wgUser = new StubGlobalUser( RequestContext::getMain()->getUser() )
if( $wgServer===false) if( $wgCanonicalServer===false) $wgVirtualRestConfig ['global']['domain'] = $wgCanonicalServer

Detailed Description

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

The entry point (such as WebStart.php and doMaintenance.php) has these responsibilities:

  • The entry point MUST:
    • define the 'MEDIAWIKI' constant.
  • The entry point SHOULD:
    • define the 'MW_ENTRY_POINT' constant.
    • display an error if MW_CONFIG_CALLBACK is not defined and the file specified in MW_CONFIG_FILE (or the LocalSettings.php default location) 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 error can be displayed via a MW_CONFIG_CALLBACK, which must then abort the process to prevent the rest of Setup.php from executing.

This file does:

  • run-time environment checks,
  • define MW_INSTALL_PATH, $IP, and $wgBaseDirectory,
  • load autoloaders, constants, default settings, and global functions,
  • load the site configuration (e.g. LocalSettings.php),
  • load the enabled extensions (via ExtensionRegistry),
  • trivial expansion of site configuration defaults and shortcuts (no calls to MediaWikiServices or other parts of MediaWiki),
  • 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)
  • complex expansion of site configuration defaults (those that require calling into MediaWikiServices, global functions, or other classes.).

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.

Definition in file Setup.php.

Variable Documentation

◆ $dynamicDefaults

if (defined('MW_SETUP_CALLBACK')) $dynamicDefaults = new DynamicDefaultValues( $wgSettings->getConfigSchema() )

Customization point after most things are loaded (constants, functions, classes, LocalSettings.

Note that this runs before extensions are registered, and before most singletons become available, and before MediaWikiServices is initialized.

Definition at line 247 of file Setup.php.

Referenced by MediaWiki\Settings\Config\ConfigSchemaAggregator\addDynamicDefaults().

◆ $IP

$IP = $IP = wfDetectInstallPath()

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 106 of file Setup.php.

Referenced by CommandLineInstaller\__construct(), MediaWiki\Shell\CommandFactory\create(), MediaWiki\Maintenance\MaintenanceRunner\defineSettings(), Installer\envCheckUploadsDirectory(), Installer\envPrepPath(), SpecialVersion\execute(), BenchmarkSettings\execute(), CheckComposerLockUpToDate\execute(), CleanupSpam\execute(), DumpUploads\execute(), FindDeprecated\execute(), GenerateJsonI18n\execute(), SchemaMaintenance\execute(), CommandLineInstaller\execute(), DateFormats\execute(), GenerateNormalizerDataAr\execute(), GenerateNormalizerDataMl\execute(), ManageForeignResources\execute(), GeneratePhpCharToUpperMappings\execute(), MWDocGen\execute(), MwSql\execute(), Version\execute(), MediaWiki\ResourceLoader\Module\expandRelativePaths(), MediaWiki\ResourceLoader\FileModule\extractBasePaths(), MediaWiki\ResourceLoader\ImageModule\extractLocalBasePath(), MediaWiki\ResourceLoader\OOUIIconPackModule\extractLocalBasePath(), SpecialVersion\getCreditsForExtension(), Installer\getExistingLocalSettings(), SpecialVersion\getExternalLibraries(), FindDeprecated\getFiles(), SqliteInstaller\getGlobalDefaults(), Language\getGrammarTransformations(), MediaWiki\ResourceLoader\CodexModule\getIcons(), MediaWiki\Languages\LanguageNameUtils\getJsonMessagesFileName(), LocalisationCache\getMessagesDirs(), MediaWiki\Languages\LanguageNameUtils\getMessagesFileName(), MediaWiki\ResourceLoader\Module\getRelativePaths(), SpecialVersion\getVersion(), File\iconThumb(), Installer\includeExtensionFiles(), MWDocGen\init(), ExternalStoreDB\initializeTable(), MediaWiki\Settings\LocalSettingsLoader\loadLocalSettingsFile(), ComposerPhpunitXmlCoverageEdit\onEvent(), TextPassDumper\openSpawn(), DatabaseInstaller\populateInterwikiTable(), SqliteInstaller\setupSearchIndex(), and wfDetectInstallPath().

◆ $serverParts

$serverParts = wfParseUrl( $wgCanonicalServer )

Definition at line 337 of file Setup.php.

◆ $settingsWarnings

if (!defined('MW_NO_SESSION') &&! $wgCommandLineMode) if (! $wgCommandLineMode) $settingsWarnings = $wgSettings->getWarnings()

Definition at line 572 of file Setup.php.

◆ $wgAutoloadClasses

$wgAutoloadClasses = []

◆ $wgCommandLineMode

if (!interface_exists(LoggerInterface::class)) $wgCommandLineMode = false

Pre-config setup: Before loading LocalSettings.php.

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

Definition at line 132 of file Setup.php.

◆ $wgConf

$wgConf = new SiteConfiguration

$wgConf hold the site configuration.

Not used for much in a default install.


Definition at line 139 of file Setup.php.

◆ $wgExtensionFunctions

global $wgExtensionFunctions

Definition at line 536 of file Setup.php.

◆ $wgFullyInitialised

global $wgFullyInitialised = true

◆ $wgInitialSessionId

if (MW_ENTRY_POINT==='index') MediaWiki Session SessionId null $wgInitialSessionId = null

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

Definition at line 388 of file Setup.php.

◆ $wgLang

◆ $wgOut

◆ $wgRequest

◆ $wgScopeTest

$wgScopeTest = 'MediaWiki Setup.php scope test'

Definition at line 187 of file Setup.php.

◆ $wgServerName

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

Definition at line 342 of file Setup.php.

◆ $wgSettings

$wgSettings = SettingsBuilder::getInstance()

◆ $wgTitle

◆ $wgUser

since 1.35, use an available context source when possible, or, as a backup, RequestContext::getMain()

Definition at line 515 of file Setup.php.

Referenced by MediaWiki\SpecialPage\SpecialPageFactory\capturePath(), DoubleRedirectJob\run(), and MediaWiki\StubObject\StubGlobalUser\setUser().

◆ $wgVirtualRestConfig

if ($wgServer===false) if ($wgCanonicalServer===false) $wgVirtualRestConfig[ 'global'][ 'domain'] = $wgCanonicalServer

Definition at line 335 of file Setup.php.

◆ else

if (!defined('MW_NO_SESSION') &&! $wgCommandLineMode) else
Initial value:
$wgSettings->load( new PhpSettingsSource( MW_INSTALL_PATH . '/includes/config-schema.php' ) )
Definition: Setup.php:143
Settings loaded from a PHP file path as an array structure.

Definition at line 157 of file Setup.php.



Definition at line 312 of file Setup.php.