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 public 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 = MediaWikiServices::getInstance()->getLanguageFactory()
80 ->getLanguage( $options[
'lang'] );
81 RequestContext::getMain()->setLanguage(
$wgLang );
84 $this->
setVar(
'wgSitename', $siteName );
86 $metaNS =
$wgContLang->ucfirst( str_replace(
' ',
'_', $siteName ) );
87 if ( $metaNS ==
'MediaWiki' ) {
90 $this->
setVar(
'wgMetaNamespace', $metaNS );
92 if ( !isset( $options[
'installdbuser'] ) ) {
93 $this->
setVar(
'_InstallUser',
94 $this->
getVar(
'wgDBuser' ) );
95 $this->
setVar(
'_InstallPassword',
96 $this->
getVar(
'wgDBpassword' ) );
98 $this->
setVar(
'_InstallUser',
99 $options[
'installdbuser'] );
100 $this->
setVar(
'_InstallPassword',
101 $options[
'installdbpass'] ??
"" );
104 $this->
setVar(
'_CreateDBAccount',
true );
108 $this->
setVar(
'_AdminName', $admin );
109 if ( isset( $options[
'pass'] ) ) {
110 $adminUser = User::newFromName( $admin );
112 throw new InstallException( Status::newFatal(
'config-admin-name-invalid' ) );
118 $status = $upp->checkUserPasswordForGroups( $adminUser, $options[
'pass'],
119 [
'bureaucrat',
'sysop',
'interface-admin' ] );
120 if ( !$status->isGood() ) {
122 $status->getMessage(
'config-admin-error-password-invalid' ) ) );
124 $this->
setVar(
'_AdminPassword', $options[
'pass'] );
129 if ( isset( $options[
'extensions'] ) ) {
131 'extension',
'extensions', $options[
'extensions'] );
132 if ( !$status->isOK() ) {
135 $this->
setVar(
'_Extensions', $status->value );
136 } elseif ( isset( $options[
'with-extensions'] ) ) {
138 if ( !$status->isOK() ) {
141 $this->
setVar(
'_Extensions', array_keys( $status->value ) );
145 if ( isset( $options[
'skins'] ) ) {
147 if ( !$status->isOK() ) {
150 $skins = $status->value;
153 if ( !$status->isOK() ) {
156 $skins = array_keys( $status->value );
158 $this->
setVar(
'_Skins', $skins );
161 $skinNames = array_map(
'strtolower', $skins );
169 foreach ( (array)$nameLists as $nameList ) {
170 foreach ( explode(
',', $nameList ) as $name ) {
171 $name = trim( $name );
172 if ( $name ===
'' ) {
176 if ( $extStatus->isOK() ) {
177 $extensions[] = $name;
179 $status->merge( $extStatus );
183 $extensions = array_unique( $extensions );
184 $status->value = $extensions;
197 if ( count( $this->
getVar(
'_Caches' ) ) ) {
199 $this->
setVar(
'_MainCacheType',
'accel' );
204 $status = Status::newFatal(
"config-localsettings-cli-upgrade" );
210 [ $this,
'startStage' ],
211 [ $this,
'endStage' ]
215 $lastStepStatus = end( $result );
216 if ( $lastStepStatus->isOK() ) {
217 return Status::newGood();
219 return $lastStepStatus;
230 $ls->writeFile(
"$path/LocalSettings.php" );
251 echo
"***{$this->getMessageText( $msg, $params )}***\n";
262 $text =
wfMessage( $msg, $params )->parse();
264 $text = preg_replace(
'/<a href="(.*?)".*?>(.*?)<\/a>/',
'$2 <$1>', $text );
266 return Sanitizer::stripAllTags( $text );
281 if ( count( $warnings ) !== 0 ) {
282 foreach ( $warnings as $w ) {
289 if ( !$this->specifiedScriptPath ) {
293 return parent::envCheckPath();
298 return 'http://localhost';
302 $this->
showMessage(
'config-no-cli-uploads-check', $dir );
$wgLanguageCode
Site language code.
$wgPasswordPolicy
Password policy for the wiki.
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().
showHelpBox( $msg,... $params)
Dummy.
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)
Check if a user's password complies with any password policies that apply to that user,...