Go to the documentation of this file.
43 '_MysqlEngine' =>
'InnoDB',
44 '_MysqlCharset' =>
'binary',
45 '_InstallUser' =>
'root',
57 'CREATE TEMPORARY TABLES',
82 $this->parent->getHelpBox(
'config-db-host-help' )
86 $this->
getTextBox(
'wgDBname',
'config-db-name',
array(
'dir' =>
'ltr' ),
87 $this->parent->getHelpBox(
'config-db-name-help' ) ) .
88 $this->
getTextBox(
'wgDBprefix',
'config-db-prefix',
array(
'dir' =>
'ltr' ),
89 $this->parent->getHelpBox(
'config-db-prefix-help' ) ) .
97 'wgDBserver',
'wgDBname',
'wgDBprefix',
'_InstallUser',
'_InstallPassword'
102 if ( !strlen( $newValues[
'wgDBserver'] ) ) {
103 $status->fatal(
'config-missing-db-host' );
105 if ( !strlen( $newValues[
'wgDBname'] ) ) {
106 $status->fatal(
'config-missing-db-name' );
107 } elseif ( !preg_match(
'/^[a-z0-9+_-]+$/i', $newValues[
'wgDBname'] ) ) {
108 $status->fatal(
'config-invalid-db-name', $newValues[
'wgDBname'] );
110 if ( !preg_match(
'/^[a-z0-9_-]*$/i', $newValues[
'wgDBprefix'] ) ) {
111 $status->fatal(
'config-invalid-db-prefix', $newValues[
'wgDBprefix'] );
113 if ( !strlen( $newValues[
'_InstallUser'] ) ) {
114 $status->fatal(
'config-db-username-empty' );
116 if (!strlen( $newValues[
'_InstallPassword'] ) ) {
117 $status->fatal(
'config-db-password-empty', $newValues[
'_InstallUser'] );
119 if ( !$status->isOK() ) {
125 if ( !$status->isOK() ) {
131 if ( !$status->isOK() ) {
137 $conn = $status->value;
140 $version = $conn->getServerVersion();
141 if ( version_compare(
$version, $this->minimumVersion ) < 0 ) {
155 'host' => $this->
getVar(
'wgDBserver' ),
156 'user' => $this->
getVar(
'_InstallUser' ),
157 'password' => $this->
getVar(
'_InstallPassword' ),
160 'tablePrefix' => $this->
getVar(
'wgDBprefix' ) ) );
161 $status->value =
$db;
163 $status->fatal(
'config-connection-error',
$e->getMessage() );
170 global $wgDBuser, $wgDBpassword;
173 if ( !$status->isOK() ) {
174 $this->parent->showStatusError( $status );
181 $conn = $status->value;
182 $conn->selectDB( $this->
getVar(
'wgDBname' ) );
184 # Determine existing default character set
185 if ( $conn->tableExists(
"revision", __METHOD__ ) ) {
186 $revision = $conn->buildLike( $this->
getVar(
'wgDBprefix' ) .
'revision' );
187 $res = $conn->query(
"SHOW TABLE STATUS $revision", __METHOD__ );
188 $row = $conn->fetchObject(
$res );
190 $this->parent->showMessage(
'config-show-table-status' );
191 $existingSchema =
false;
192 $existingEngine =
false;
194 if ( preg_match(
'/^latin1/', $row->Collation ) ) {
195 $existingSchema =
'latin1';
196 } elseif ( preg_match(
'/^utf8/', $row->Collation ) ) {
197 $existingSchema =
'utf8';
198 } elseif ( preg_match(
'/^binary/', $row->Collation ) ) {
199 $existingSchema =
'binary';
201 $existingSchema =
false;
202 $this->parent->showMessage(
'config-unknown-collation' );
204 if ( isset( $row->Engine ) ) {
205 $existingEngine = $row->Engine;
207 $existingEngine = $row->Type;
211 $existingSchema =
false;
212 $existingEngine =
false;
215 if ( $existingSchema && $existingSchema != $this->
getVar(
'_MysqlCharset' ) ) {
216 $this->
setVar(
'_MysqlCharset', $existingSchema );
218 if ( $existingEngine && $existingEngine != $this->
getVar(
'_MysqlEngine' ) ) {
219 $this->
setVar(
'_MysqlEngine', $existingEngine );
222 # Normal user and password are selected after this step, so for now
223 # just copy these two
224 $wgDBuser = $this->
getVar(
'_InstallUser' );
225 $wgDBpassword = $this->
getVar(
'_InstallPassword' );
239 $conn = $status->value;
242 $res = $conn->query(
'SHOW ENGINES', __METHOD__ );
243 foreach (
$res as $row ) {
244 if ( $row->Support ==
'YES' || $row->Support ==
'DEFAULT' ) {
245 $engines[] = $row->Engine;
248 $engines = array_intersect( $this->supportedEngines, $engines );
259 return array(
'binary',
'utf8' );
269 if ( !$status->isOK() ) {
273 $conn = $status->value;
276 $currentName = $conn->selectField(
'',
'CURRENT_USER()',
'', __METHOD__ );
277 $parts = explode(
'@', $currentName );
278 if ( count( $parts ) != 2 ) {
281 $quotedUser = $conn->addQuotes( $parts[0] ) .
282 '@' . $conn->addQuotes( $parts[1] );
286 $res = $conn->select(
'INFORMATION_SCHEMA.USER_PRIVILEGES',
'*',
287 array(
'GRANTEE' => $quotedUser ), __METHOD__ );
288 $insertMysql =
false;
289 $grantOptions = array_flip( $this->webUserPrivs );
290 foreach (
$res as $row ) {
291 if ( $row->PRIVILEGE_TYPE ==
'INSERT' ) {
294 if ( $row->IS_GRANTABLE ) {
295 unset( $grantOptions[$row->PRIVILEGE_TYPE] );
300 if ( !$insertMysql ) {
301 $row = $conn->selectRow(
'INFORMATION_SCHEMA.SCHEMA_PRIVILEGES',
'*',
303 'GRANTEE' => $quotedUser,
304 'TABLE_SCHEMA' =>
'mysql',
305 'PRIVILEGE_TYPE' =>
'INSERT',
312 if ( !$insertMysql ) {
317 $res = $conn->select(
'INFORMATION_SCHEMA.SCHEMA_PRIVILEGES',
'*',
319 'GRANTEE' => $quotedUser,
322 foreach (
$res as $row ) {
323 $regex = $conn->likeToRegex( $row->TABLE_SCHEMA );
324 if ( preg_match( $regex, $this->
getVar(
'wgDBname' ) ) ) {
325 unset( $grantOptions[$row->PRIVILEGE_TYPE] );
328 if ( count( $grantOptions ) ) {
341 $noCreateMsg =
false;
343 $noCreateMsg =
'config-db-web-no-create-privs';
350 if ( !in_array( $this->
getVar(
'_MysqlEngine' ), $engines ) ) {
351 $this->
setVar(
'_MysqlEngine', reset( $engines ) );
355 'id' =>
'dbMyisamWarning'
357 $myisamWarning =
'config-mysql-myisam-dep';
358 if ( count( $engines ) === 1 ) {
359 $myisamWarning =
'config-mysql-only-myisam-dep';
361 $s .= $this->parent->getWarningBox(
wfMessage( $myisamWarning )->
text() );
364 if ( $this->
getVar(
'_MysqlEngine' ) !=
'MyISAM' ) {
366 $s .=
'$(\'#dbMyisamWarning\').hide();';
370 if ( count( $engines ) >= 2 ) {
375 'var' =>
'_MysqlEngine',
376 'label' =>
'config-mysql-engine',
377 'itemLabelPrefix' =>
'config-mysql-',
378 'values' => $engines,
379 'itemAttribs' =>
array(
381 'class' =>
'showHideRadio',
382 'rel' =>
'dbMyisamWarning'
385 'class' =>
'hideShowRadio',
386 'rel' =>
'dbMyisamWarning'
390 $s .= $this->parent->getHelpBox(
'config-mysql-engine-help' );
395 if ( !in_array( $this->
getVar(
'_MysqlCharset' ), $charsets ) ) {
396 $this->
setVar(
'_MysqlCharset', reset( $charsets ) );
400 if ( count( $charsets ) >= 2 ) {
405 'var' =>
'_MysqlCharset',
406 'label' =>
'config-mysql-charset',
407 'itemLabelPrefix' =>
'config-mysql-',
408 'values' => $charsets
410 $s .= $this->parent->getHelpBox(
'config-mysql-charset-help' );
422 if ( !$status->isOK() ) {
429 $this->
setVar(
'_CreateDBAccount',
false );
432 $create = $this->
getVar(
'_CreateDBAccount' );
439 'host' => $this->
getVar(
'wgDBserver' ),
440 'user' => $this->
getVar(
'wgDBuser' ),
441 'password' => $this->
getVar(
'wgDBpassword' ),
444 'tablePrefix' => $this->
getVar(
'wgDBprefix' )
454 if ( !in_array( $this->
getVar(
'_MysqlEngine' ), $engines ) ) {
455 $this->
setVar(
'_MysqlEngine', reset( $engines ) );
458 if ( !in_array( $this->
getVar(
'_MysqlCharset' ), $charsets ) ) {
459 $this->
setVar(
'_MysqlCharset', reset( $charsets ) );
466 # Add our user callback to installSteps, right before the tables are created.
469 'callback' =>
array( $this,
'setupUser' ),
471 $this->parent->addInstallStep( $callback,
'tables' );
479 if ( !$status->isOK() ) {
483 $conn = $status->value;
484 $dbName = $this->
getVar(
'wgDBname' );
485 if ( !$conn->selectDB( $dbName ) ) {
487 "CREATE DATABASE " . $conn->addIdentifierQuotes( $dbName ) .
"CHARACTER SET utf8",
490 $conn->selectDB( $dbName );
501 $dbUser = $this->
getVar(
'wgDBuser' );
502 if ( $dbUser == $this->
getVar(
'_InstallUser' ) ) {
506 if ( !$status->isOK() ) {
511 $dbName = $this->
getVar(
'wgDBname' );
512 $this->db->selectDB( $dbName );
513 $server = $this->
getVar(
'wgDBserver' );
515 $grantableNames =
array();
517 if ( $this->
getVar(
'_CreateDBAccount' ) ) {
526 'tablePrefix' => $this->
getVar(
'wgDBprefix' )
529 $tryToCreate =
false;
535 $tryToCreate =
false;
538 if ( $tryToCreate ) {
539 $createHostList =
array(
542 'localhost.localdomain',
546 $createHostList = array_unique( $createHostList );
547 $escPass = $this->db->addQuotes(
$password );
549 foreach ( $createHostList
as $host ) {
553 $this->db->begin( __METHOD__ );
554 $this->db->query(
"CREATE USER $fullName IDENTIFIED BY $escPass", __METHOD__ );
555 $this->db->commit( __METHOD__ );
556 $grantableNames[] = $fullName;
558 if ( $this->db->lastErrno() == 1396 ) {
560 $this->db->rollback( __METHOD__ );
561 $status->warning(
'config-install-user-alreadyexists', $dbUser );
562 $grantableNames[] = $fullName;
567 $this->db->rollback( __METHOD__ );
568 $status->warning(
'config-install-user-create-failed', $dbUser, $dqe->
getText() );
572 $status->warning(
'config-install-user-alreadyexists', $dbUser );
573 $grantableNames[] = $fullName;
580 $dbAllTables = $this->db->addIdentifierQuotes( $dbName ) .
'.*';
581 foreach ( $grantableNames
as $name ) {
583 $this->db->begin( __METHOD__ );
584 $this->db->query(
"GRANT ALL PRIVILEGES ON $dbAllTables TO $name", __METHOD__ );
585 $this->db->commit( __METHOD__ );
587 $this->db->rollback( __METHOD__ );
588 $status->fatal(
'config-install-user-grant-failed', $dbUser, $dqe->
getText() );
602 return $this->db->addQuotes(
$name ) .
'@' . $this->db->addQuotes( $host );
614 $res = $this->db->selectRow(
'mysql.user',
array(
'Host',
'User' ),
615 array(
'Host' => $host,
'User' =>
$user ), __METHOD__ );
631 if ( $this->
getVar(
'_MysqlEngine' ) !==
null ) {
634 if ( $this->
getVar(
'_MysqlCharset' ) !==
null ) {
635 $options[] =
'DEFAULT CHARSET=' . $this->
getVar(
'_MysqlCharset' );
649 'wgDBname' => $this->
getVar(
'wgDBname' ),
650 'wgDBuser' => $this->
getVar(
'wgDBuser' ),
651 'wgDBpassword' => $this->
getVar(
'wgDBpassword' ),
660 return "# MySQL specific settings
661 \$wgDBprefix = \"{$prefix}\";
663 # MySQL table options to use during installation or update
664 \$wgDBTableOptions = \"{$tblOpts}\";
666 # Experimental charset support for MySQL 5.0.
667 \$wgDBmysql5 = {$dbmysql5};";
getTableOptions()
Return any table options to be applied to all tables that don't override them.
getEngines()
Get a list of storage engines that are available and supported.
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
static checkExtension( $name)
Convenience function.
design txt This is a brief overview of the new design More thorough and up to date information is available on the documentation wiki at etc Handles the details of getting and saving to the user table of the and dealing with sessions and cookies OutputPage Encapsulates the entire HTML page that will be sent in response to any server request It is used by calling its functions to add text
userDefinitelyExists( $host, $user)
Try to see if the user account exists.
getConnection()
Connect to the database using the administrative user/password currently defined in the session.
preInstall()
Allow DB installers a chance to make last-minute changes before installation occurs.
getLocalSettings()
Get the DBMS-specific options for LocalSettings.php generation.
static newGood( $value=null)
Factory function for good results.
static openElement( $element, $attribs=null)
This opens an XML element.
getTextBox( $var, $label, $attribs=array(), $helpData="")
Get a labelled text box to configure a local variable.
buildFullUserName( $name, $host)
Return a formal 'User'@'Host' username for use in queries.
wfBoolToStr( $value)
Convenience function converts boolean values into "true" or "false" (string) values.
static closeElement( $element)
Returns "</$element>".
static openElement( $element, $attribs=array())
Identical to rawElement(), but has no third parameter and omits the end tag (and the self-closing '/'...
static element( $element, $attribs=array(), $contents='')
Identical to rawElement(), but HTML-escapes $contents (like Xml::element()).
submitWebUserBox()
Submit the form from getWebUserBox().
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 "<
setupSchemaVars()
Set appropriate schema variables in the current database connection.
submitConnectForm()
Set variables based on the request array, assuming it was submitted via the form returned by getConne...
the array() calling protocol came about after MediaWiki 1.4rc1.
List of Api Query prop modules.
when a variable name is used in a it is silently declared as a new masking the global
static factory( $dbType, $p=array())
Given a DB type, construct the name of the appropriate child class of DatabaseBase.
getWebUserBox( $noCreateMsg=false)
Get a standard web-user fieldset.
getRadioSet( $params)
Get a set of labelled radio buttons.
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 & $options
DatabaseBase $db
The database connection.
preUpgrade()
Allow DB installers a chance to make checks before upgrade.
Allows to change the fields on the form that will be generated $name
getVar( $var, $default=null)
Get a variable, taking local defaults into account.
getSchemaVars()
Get variables to substitute into tables.sql and the SQL patch files.
submitInstallUserBox()
Submit a standard install user fieldset.
Base class for DBMS-specific installation helper classes.
getCharsets()
Get a list of character sets that are available and supported.
Class for setting up the MediaWiki database using MySQL.
please add to it if you re going to add events to the MediaWiki code where normally authentication against an external auth plugin would be creating a account $user
return false to override stock group addition can be modified try getUserPermissionsErrors userCan checks are continued by internal code can override on output return false to not delete it return false to override the default password checks this Boolean value will be checked to determine if the password was valid return false to implement your own hashing method & $password
static closeElement( $element)
Shortcut to close an XML element.
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
setVar( $name, $value)
Convenience alias for $this->parent->setVar()
getInstallUserBox()
Get a standard install-user fieldset.
setVarsFromRequest( $varNames)
Convenience function to set variables based on form data.
static escapePhpString( $string)
Returns the escaped version of a string of php code.
canCreateAccounts()
Return true if the install user can create accounts.
div flags Integer display flags(NO_ACTION_LINK, NO_EXTRA_USER_LINKS) 'LogException' returning false will NOT prevent logging $e
static newFatal( $message)
Factory function for fatal errors.