MediaWiki  1.23.8
CliInstaller.php
Go to the documentation of this file.
1 <?php
30 class CliInstaller extends Installer {
31  private $specifiedScriptPath = false;
32 
33  private $optionMap = array(
34  'dbtype' => 'wgDBtype',
35  'dbserver' => 'wgDBserver',
36  'dbname' => 'wgDBname',
37  'dbuser' => 'wgDBuser',
38  'dbpass' => 'wgDBpassword',
39  'dbprefix' => 'wgDBprefix',
40  'dbtableoptions' => 'wgDBTableOptions',
41  'dbmysql5' => 'wgDBmysql5',
42  'dbport' => 'wgDBport',
43  'dbschema' => 'wgDBmwschema',
44  'dbpath' => 'wgSQLiteDataDir',
45  'server' => 'wgServer',
46  'scriptpath' => 'wgScriptPath',
47  );
48 
56  function __construct( $siteName, $admin = null, array $option = array() ) {
58 
59  parent::__construct();
60 
61  if ( isset( $option['scriptpath'] ) ) {
62  $this->specifiedScriptPath = true;
63  }
64 
65  foreach ( $this->optionMap as $opt => $global ) {
66  if ( isset( $option[$opt] ) ) {
67  $GLOBALS[$global] = $option[$opt];
68  $this->setVar( $global, $option[$opt] );
69  }
70  }
71 
72  if ( isset( $option['lang'] ) ) {
73  global $wgLang, $wgLanguageCode;
74  $this->setVar( '_UserLang', $option['lang'] );
75  $wgContLang = Language::factory( $option['lang'] );
76  $wgLang = Language::factory( $option['lang'] );
77  $wgLanguageCode = $option['lang'];
78  }
79 
80  $this->setVar( 'wgSitename', $siteName );
81 
82  $metaNS = $wgContLang->ucfirst( str_replace( ' ', '_', $siteName ) );
83  if ( $metaNS == 'MediaWiki' ) {
84  $metaNS = 'Project';
85  }
86  $this->setVar( 'wgMetaNamespace', $metaNS );
87 
88  if ( $admin ) {
89  $this->setVar( '_AdminName', $admin );
90  }
91 
92  if ( !isset( $option['installdbuser'] ) ) {
93  $this->setVar( '_InstallUser',
94  $this->getVar( 'wgDBuser' ) );
95  $this->setVar( '_InstallPassword',
96  $this->getVar( 'wgDBpassword' ) );
97  } else {
98  $this->setVar( '_InstallUser',
99  $option['installdbuser'] );
100  $this->setVar( '_InstallPassword',
101  isset( $option['installdbpass'] ) ? $option['installdbpass'] : "" );
102 
103  // Assume that if we're given the installer user, we'll create the account.
104  $this->setVar( '_CreateDBAccount', true );
105  }
106 
107  if ( isset( $option['pass'] ) ) {
108  $this->setVar( '_AdminPassword', $option['pass'] );
109  }
110  }
111 
115  public function execute() {
117  if ( $vars ) {
118  $this->showStatusMessage(
119  Status::newFatal( "config-localsettings-cli-upgrade" )
120  );
121  }
122 
123  $this->performInstallation(
124  array( $this, 'startStage' ),
125  array( $this, 'endStage' )
126  );
127  }
128 
134  public function writeConfigurationFile( $path ) {
136  $ls->writeFile( "$path/LocalSettings.php" );
137  }
138 
139  public function startStage( $step ) {
140  // Messages: config-install-database, config-install-tables, config-install-interwiki,
141  // config-install-stats, config-install-keys, config-install-sysop, config-install-mainpage
142  $this->showMessage( "config-install-$step" );
143  }
144 
145  public function endStage( $step, $status ) {
146  $this->showStatusMessage( $status );
147  $this->showMessage( 'config-install-step-done' );
148  }
149 
150  public function showMessage( $msg /*, ... */ ) {
151  echo $this->getMessageText( func_get_args() ) . "\n";
152  flush();
153  }
154 
155  public function showError( $msg /*, ... */ ) {
156  echo "***{$this->getMessageText( func_get_args() )}***\n";
157  flush();
158  }
159 
165  protected function getMessageText( $params ) {
166  $msg = array_shift( $params );
167 
168  $text = wfMessage( $msg, $params )->parse();
169 
170  $text = preg_replace( '/<a href="(.*?)".*?>(.*?)<\/a>/', '$2 &lt;$1&gt;', $text );
171 
172  return html_entity_decode( strip_tags( $text ), ENT_QUOTES );
173  }
174 
178  public function showHelpBox( $msg /*, ... */ ) {
179  }
180 
181  public function showStatusMessage( Status $status ) {
182  $warnings = array_merge( $status->getWarningsArray(),
183  $status->getErrorsArray() );
184 
185  if ( count( $warnings ) !== 0 ) {
186  foreach ( $warnings as $w ) {
187  call_user_func_array( array( $this, 'showMessage' ), $w );
188  }
189  }
190 
191  if ( !$status->isOk() ) {
192  echo "\n";
193  exit( 1 );
194  }
195  }
196 
197  public function envCheckPath() {
198  if ( !$this->specifiedScriptPath ) {
199  $this->showMessage( 'config-no-cli-uri', $this->getVar( "wgScriptPath" ) );
200  }
201 
202  return parent::envCheckPath();
203  }
204 
205  protected function envGetDefaultServer() {
206  return null; // Do not guess if installing from CLI
207  }
208 
209  public function dirIsExecutable( $dir, $url ) {
210  $this->showMessage( 'config-no-cli-uploads-check', $dir );
211 
212  return false;
213  }
214 }
Installer\__construct
__construct()
Constructor, always call this from child classes.
Definition: Installer.php:337
php
skin txt MediaWiki includes four core it has been set as the default in MediaWiki since the replacing Monobook it had been been the default skin since before being replaced by Vector largely rewritten in while keeping its appearance Several legacy skins were removed in the as the burden of supporting them became too heavy to bear Those in etc for skin dependent CSS etc for skin dependent JavaScript These can also be customised on a per user by etc This feature has led to a wide variety of user styles becoming that gallery is a good place to ending in php
Definition: skin.txt:62
Installer\showMessage
showMessage( $msg)
UI interface for displaying a short message The parameters are like parameters to wfMessage().
Installer\showStatusMessage
showStatusMessage(Status $status)
Show a message to the installing user by using a Status object.
Installer\dirIsExecutable
dirIsExecutable( $dir, $url)
Checks if scripts located in the given directory can be executed via the given URL.
Definition: Installer.php:1307
$params
$params
Definition: styleTest.css.php:40
Installer\performInstallation
performInstallation( $startCB, $endCB)
Actually perform the installation.
Definition: Installer.php:1519
$wgContLang
this class mediates it Skin Encapsulates a look and feel for the wiki All of the functions that render HTML and make choices about how to render it are here and are called from various other places when and is meant to be subclassed with other skins that may override some of its functions The User object contains a reference to a and so rather than having a global skin object we just rely on the global User and get the skin with $wgUser and also has some character encoding functions and other locale stuff The current user interface language is instantiated as and the content language as $wgContLang
Definition: design.txt:56
Installer\envGetDefaultServer
envGetDefaultServer()
Helper function to be called from envCheckServer()
Installer\setVar
setVar( $name, $value)
Set a MW configuration variable, or internal installer configuration variable.
Definition: Installer.php:443
Status
Generic operation result class Has warning/error list, boolean status and arbitrary value.
Definition: Status.php:40
Installer\showError
showError( $msg)
Same as showMessage(), but for displaying errors.
wfMessage
null means default in associative array with keys and values unescaped Should be merged with default with a value of false meaning to suppress the attribute in associative array with keys and values unescaped noclasses just before the function returns a value If you return an< a > element with HTML attributes $attribs and contents $html will be returned If you return $ret will be returned and may include noclasses after processing after in associative array form externallinks including delete and has completed for all link tables default is conds Array Extra conditions for the No matching items in log is displayed if loglist is empty msgKey Array If you want a nice box with a set this to the key of the message First element is the message additional optional elements are parameters for the key that are processed with wfMessage() -> params() ->parseAsBlock() - offset Set to overwrite offset parameter in $wgRequest set to '' to unset offset - wrap String Wrap the message in html(usually something like "&lt
Installer\getExistingLocalSettings
static getExistingLocalSettings()
Determine if LocalSettings.php exists.
Definition: Installer.php:501
Installer\envCheckPath
envCheckPath()
Environment check for setting $IP and $wgScriptPath.
Definition: Installer.php:976
array
the array() calling protocol came about after MediaWiki 1.4rc1.
List of Api Query prop modules.
InstallerOverrides\getLocalSettingsGenerator
static getLocalSettingsGenerator(Installer $installer)
Instantiates and returns an instance of LocalSettingsGenerator or its descendant classes.
Definition: overrides.php:57
global
when a variable name is used in a it is silently declared as a new masking the global
Definition: design.txt:93
Installer\getVar
getVar( $name, $default=null)
Get an MW configuration variable, or internal installer configuration variable.
Definition: Installer.php:457
execute
$batch execute()
$wgLang
this class mediates it Skin Encapsulates a look and feel for the wiki All of the functions that render HTML and make choices about how to render it are here and are called from various other places when and is meant to be subclassed with other skins that may override some of its functions The User object contains a reference to a and so rather than having a global skin object we just rely on the global User and get the skin with $wgUser and also has some character encoding functions and other locale stuff The current user interface language is instantiated as $wgLang
Definition: design.txt:56
$dir
if(count( $args)==0) $dir
Definition: importImages.php:49
Status\getWarningsArray
getWarningsArray()
Get the list of warnings (but not errors)
Definition: Status.php:351
$path
$path
Definition: NoLocalSettings.php:35
as
This document is intended to provide useful advice for parties seeking to redistribute MediaWiki to end users It s targeted particularly at maintainers for Linux since it s been observed that distribution packages of MediaWiki often break We ve consistently had to recommend that users seeking support use official tarballs instead of their distribution s and this often solves whatever problem the user is having It would be nice if this could such as
Definition: distributors.txt:9
Installer
Base installer class.
Definition: Installer.php:39
Language\factory
static factory( $code)
Get a cached or new language object for a given language code.
Definition: Language.php:184
$vars
static configuration should be added through ResourceLoaderGetConfigVars instead & $vars
Definition: hooks.txt:1679
Status\getErrorsArray
getErrorsArray()
Get the list of errors (but not warnings)
Definition: Status.php:341
$GLOBALS
$GLOBALS['IP']
Definition: ComposerHookHandler.php:6
Status\newFatal
static newFatal( $message)
Factory function for fatal errors.
Definition: Status.php:63