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.

Variables

if(defined( 'MW_SETUP_CALLBACK')) $dynamicDefaults = new DynamicDefaultValues( $wgSettings->getConfigSchema() )
 Customization point after most things are loaded (constants, functions, classes, LocalSettings.
 
if(!defined('MEDIAWIKI')) if(!defined( 'MW_ENTRY_POINT')) $IP = wfDetectInstallPath()
 Environment checks.
 
if(!defined('MW_NO_SESSION') &&MW_ENTRY_POINT !=='cli') if(MW_ENTRY_POINT !=='cli' && $wgPingback $settingsWarnings ) = $wgSettings->getWarnings()
 
 $wgAutoloadClasses = []
 
if(!interface_exists(LoggerInterface::class)) $wgCommandLineMode = MW_ENTRY_POINT === 'cli'
 Pre-config setup: Before loading LocalSettings.php.
 
 $wgConf = new SiteConfiguration
 $wgConf hold the site configuration.
 
global $wgExtensionFunctions
 
global $wgFullyInitialised = true
 
 $wgLang = new StubUserLang
 
if(MW_ENTRY_POINT==='index') if(!defined( 'MW_NO_SESSION') &&MW_ENTRY_POINT !=='cli' $wgOut = RequestContext::getMain()->getOutput()
 
global $wgRequest = RequestContext::getMain()->getRequest()
 
 $wgScopeTest = 'MediaWiki Setup.php scope test'
 
if( $wgServerName !==false) $wgServerName = parse_url( $wgCanonicalServer, PHP_URL_HOST )
 
 $wgSettings = SettingsBuilder::getInstance()
 
if(MW_ENTRY_POINT==='index') if(!defined( 'MW_NO_SESSION') &&MW_ENTRY_POINT !=='cli' $wgTitle = null
 
if($wgServer===false) if( $wgCanonicalServer===false) $wgVirtualRestConfig ['global']['domain'] = $wgCanonicalServer
 
if(defined( 'MW_USE_CONFIG_SCHEMA_CLASS')) else
 
const MW_SERVICE_BOOTSTRAP_COMPLETE 1
 
 try
 

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, and $IP,
  • 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.).
Note
GPL-2.0-or-later

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

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

◆ $IP

◆ $settingsWarnings

if(!defined( 'MW_NO_SESSION') &&MW_ENTRY_POINT !=='cli') if (MW_ENTRY_POINT !=='cli' &&$wgPingback $settingsWarnings) = $wgSettings->getWarnings()

Definition at line 608 of file Setup.php.

◆ $wgAutoloadClasses

$wgAutoloadClasses = []

Definition at line 140 of file Setup.php.

Referenced by MediaWiki\Installer\Installer\getExistingLocalSettings().

◆ $wgCommandLineMode

if (!interface_exists(LoggerInterface::class)) $wgCommandLineMode = MW_ENTRY_POINT === 'cli'

Pre-config setup: Before loading LocalSettings.php.

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

Definition at line 131 of file Setup.php.

Referenced by MediaWiki\Installer\Installer\getExistingLocalSettings(), and MediaWiki\Settings\LocalSettingsLoader\loadLocalSettingsFile().

◆ $wgConf

$wgConf = new SiteConfiguration

$wgConf hold the site configuration.

Not used for much in a default install.

Since
1.5

Definition at line 138 of file Setup.php.

Referenced by MediaWiki\Installer\Installer\getExistingLocalSettings(), and MediaWiki\Settings\LocalSettingsLoader\loadLocalSettingsFile().

◆ $wgExtensionFunctions

global $wgExtensionFunctions

Definition at line 569 of file Setup.php.

◆ $wgFullyInitialised

◆ $wgLang

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

Definition at line 556 of file Setup.php.

Referenced by MediaWiki\Api\ApiMain\__construct(), MediaWiki\SpecialPage\SpecialPageFactory\capturePath(), and UpdateMediaWiki\execute().

◆ $wgOut

◆ $wgRequest

$wgRequest = RequestContext::getMain()->getRequest()

◆ $wgScopeTest

$wgScopeTest = 'MediaWiki Setup.php scope test'

Definition at line 186 of file Setup.php.

◆ $wgServerName

if ($wgServerName !==false) $wgServerName = parse_url( $wgCanonicalServer, PHP_URL_HOST )

Definition at line 388 of file Setup.php.

◆ $wgSettings

$wgSettings = SettingsBuilder::getInstance()

◆ $wgTitle

◆ $wgVirtualRestConfig

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

Definition at line 382 of file Setup.php.

◆ else

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

Definition at line 149 of file Setup.php.

◆ MW_SERVICE_BOOTSTRAP_COMPLETE

const MW_SERVICE_BOOTSTRAP_COMPLETE 1

Definition at line 326 of file Setup.php.

◆ try

try
Initial value:
{
if ( defined( 'MW_CONFIG_CALLBACK' ) ) {
call_user_func( MW_CONFIG_CALLBACK, $wgSettings );
} else {
wfDetectLocalSettingsFile( MW_INSTALL_PATH );
if ( getenv( 'MW_USE_LOCAL_SETTINGS_LOADER' ) ) {
$localSettingsLoader = new LocalSettingsLoader( $wgSettings, MW_INSTALL_PATH );
$localSettingsLoader->loadLocalSettingsFile( MW_CONFIG_FILE );
unset( $localSettingsLoader );
} else {
if ( str_ends_with( MW_CONFIG_FILE, '.php' ) ) {
$wgSettings->apply();
require_once MW_CONFIG_FILE;
} else {
$wgSettings->loadFile( MW_CONFIG_FILE );
}
}
}
$wgSettings->apply()
wfDetectLocalSettingsFile(?string $installationPath=null)
Decide and remember where to load LocalSettings from.
Utility for loading LocalSettings files.
const MW_CONFIG_CALLBACK
Definition install.php:19

Definition at line 197 of file Setup.php.