37 'dbtype' =>
'wgDBtype',
38 'dbserver' =>
'wgDBserver',
39 'dbname' =>
'wgDBname',
40 'dbuser' =>
'wgDBuser',
41 'dbpass' =>
'wgDBpassword',
42 'dbprefix' =>
'wgDBprefix',
43 'dbtableoptions' =>
'wgDBTableOptions',
44 'dbport' =>
'wgDBport',
45 'dbschema' =>
'wgDBmwschema',
46 'dbpath' =>
'wgSQLiteDataDir',
47 'server' =>
'wgServer',
48 'scriptpath' =>
'wgScriptPath',
57 function __construct( $siteName, $admin =
null, array $options = [] ) {
60 parent::__construct();
62 if ( isset( $options[
'scriptpath'] ) ) {
63 $this->specifiedScriptPath =
true;
66 foreach ( $this->optionMap as $opt => $global ) {
67 if ( isset( $options[$opt] ) ) {
69 $this->
setVar( $global, $options[$opt] );
73 if ( isset( $options[
'lang'] ) ) {
75 $this->
setVar(
'_UserLang', $options[
'lang'] );
77 $this->
setVar(
'wgLanguageCode', $wgLanguageCode );
78 $wgContLang = MediaWikiServices::getInstance()->getContentLanguage();
79 $wgLang = Language::factory( $options[
'lang'] );
80 RequestContext::getMain()->setLanguage(
$wgLang );
83 $this->
setVar(
'wgSitename', $siteName );
85 $metaNS =
$wgContLang->ucfirst( str_replace(
' ',
'_', $siteName ) );
86 if ( $metaNS ==
'MediaWiki' ) {
89 $this->
setVar(
'wgMetaNamespace', $metaNS );
92 $this->
setVar(
'_AdminName', $admin );
95 if ( !isset( $options[
'installdbuser'] ) ) {
96 $this->
setVar(
'_InstallUser',
97 $this->
getVar(
'wgDBuser' ) );
98 $this->
setVar(
'_InstallPassword',
99 $this->
getVar(
'wgDBpassword' ) );
101 $this->
setVar(
'_InstallUser',
102 $options[
'installdbuser'] );
103 $this->
setVar(
'_InstallPassword',
104 $options[
'installdbpass'] ??
"" );
107 $this->
setVar(
'_CreateDBAccount',
true );
110 if ( isset( $options[
'pass'] ) ) {
111 $this->
setVar(
'_AdminPassword', $options[
'pass'] );
115 if ( isset( $options[
'extensions'] ) ) {
117 'extension',
'extensions', $options[
'extensions'] );
118 if ( !$status->isOK() ) {
121 $this->
setVar(
'_Extensions', $status->value );
122 } elseif ( isset( $options[
'with-extensions'] ) ) {
124 if ( !$status->isOK() ) {
127 $this->
setVar(
'_Extensions', array_keys( $status->value ) );
131 if ( isset( $options[
'skins'] ) ) {
133 if ( !$status->isOK() ) {
136 $skins = $status->value;
139 if ( !$status->isOK() ) {
142 $skins = array_keys( $status->value );
144 $this->
setVar(
'_Skins', $skins );
147 $skinNames = array_map(
'strtolower', $skins );
155 foreach ( (array)$nameLists as $nameList ) {
156 foreach ( explode(
',', $nameList ) as $name ) {
157 $name = trim( $name );
158 if ( $name ===
'' ) {
162 if ( $extStatus->isOK() ) {
163 $extensions[] = $name;
165 $status->merge( $extStatus );
169 $extensions = array_unique( $extensions );
170 $status->value = $extensions;
182 if ( count( $this->
getVar(
'_Caches' ) ) ) {
184 $this->
setVar(
'_MainCacheType',
'accel' );
189 $status = Status::newFatal(
"config-localsettings-cli-upgrade" );
195 [ $this,
'startStage' ],
196 [ $this,
'endStage' ]
200 $lastStepStatus = end( $result );
201 if ( $lastStepStatus->isOK() ) {
202 return Status::newGood();
204 return $lastStepStatus;
215 $ls->writeFile(
"$path/LocalSettings.php" );
236 echo
"***{$this->getMessageText( $msg, $params )}***\n";
247 $text =
wfMessage( $msg, $params )->parse();
249 $text = preg_replace(
'/<a href="(.*?)".*?>(.*?)<\/a>/',
'$2 <$1>', $text );
251 return Sanitizer::stripAllTags( $text );
264 if ( count( $warnings ) !== 0 ) {
265 foreach ( $warnings as $w ) {
272 if ( !$this->specifiedScriptPath ) {
276 return parent::envCheckPath();
281 return 'http://localhost';
285 $this->
showMessage(
'config-no-cli-uploads-check', $dir );
$wgLanguageCode
Site language code.
wfMessage( $key,... $params)
This is the function for getting translated interface messages.
Class for the core installer command line interface.
showMessage( $msg,... $params)
UI interface for displaying a short message The parameters are like parameters to wfMessage().
execute()
Main entry point.
__construct( $siteName, $admin=null, array $options=[])
getMessageText( $msg, $params)
showStatusMessage(Status $status)
Show a message to the installing user by using a Status object.
writeConfigurationFile( $path)
Write LocalSettings.php to a given path.
validateExtensions( $type, $directory, $nameLists)
dirIsExecutable( $dir, $url)
Checks if scripts located in the given directory can be executed via the given URL.
showError( $msg,... $params)
Same as showMessage(), but for displaying errors.
envGetDefaultServer()
Helper function to be called from envPrepServer()
envCheckPath()
Environment check to inform user which paths we've assumed.
endStage( $step, $status)
static getLocalSettingsGenerator(Installer $installer)
Instantiates and returns an instance of LocalSettingsGenerator or its descendant classes.
getExtensionInfo( $type, $parentRelPath, $name)
getDefaultSkin(array $skinNames)
Returns a default value to be used for $wgDefaultSkin: normally the one set in DefaultSettings,...
setVar( $name, $value)
Set a MW configuration variable, or internal installer configuration variable.
static getExistingLocalSettings()
Determine if LocalSettings.php exists.
performInstallation( $startCB, $endCB)
Actually perform the installation.
getVar( $name, $default=null)
Get an MW configuration variable, or internal installer configuration variable.
findExtensions( $directory='extensions')
Find extensions or skins in a subdirectory of $IP.
Generic operation result class Has warning/error list, boolean status and arbitrary value.
getErrorsArray()
Get the list of errors (but not warnings)
getWarningsArray()
Get the list of warnings (but not errors)