40 private $specifiedScriptPath =
false;
42 private $optionMap = [
43 'dbtype' =>
'wgDBtype',
44 'dbserver' =>
'wgDBserver',
45 'dbname' =>
'wgDBname',
46 'dbuser' =>
'wgDBuser',
47 'dbpass' =>
'wgDBpassword',
48 'dbprefix' =>
'wgDBprefix',
49 'dbtableoptions' =>
'wgDBTableOptions',
50 'dbport' =>
'wgDBport',
52 'dbschema' =>
'wgDBmwschema',
53 'dbpath' =>
'wgSQLiteDataDir',
54 'server' =>
'wgServer',
55 'scriptpath' =>
'wgScriptPath',
64 public function __construct( $siteName, $admin =
null, array $options = [] ) {
67 parent::__construct();
69 if ( isset( $options[
'scriptpath'] ) ) {
70 $this->specifiedScriptPath =
true;
73 foreach ( $this->optionMap as $opt => $global ) {
74 if ( isset( $options[$opt] ) ) {
75 $GLOBALS[$global] = $options[$opt];
76 $this->
setVar( $global, $options[$opt] );
80 if ( isset( $options[
'lang'] ) ) {
82 $this->
setVar(
'_UserLang', $options[
'lang'] );
84 $this->
setVar(
'wgLanguageCode', $wgLanguageCode );
86 ->getLanguage( $options[
'lang'] );
87 RequestContext::getMain()->setLanguage(
$wgLang );
90 $this->
setVar(
'wgSitename', $siteName );
93 $metaNS = $contLang->ucfirst( str_replace(
' ',
'_', $siteName ) );
94 if ( $metaNS ==
'MediaWiki' ) {
97 $this->
setVar(
'wgMetaNamespace', $metaNS );
99 if ( !isset( $options[
'installdbuser'] ) ) {
100 $this->
setVar(
'_InstallUser',
101 $this->
getVar(
'wgDBuser' ) );
102 $this->
setVar(
'_InstallPassword',
103 $this->
getVar(
'wgDBpassword' ) );
105 $this->
setVar(
'_InstallUser',
106 $options[
'installdbuser'] );
107 $this->
setVar(
'_InstallPassword',
108 $options[
'installdbpass'] ??
"" );
111 $this->
setVar(
'_CreateDBAccount',
true );
115 $this->
setVar(
'_AdminName', $admin );
116 if ( isset( $options[
'pass'] ) ) {
117 $adminUser = User::newFromName( $admin );
119 throw new InstallException( Status::newFatal(
'config-admin-name-invalid' ) );
125 $status = $upp->checkUserPasswordForGroups( $adminUser, $options[
'pass'],
126 [
'bureaucrat',
'sysop',
'interface-admin' ] );
127 if ( !$status->isGood() ) {
129 $status->getMessage(
'config-admin-error-password-invalid' ) ) );
131 $this->
setVar(
'_AdminPassword', $options[
'pass'] );
136 if ( isset( $options[
'extensions'] ) ) {
137 $status = $this->validateExtensions(
138 'extension',
'extensions', $options[
'extensions'] );
139 if ( !$status->isOK() ) {
142 $this->
setVar(
'_Extensions', $status->value );
143 } elseif ( isset( $options[
'with-extensions'] ) ) {
145 if ( !$status->isOK() ) {
148 $this->
setVar(
'_Extensions', array_keys( $status->value ) );
152 if ( isset( $options[
'skins'] ) ) {
153 $status = $this->validateExtensions(
'skin',
'skins', $options[
'skins'] );
154 if ( !$status->isOK() ) {
157 $skins = $status->value;
160 if ( !$status->isOK() ) {
163 $skins = array_keys( $status->value );
165 $this->
setVar(
'_Skins', $skins );
168 $skinNames = array_map(
'strtolower', $skins );
172 $this->
setVar(
'_WithDevelopmentSettings', isset( $options[
'with-developmentsettings'] ) );
175 private function validateExtensions( $type, $directory, $nameLists ) {
178 foreach ( (array)$nameLists as $nameList ) {
179 foreach ( explode(
',', $nameList ) as $name ) {
180 $name = trim( $name );
181 if ( $name ===
'' ) {
185 if ( $extStatus->isOK() ) {
186 $extensions[] = $name;
188 $status->merge( $extStatus );
192 $extensions = array_unique( $extensions );
193 $status->value = $extensions;
206 if ( count( $this->
getVar(
'_Caches' ) ) ) {
208 $this->
setVar(
'_MainCacheType',
'accel' );
213 $status = Status::newFatal(
"config-localsettings-cli-upgrade" );
219 [ $this,
'startStage' ],
220 [ $this,
'endStage' ]
224 $lastStepStatus = end( $result );
225 if ( $lastStepStatus->isOK() ) {
226 return Status::newGood();
228 return $lastStepStatus;
239 $ls->writeFile(
"$path/LocalSettings.php" );
251 if ( $status->isOK() ) {
254 $this->
showError(
'config-install-step-failed' );
266 echo
"***{$this->getMessageText( $msg, $params )}***\n";
278 $text = preg_replace(
'/<a href="(.*?)".*?>(.*?)<\/a>/',
'$2 <$1>', $text );
280 return Sanitizer::stripAllTags( $text );
295 if ( count( $warnings ) !== 0 ) {
296 foreach ( $warnings as $w ) {
303 if ( !$this->specifiedScriptPath ) {
307 return parent::envCheckPath();
312 return 'http://localhost';
316 $this->
showMessage(
'config-no-cli-uploads-check', $dir );
wfMessage( $key,... $params)
This is the function for getting translated interface messages.
if(!defined( 'MW_NO_SESSION') &&MW_ENTRY_POINT !=='cli' $wgLang
array $params
The job parameters.
Group all the pieces relevant to the context of a request into one instance.
Check if a user's password complies with any password policies that apply to that user,...
$wgLanguageCode
Config variable stub for the LanguageCode setting, for use by phpdoc and IDEs.
$wgPasswordPolicy
Config variable stub for the PasswordPolicy setting, for use by phpdoc and IDEs.