MediaWiki
master
|
Base installer class. More...
Public Member Functions | |
__construct () | |
Constructor, always call this from child classes. More... | |
addInstallStep ( $callback, $findStep='BEGINNING') | |
Add an installation step following the given step. More... | |
dirIsExecutable ( $dir, $url) | |
Checks if scripts located in the given directory can be executed via the given URL. More... | |
disableLinkPopups () | |
doEnvironmentChecks () | |
Do initial checks of the PHP environment. More... | |
doEnvironmentPreps () | |
findExtensions ( $directory='extensions') | |
Find extensions or skins in a subdirectory of $IP. More... | |
generateKeys () | |
Generate $wgSecretKey. More... | |
getAutoExtensionHookContainer () | |
Get the hook container previously populated by includeExtensions(). More... | |
getCompiledDBs () | |
Get a list of DBs supported by current PHP setup. More... | |
getDBInstaller ( $type=false) | |
Get an instance of DatabaseInstaller for the specified DB type. More... | |
getDefaultSkin (array $skinNames) | |
Returns a default value to be used for $wgDefaultSkin: normally the DefaultSkin from config-schema.yaml, but will fall back to another if the default skin is missing and some other one is present instead. More... | |
getFakePassword ( $realPassword) | |
Get a fake password for sending back to the user in HTML. More... | |
getParserOptions () | |
getVar ( $name, $default=null) | |
Get an MW configuration variable, or internal installer configuration variable. More... | |
parse ( $text, $lineStart=false) | |
Convert wikitext $text to HTML. More... | |
performInstallation ( $startCB, $endCB) | |
Actually perform the installation. More... | |
populateSiteStats (DatabaseInstaller $installer) | |
Install step which adds a row to the site_stats table with appropriate initial values. More... | |
resetMediaWikiServices (Config $installerConfig=null, $serviceOverrides=[]) | |
Reset the global service container and associated global state to accommodate different stages of the installation. More... | |
restoreLinkPopups () | |
restoreServices () | |
Restore services that have been redefined in the early stage of installation. More... | |
setParserLanguage ( $lang) | |
ParserOptions are constructed before we determined the language, so fix it. More... | |
setPassword ( $name, $value) | |
Set a variable which stores a password, except if the new value is a fake password in which case leave it as it is. More... | |
setVar ( $name, $value) | |
Set a MW configuration variable, or internal installer configuration variable. More... | |
showError ( $msg,... $params) | |
Same as showMessage(), but for displaying errors. More... | |
showMessage ( $msg,... $params) | |
UI interface for displaying a short message The parameters are like parameters to wfMessage(). More... | |
showStatusMessage (Status $status) | |
Show a message to the installing user by using a Status object. More... | |
Static Public Member Functions | |
static | apacheModulePresent ( $moduleName) |
Checks for presence of an Apache module. More... | |
static | getDBInstallerClass ( $type) |
Get the DatabaseInstaller class name for this type. More... | |
static | getDBTypes () |
Get a list of known DB types. More... | |
static | getExistingLocalSettings () |
Determine if LocalSettings.php exists. More... | |
static | getInstallerConfig (Config $baseConfig) |
Constructs a Config object that contains configuration settings that should be overwritten for the installation process. More... | |
static | maybeGetWebserverPrimaryGroup () |
On POSIX systems return the primary group of the webserver we're running under. More... | |
static | overrideConfig (SettingsBuilder $settings) |
Override the necessary bits of the config to run an installation. More... | |
Public Attributes | |
array | $licenses |
License types. More... | |
array | $rightsProfiles |
User rights profiles. More... | |
const | MINIMUM_PCRE_VERSION = '7.2' |
The oldest version of PCRE we can support. More... | |
Protected Member Functions | |
createMainpage (DatabaseInstaller $installer) | |
Insert Main Page with default content. More... | |
createSysop () | |
Create the first user account, grant it sysop, bureaucrat and interface-admin rights. More... | |
disableTimeLimit () | |
Disable the time limit for execution. More... | |
doGenerateKeys ( $keys) | |
Generate a secret value for variables using a secure generator. More... | |
envCheck64Bit () | |
Checks if we're running on 64 bit or not. More... | |
envCheckCache () | |
Environment check for compiled object cache types. More... | |
envCheckDB () | |
Environment check for DB types. More... | |
envCheckDiff3 () | |
Search for GNU diff3. More... | |
envCheckGit () | |
Search for git. More... | |
envCheckGraphics () | |
Environment check for ImageMagick and GD. More... | |
envCheckLibicu () | |
Check and display the libicu and Unicode versions. More... | |
envCheckMemory () | |
Environment check for available memory. More... | |
envCheckModSecurity () | |
Scare user to death if they have mod_security or mod_security2. More... | |
envCheckPath () | |
Environment check to inform user which paths we've assumed. More... | |
envCheckPCRE () | |
Environment check for the PCRE module. More... | |
envCheckServer () | |
Environment check to inform user which server we've assumed. More... | |
envCheckUploadsDirectory () | |
Environment check for the permissions of the uploads directory. More... | |
envGetDefaultServer () | |
Helper function to be called from envPrepServer() More... | |
envPrepPath () | |
Environment prep for setting $IP and $wgScriptPath. More... | |
envPrepServer () | |
Environment prep for the server hostname. More... | |
findExtensionsByType ( $type='extension', $directory='extensions') | |
Find extensions or skins, and return an array containing the value for 'Name' for each found extension. More... | |
getAutoExtensionData () | |
Auto-detect extensions with an extension.json file. More... | |
getAutoExtensionLegacyHooks () | |
Auto-detect extensions with an old style .php registration file, load the extensions, and return the merged $wgHooks array. More... | |
getDocUrl ( $page) | |
Overridden by WebInstaller to provide lastPage parameters. More... | |
getExtensionInfo ( $type, $parentRelPath, $name) | |
getInstallSteps (DatabaseInstaller $installer) | |
Get an array of install steps. More... | |
includeExtensionFiles ( $files) | |
Include the specified extension PHP files. More... | |
includeExtensions () | |
Installs the auto-detected extensions. More... | |
Protected Attributes | |
HookContainer null | $autoExtensionHookContainer |
array | $compiledDBs |
List of detected DBs, access using getCompiledDBs(). More... | |
array | $dbInstallers = [] |
Cached DB installer instances, access using getDBInstaller(). More... | |
array | $envChecks |
A list of environment check methods called by doEnvironmentChecks(). More... | |
array | $envPreps |
A list of environment preparation methods called by doEnvironmentPreps(). More... | |
array | $extraInstallSteps = [] |
Extra steps for installation, for things like DatabaseInstallers to modify. More... | |
array | $internalDefaults |
Variables that are stored alongside globals, and are used for any configuration of the installation process aside from the MediaWiki configuration. More... | |
int | $minMemorySize = 50 |
Minimum memory size in MiB. More... | |
array | $objectCaches |
Known object cache types and the functions used to test for their existence. More... | |
ParserOptions | $parserOptions |
Cached ParserOptions, used by parse(). More... | |
Title | $parserTitle |
Cached Title, used by parse(). More... | |
array | $settings |
Static Protected Attributes | |
static array | $dbTypes |
Known database types. More... | |
Base installer class.
This class provides the base for installation and update functionality for both MediaWiki core and extensions.
Definition at line 58 of file Installer.php.
Installer::__construct | ( | ) |
Constructor, always call this from child classes.
Definition at line 412 of file Installer.php.
References $type, doEnvironmentPreps(), getDBInstaller(), getInstallerConfig(), Title\newFromText(), and resetMediaWikiServices().
Installer::addInstallStep | ( | $callback, | |
$findStep = 'BEGINNING' |
|||
) |
Add an installation step following the given step.
array | $callback | A valid installation callback array, in this form: [ 'name' => 'some-unique-name', 'callback' => [ $obj, 'function' ] ]; |
string | $findStep | The step to find. Omit to put the step at the beginning |
Definition at line 1941 of file Installer.php.
|
static |
Checks for presence of an Apache module.
Works only if PHP is running as an Apache module, too.
string | $moduleName | Name of module to check. |
Definition at line 1203 of file Installer.php.
|
protected |
Insert Main Page with default content.
DatabaseInstaller | $installer |
Definition at line 1844 of file Installer.php.
References $content, $title, EDIT_NEW, StatusValue\newGood(), Title\newMainPage(), User\newSystemUser(), and wfMessage().
|
protected |
Create the first user account, grant it sysop, bureaucrat and interface-admin rights.
Definition at line 1740 of file Installer.php.
References SiteStatsUpdate\factory(), StatusValue\newFatal(), User\newFromName(), and StatusValue\newGood().
Installer::dirIsExecutable | ( | $dir, | |
$url | |||
) |
Checks if scripts located in the given directory can be executed via the given URL.
Used only by environment checks.
string | $dir | |
string | $url |
Reimplemented in CliInstaller.
Definition at line 1148 of file Installer.php.
Installer::disableLinkPopups | ( | ) |
Definition at line 800 of file Installer.php.
|
protected |
Disable the time limit for execution.
Some long-running pages (Install, Upgrade) will want to do this
Definition at line 1949 of file Installer.php.
Referenced by WebInstaller\execute().
Installer::doEnvironmentChecks | ( | ) |
Do initial checks of the PHP environment.
Set variables according to the observed environment.
It's possible that this may be called under the CLI SAPI, not the SAPI that the wiki will primarily run under. In that case, the subclass should initialise variables such as wgScriptPath, before calling this function.
Under the web subclass, it can already be assumed that PHP 5+ is in use and that sessions are working.
Definition at line 552 of file Installer.php.
References StatusValue\newFatal(), and StatusValue\newGood().
Installer::doEnvironmentPreps | ( | ) |
Definition at line 577 of file Installer.php.
Referenced by __construct().
|
protected |
Generate a secret value for variables using a secure generator.
array | $keys |
Definition at line 1727 of file Installer.php.
References $keys, MWCryptRand\generateHex(), and StatusValue\newGood().
|
protected |
Checks if we're running on 64 bit or not.
32 bit is becoming increasingly hard to support, so let's at least warn people.
Definition at line 1099 of file Installer.php.
|
protected |
Environment check for compiled object cache types.
Definition at line 952 of file Installer.php.
|
protected |
Environment check for DB types.
Definition at line 849 of file Installer.php.
References $wgLang, and wfMessage().
|
protected |
Search for GNU diff3.
Definition at line 984 of file Installer.php.
References ExecutableFinder\findInDefaultPaths(), and wfIsWindows().
|
protected |
Search for git.
Definition at line 1031 of file Installer.php.
References ExecutableFinder\findInDefaultPaths(), and wfIsWindows().
|
protected |
Environment check for ImageMagick and GD.
Definition at line 1007 of file Installer.php.
References ExecutableFinder\findInDefaultPaths(), and wfIsWindows().
|
protected |
Check and display the libicu and Unicode versions.
Definition at line 1110 of file Installer.php.
|
protected |
Environment check for available memory.
Definition at line 926 of file Installer.php.
References wfShorthandToInteger().
|
protected |
Scare user to death if they have mod_security or mod_security2.
Definition at line 971 of file Installer.php.
|
protected |
Environment check to inform user which paths we've assumed.
Reimplemented in WebInstaller, and CliInstaller.
Definition at line 1066 of file Installer.php.
|
protected |
Environment check for the PCRE module.
Definition at line 895 of file Installer.php.
|
protected |
Environment check to inform user which server we've assumed.
Definition at line 1053 of file Installer.php.
|
protected |
Environment check for the permissions of the uploads directory.
Definition at line 1079 of file Installer.php.
References $IP.
|
abstractprotected |
Helper function to be called from envPrepServer()
Reimplemented in WebInstaller, and CliInstaller.
|
protected |
Environment prep for setting $IP and $wgScriptPath.
Reimplemented in WebInstaller.
Definition at line 1134 of file Installer.php.
References $IP.
|
protected |
Environment prep for the server hostname.
Definition at line 1118 of file Installer.php.
Installer::findExtensions | ( | $directory = 'extensions' | ) |
Find extensions or skins in a subdirectory of $IP.
Returns an array containing the value for 'Name' for each found extension.
string | $directory | Directory to search in, relative to $IP, must be either "extensions" or "skins" |
Definition at line 1243 of file Installer.php.
Referenced by CliInstaller\__construct().
|
protected |
Find extensions or skins, and return an array containing the value for 'Name' for each found extension.
string | $type | Either "extension" or "skin" |
string | $directory | Directory to search in, relative to $IP |
Definition at line 1263 of file Installer.php.
References $file, $type, and StatusValue\newGood().
Installer::generateKeys | ( | ) |
Generate $wgSecretKey.
Will warn if we had to use an insecure random source.
Definition at line 1699 of file Installer.php.
References $keys.
|
protected |
Auto-detect extensions with an extension.json file.
Load the extensions, register classes with the autoloader and return the merged registry data.
Definition at line 1556 of file Installer.php.
Installer::getAutoExtensionHookContainer | ( | ) |
Get the hook container previously populated by includeExtensions().
Definition at line 1583 of file Installer.php.
|
protected |
Auto-detect extensions with an old style .php registration file, load the extensions, and return the merged $wgHooks array.
Definition at line 1489 of file Installer.php.
Installer::getCompiledDBs | ( | ) |
Get a list of DBs supported by current PHP setup.
Definition at line 612 of file Installer.php.
Installer::getDBInstaller | ( | $type = false | ) |
Get an instance of DatabaseInstaller for the specified DB type.
mixed | $type | DB installer for which is needed, false to use default. |
Definition at line 634 of file Installer.php.
References $type.
Referenced by __construct(), and LocalSettingsGenerator\__construct().
|
static |
Get the DatabaseInstaller class name for this type.
string | $type | database type ($wgDBtype) |
Definition at line 623 of file Installer.php.
References $type.
Referenced by UpdateMediaWiki\execute().
|
static |
Get a list of known DB types.
Definition at line 535 of file Installer.php.
Referenced by WebInstallerDBConnect\execute(), WebInstallerExistingWiki\handleExistingUpgrade(), and DatabaseUpdater\newForDB().
Installer::getDefaultSkin | ( | array | $skinNames | ) |
Returns a default value to be used for $wgDefaultSkin: normally the DefaultSkin from config-schema.yaml, but will fall back to another if the default skin is missing and some other one is present instead.
string[] | $skinNames | Names of installed skins. |
Definition at line 1443 of file Installer.php.
Referenced by CliInstaller\__construct().
|
protected |
Overridden by WebInstaller to provide lastPage parameters.
string | $page |
Reimplemented in WebInstaller.
Definition at line 1230 of file Installer.php.
|
static |
Determine if LocalSettings.php exists.
If it does, return its variables.
Definition at line 654 of file Installer.php.
References $IP, $wgAutoloadClasses, $wgExtensionDirectory, $wgStyleDirectory, wfDetectInstallPath(), and wfDetectLocalSettingsFile().
Referenced by CliInstaller\execute(), and WebInstallerExistingWiki\execute().
|
protected |
string | $type | Either "extension" or "skin" |
string | $parentRelPath | The parent directory relative to $IP |
string | $name | The extension or skin name |
Definition at line 1306 of file Installer.php.
References $path, $type, StatusValue\newFatal(), and StatusValue\newGood().
Installer::getFakePassword | ( | $realPassword | ) |
Get a fake password for sending back to the user in HTML.
This is a security mechanism to avoid compromise of the password in the event of session ID compromise.
string | $realPassword |
Definition at line 720 of file Installer.php.
Referenced by WebInstaller\getPasswordBox().
|
static |
Constructs a Config object that contains configuration settings that should be overwritten for the installation process.
Config | $baseConfig |
Definition at line 374 of file Installer.php.
References $objectCaches, CACHE_ANYTHING, CACHE_DB, CACHE_MEMCACHED, CACHE_NONE, and Config\get().
Referenced by __construct().
|
protected |
Get an array of install steps.
Should always be in the format of [ 'name' => 'someuniquename', 'callback' => [ $obj, 'method' ], ] There must be a config-install-$name message defined per step, which will be shown on install.
DatabaseInstaller | $installer | DatabaseInstaller so we can make callbacks |
Definition at line 1604 of file Installer.php.
Installer::getParserOptions | ( | ) |
Definition at line 796 of file Installer.php.
Installer::getVar | ( | $name, | |
$default = null |
|||
) |
Get an MW configuration variable, or internal installer configuration variable.
The defaults come from MainConfigSchema. Installer variables are typically prefixed by an underscore.
string | $name | |
mixed | null | $default |
Definition at line 603 of file Installer.php.
Referenced by CliInstaller\__construct(), LocalSettingsGenerator\__construct(), CliInstaller\envCheckPath(), WebInstaller\envGetDefaultServer(), CliInstaller\execute(), WebInstaller\execute(), WebInstaller\getCheckBox(), WebInstaller\getPasswordBox(), WebInstaller\getRadioElements(), WebInstaller\getTextArea(), WebInstaller\getTextBox(), and WebInstaller\setupLanguage().
|
protected |
Include the specified extension PHP files.
Populate $wgAutoloadClasses and return the LoadExtensionSchemaUpdates hooks.
string[] | $files |
Definition at line 1513 of file Installer.php.
References $file, $IP, $wgAutoloadClasses, $wgExtensionDirectory, $wgHooks, and $wgStyleDirectory.
|
protected |
Installs the auto-detected extensions.
Definition at line 1457 of file Installer.php.
References StatusValue\newGood().
|
static |
On POSIX systems return the primary group of the webserver we're running under.
On other systems just returns null.
This is used to advice the user that he should chgrp his mw-config/data/images directory as the webserver user before he can install.
Public because SqliteInstaller needs it, and doesn't subclass Installer.
Definition at line 748 of file Installer.php.
|
static |
Override the necessary bits of the config to run an installation.
SettingsBuilder | $settings |
Definition at line 1877 of file Installer.php.
References CACHE_NONE, and MediaWiki\Settings\SettingsBuilder\overrideConfigValues().
Installer::parse | ( | $text, | |
$lineStart = false |
|||
) |
Convert wikitext $text to HTML.
This is potentially error prone since many parser features require a complete installed MW database. The solution is to just not use those features when you write your messages. This appears to work well enough. Basic formatting and external links work just fine.
But in case a translator decides to throw in a "#ifexist" or internal link or whatever, this function is guarded to catch the attempted DB access and to present some fallback text.
string | $text | |
bool | $lineStart |
Definition at line 776 of file Installer.php.
References Parser\stripOuterParagraph().
Referenced by WebInstaller\getCheckBox(), WebInstaller\getHelpBox(), WebInstaller\getInfoBox(), WebInstaller\getRadioElements(), WebInstaller\makeDownloadLinkHtml(), and WebInstaller\showMessage().
Installer::performInstallation | ( | $startCB, | |
$endCB | |||
) |
Actually perform the installation.
callable | $startCB | A callback array for the beginning of each step |
callable | $endCB | A callback array for the end of each step |
Definition at line 1660 of file Installer.php.
Referenced by CliInstaller\execute().
Installer::populateSiteStats | ( | DatabaseInstaller | $installer | ) |
Install step which adds a row to the site_stats table with appropriate initial values.
DatabaseInstaller | $installer |
Definition at line 821 of file Installer.php.
References DatabaseInstaller\getConnection(), and StatusValue\newGood().
Installer::resetMediaWikiServices | ( | Config | $installerConfig = null , |
$serviceOverrides = [] |
|||
) |
Reset the global service container and associated global state to accommodate different stages of the installation.
Config | null | $installerConfig | Config override. If null, the previous config will be inherited. |
array | $serviceOverrides | Service definition overrides. Values can be null to disable specific overrides that would be applied per default, namely 'InterwikiLookup' and 'UserOptionsLookup'. |
Definition at line 471 of file Installer.php.
References $lang, $wgLang, $wgObjectCaches, RequestContext\getMain(), and User\newFromId().
Referenced by __construct().
Installer::restoreLinkPopups | ( | ) |
Definition at line 806 of file Installer.php.
References $wgExternalLinkTarget.
Installer::restoreServices | ( | ) |
Restore services that have been redefined in the early stage of installation.
Definition at line 1712 of file Installer.php.
References StatusValue\newGood().
Installer::setParserLanguage | ( | $lang | ) |
ParserOptions are constructed before we determined the language, so fix it.
Language | $lang |
Definition at line 1220 of file Installer.php.
References $lang.
Installer::setPassword | ( | $name, | |
$value | |||
) |
Set a variable which stores a password, except if the new value is a fake password in which case leave it as it is.
string | $name | |
mixed | $value |
Definition at line 731 of file Installer.php.
Referenced by WebInstaller\setVarsFromRequest().
Installer::setVar | ( | $name, | |
$value | |||
) |
Set a MW configuration variable, or internal installer configuration variable.
string | $name | |
mixed | $value |
Definition at line 589 of file Installer.php.
Referenced by CliInstaller\__construct(), WebInstaller\envPrepPath(), CliInstaller\execute(), WebInstaller\setupLanguage(), and WebInstaller\setVarsFromRequest().
|
abstract |
Same as showMessage(), but for displaying errors.
string | $msg | |
mixed | ...$params |
Reimplemented in WebInstaller, and CliInstaller.
|
abstract |
UI interface for displaying a short message The parameters are like parameters to wfMessage().
The messages will be in wikitext format, which will be converted to an output format such as HTML or text before being sent to the user.
string | $msg | |
mixed | ...$params |
Reimplemented in WebInstaller, and CliInstaller.
|
abstract |
Show a message to the installing user by using a Status object.
Status | $status |
Reimplemented in WebInstaller, and CliInstaller.
|
protected |
Definition at line 339 of file Installer.php.
|
protected |
List of detected DBs, access using getCompiledDBs().
Definition at line 84 of file Installer.php.
|
protected |
Cached DB installer instances, access using getDBInstaller().
Definition at line 91 of file Installer.php.
|
staticprotected |
Known database types.
These correspond to the class names <type>Installer, and are also MediaWiki database types valid for $wgDBtype.
To add a new type, create a <type>Installer class and a Database<type> class, and add a config-type-<type> message to MessagesEn.php.
Definition at line 123 of file Installer.php.
|
protected |
A list of environment check methods called by doEnvironmentChecks().
These may output warnings using showMessage(), and/or abort the installation process by returning false.
For the WebInstaller these are only called on the Welcome page, if these methods have side-effects that should affect later page loads (as well as the generated stylesheet), use envPreps instead.
Definition at line 140 of file Installer.php.
|
protected |
A list of environment preparation methods called by doEnvironmentPreps().
Definition at line 161 of file Installer.php.
|
protected |
Extra steps for installation, for things like DatabaseInstallers to modify.
Definition at line 260 of file Installer.php.
|
protected |
Variables that are stored alongside globals, and are used for any configuration of the installation process aside from the MediaWiki configuration.
Map of names to defaults.
Definition at line 209 of file Installer.php.
array Installer::$licenses |
License types.
Definition at line 302 of file Installer.php.
|
protected |
Minimum memory size in MiB.
Definition at line 98 of file Installer.php.
|
protected |
Known object cache types and the functions used to test for their existence.
Definition at line 267 of file Installer.php.
Referenced by getInstallerConfig().
|
protected |
Cached ParserOptions, used by parse().
Definition at line 112 of file Installer.php.
|
protected |
Cached Title, used by parse().
Definition at line 105 of file Installer.php.
array Installer::$rightsProfiles |
User rights profiles.
Definition at line 277 of file Installer.php.
|
protected |
Definition at line 77 of file Installer.php.
Referenced by WebInstaller\execute(), and WebInstaller\finish().
const Installer::MINIMUM_PCRE_VERSION = '7.2' |
The oldest version of PCRE we can support.
Defining this is necessary because PHP may be linked with a system version of PCRE, which may be older than that bundled with the minimum PHP version.
Definition at line 66 of file Installer.php.