Go to the documentation of this file.
43 '_MysqlEngine' =>
'InnoDB',
44 '_MysqlCharset' =>
'binary',
45 '_InstallUser' =>
'root',
57 'CREATE TEMPORARY TABLES',
89 $this->parent->getHelpBox(
'config-db-host-help' )
93 $this->
getTextBox(
'wgDBname',
'config-db-name',
array(
'dir' =>
'ltr' ),
94 $this->parent->getHelpBox(
'config-db-name-help' ) ) .
95 $this->
getTextBox(
'wgDBprefix',
'config-db-prefix',
array(
'dir' =>
'ltr' ),
96 $this->parent->getHelpBox(
'config-db-prefix-help' ) ) .
104 'wgDBserver',
'wgDBname',
'wgDBprefix',
'_InstallUser',
'_InstallPassword'
109 if ( !strlen( $newValues[
'wgDBserver'] ) ) {
110 $status->fatal(
'config-missing-db-host' );
112 if ( !strlen( $newValues[
'wgDBname'] ) ) {
113 $status->fatal(
'config-missing-db-name' );
114 } elseif ( !preg_match(
'/^[a-z0-9+_-]+$/i', $newValues[
'wgDBname'] ) ) {
115 $status->fatal(
'config-invalid-db-name', $newValues[
'wgDBname'] );
117 if ( !preg_match(
'/^[a-z0-9_-]*$/i', $newValues[
'wgDBprefix'] ) ) {
118 $status->fatal(
'config-invalid-db-prefix', $newValues[
'wgDBprefix'] );
120 if ( !strlen( $newValues[
'_InstallUser'] ) ) {
121 $status->fatal(
'config-db-username-empty' );
123 if (!strlen( $newValues[
'_InstallPassword'] ) ) {
124 $status->fatal(
'config-db-password-empty', $newValues[
'_InstallUser'] );
126 if ( !$status->isOK() ) {
132 if ( !$status->isOK() ) {
138 if ( !$status->isOK() ) {
144 $conn = $status->value;
147 $version = $conn->getServerVersion();
148 if ( version_compare(
$version, $this->minimumVersion ) < 0 ) {
162 'host' => $this->
getVar(
'wgDBserver' ),
163 'user' => $this->
getVar(
'_InstallUser' ),
164 'password' => $this->
getVar(
'_InstallPassword' ),
167 'tablePrefix' => $this->
getVar(
'wgDBprefix' ) ) );
168 $status->value =
$db;
170 $status->fatal(
'config-connection-error',
$e->getMessage() );
177 global $wgDBuser, $wgDBpassword;
180 if ( !$status->isOK() ) {
181 $this->parent->showStatusError( $status );
188 $conn = $status->value;
189 $conn->selectDB( $this->
getVar(
'wgDBname' ) );
191 # Determine existing default character set
192 if ( $conn->tableExists(
"revision", __METHOD__ ) ) {
193 $revision = $conn->buildLike( $this->
getVar(
'wgDBprefix' ) .
'revision' );
194 $res = $conn->query(
"SHOW TABLE STATUS $revision", __METHOD__ );
195 $row = $conn->fetchObject(
$res );
197 $this->parent->showMessage(
'config-show-table-status' );
198 $existingSchema =
false;
199 $existingEngine =
false;
201 if ( preg_match(
'/^latin1/', $row->Collation ) ) {
202 $existingSchema =
'latin1';
203 } elseif ( preg_match(
'/^utf8/', $row->Collation ) ) {
204 $existingSchema =
'utf8';
205 } elseif ( preg_match(
'/^binary/', $row->Collation ) ) {
206 $existingSchema =
'binary';
208 $existingSchema =
false;
209 $this->parent->showMessage(
'config-unknown-collation' );
211 if ( isset( $row->Engine ) ) {
212 $existingEngine = $row->Engine;
214 $existingEngine = $row->Type;
218 $existingSchema =
false;
219 $existingEngine =
false;
222 if ( $existingSchema && $existingSchema != $this->
getVar(
'_MysqlCharset' ) ) {
223 $this->
setVar(
'_MysqlCharset', $existingSchema );
225 if ( $existingEngine && $existingEngine != $this->
getVar(
'_MysqlEngine' ) ) {
226 $this->
setVar(
'_MysqlEngine', $existingEngine );
229 # Normal user and password are selected after this step, so for now
230 # just copy these two
231 $wgDBuser = $this->
getVar(
'_InstallUser' );
232 $wgDBpassword = $this->
getVar(
'_InstallPassword' );
246 $conn = $status->value;
249 $res = $conn->query(
'SHOW ENGINES', __METHOD__ );
250 foreach (
$res as $row ) {
251 if ( $row->Support ==
'YES' || $row->Support ==
'DEFAULT' ) {
252 $engines[] = $row->Engine;
255 $engines = array_intersect( $this->supportedEngines, $engines );
266 return array(
'binary',
'utf8' );
276 if ( !$status->isOK() ) {
280 $conn = $status->value;
283 $currentName = $conn->selectField(
'',
'CURRENT_USER()',
'', __METHOD__ );
284 $parts = explode(
'@', $currentName );
285 if ( count( $parts ) != 2 ) {
288 $quotedUser = $conn->addQuotes( $parts[0] ) .
289 '@' . $conn->addQuotes( $parts[1] );
293 $res = $conn->select(
'INFORMATION_SCHEMA.USER_PRIVILEGES',
'*',
294 array(
'GRANTEE' => $quotedUser ), __METHOD__ );
295 $insertMysql =
false;
296 $grantOptions = array_flip( $this->webUserPrivs );
297 foreach (
$res as $row ) {
298 if ( $row->PRIVILEGE_TYPE ==
'INSERT' ) {
301 if ( $row->IS_GRANTABLE ) {
302 unset( $grantOptions[$row->PRIVILEGE_TYPE] );
307 if ( !$insertMysql ) {
308 $row = $conn->selectRow(
'INFORMATION_SCHEMA.SCHEMA_PRIVILEGES',
'*',
310 'GRANTEE' => $quotedUser,
311 'TABLE_SCHEMA' =>
'mysql',
312 'PRIVILEGE_TYPE' =>
'INSERT',
319 if ( !$insertMysql ) {
324 $res = $conn->select(
'INFORMATION_SCHEMA.SCHEMA_PRIVILEGES',
'*',
326 'GRANTEE' => $quotedUser,
329 foreach (
$res as $row ) {
330 $regex = $conn->likeToRegex( $row->TABLE_SCHEMA );
331 if ( preg_match( $regex, $this->
getVar(
'wgDBname' ) ) ) {
332 unset( $grantOptions[$row->PRIVILEGE_TYPE] );
335 if ( count( $grantOptions ) ) {
348 $noCreateMsg =
false;
350 $noCreateMsg =
'config-db-web-no-create-privs';
357 if ( !in_array( $this->
getVar(
'_MysqlEngine' ), $engines ) ) {
358 $this->
setVar(
'_MysqlEngine', reset( $engines ) );
362 'id' =>
'dbMyisamWarning'
364 $myisamWarning =
'config-mysql-myisam-dep';
365 if ( count( $engines ) === 1 ) {
366 $myisamWarning =
'config-mysql-only-myisam-dep';
368 $s .= $this->parent->getWarningBox(
wfMessage( $myisamWarning )->
text() );
371 if ( $this->
getVar(
'_MysqlEngine' ) !=
'MyISAM' ) {
373 $s .=
'$(\'#dbMyisamWarning\').hide();';
377 if ( count( $engines ) >= 2 ) {
382 'var' =>
'_MysqlEngine',
383 'label' =>
'config-mysql-engine',
384 'itemLabelPrefix' =>
'config-mysql-',
385 'values' => $engines,
386 'itemAttribs' =>
array(
388 'class' =>
'showHideRadio',
389 'rel' =>
'dbMyisamWarning'
392 'class' =>
'hideShowRadio',
393 'rel' =>
'dbMyisamWarning'
397 $s .= $this->parent->getHelpBox(
'config-mysql-engine-help' );
402 if ( !in_array( $this->
getVar(
'_MysqlCharset' ), $charsets ) ) {
403 $this->
setVar(
'_MysqlCharset', reset( $charsets ) );
407 if ( count( $charsets ) >= 2 ) {
412 'var' =>
'_MysqlCharset',
413 'label' =>
'config-mysql-charset',
414 'itemLabelPrefix' =>
'config-mysql-',
415 'values' => $charsets
417 $s .= $this->parent->getHelpBox(
'config-mysql-charset-help' );
429 if ( !$status->isOK() ) {
436 $this->
setVar(
'_CreateDBAccount',
false );
439 $create = $this->
getVar(
'_CreateDBAccount' );
446 'host' => $this->
getVar(
'wgDBserver' ),
447 'user' => $this->
getVar(
'wgDBuser' ),
448 'password' => $this->
getVar(
'wgDBpassword' ),
451 'tablePrefix' => $this->
getVar(
'wgDBprefix' )
461 if ( !in_array( $this->
getVar(
'_MysqlEngine' ), $engines ) ) {
462 $this->
setVar(
'_MysqlEngine', reset( $engines ) );
465 if ( !in_array( $this->
getVar(
'_MysqlCharset' ), $charsets ) ) {
466 $this->
setVar(
'_MysqlCharset', reset( $charsets ) );
473 # Add our user callback to installSteps, right before the tables are created.
476 'callback' =>
array( $this,
'setupUser' ),
478 $this->parent->addInstallStep( $callback,
'tables' );
486 if ( !$status->isOK() ) {
490 $conn = $status->value;
491 $dbName = $this->
getVar(
'wgDBname' );
492 if ( !$conn->selectDB( $dbName ) ) {
494 "CREATE DATABASE " . $conn->addIdentifierQuotes( $dbName ) .
"CHARACTER SET utf8",
497 $conn->selectDB( $dbName );
508 $dbUser = $this->
getVar(
'wgDBuser' );
509 if ( $dbUser == $this->
getVar(
'_InstallUser' ) ) {
513 if ( !$status->isOK() ) {
518 $dbName = $this->
getVar(
'wgDBname' );
519 $this->db->selectDB( $dbName );
520 $server = $this->
getVar(
'wgDBserver' );
522 $grantableNames =
array();
524 if ( $this->
getVar(
'_CreateDBAccount' ) ) {
533 'tablePrefix' => $this->
getVar(
'wgDBprefix' )
536 $tryToCreate =
false;
542 $tryToCreate =
false;
545 if ( $tryToCreate ) {
546 $createHostList =
array(
549 'localhost.localdomain',
553 $createHostList = array_unique( $createHostList );
554 $escPass = $this->db->addQuotes(
$password );
556 foreach ( $createHostList
as $host ) {
560 $this->db->begin( __METHOD__ );
561 $this->db->query(
"CREATE USER $fullName IDENTIFIED BY $escPass", __METHOD__ );
562 $this->db->commit( __METHOD__ );
563 $grantableNames[] = $fullName;
565 if ( $this->db->lastErrno() == 1396 ) {
567 $this->db->rollback( __METHOD__ );
568 $status->warning(
'config-install-user-alreadyexists', $dbUser );
569 $grantableNames[] = $fullName;
574 $this->db->rollback( __METHOD__ );
575 $status->warning(
'config-install-user-create-failed', $dbUser, $dqe->
getText() );
579 $status->warning(
'config-install-user-alreadyexists', $dbUser );
580 $grantableNames[] = $fullName;
587 $dbAllTables = $this->db->addIdentifierQuotes( $dbName ) .
'.*';
588 foreach ( $grantableNames
as $name ) {
590 $this->db->begin( __METHOD__ );
591 $this->db->query(
"GRANT ALL PRIVILEGES ON $dbAllTables TO $name", __METHOD__ );
592 $this->db->commit( __METHOD__ );
594 $this->db->rollback( __METHOD__ );
595 $status->fatal(
'config-install-user-grant-failed', $dbUser, $dqe->
getText() );
609 return $this->db->addQuotes(
$name ) .
'@' . $this->db->addQuotes( $host );
621 $res = $this->db->selectRow(
'mysql.user',
array(
'Host',
'User' ),
622 array(
'Host' => $host,
'User' =>
$user ), __METHOD__ );
638 if ( $this->
getVar(
'_MysqlEngine' ) !==
null ) {
641 if ( $this->
getVar(
'_MysqlCharset' ) !==
null ) {
642 $options[] =
'DEFAULT CHARSET=' . $this->
getVar(
'_MysqlCharset' );
656 'wgDBname' => $this->
getVar(
'wgDBname' ),
657 'wgDBuser' => $this->
getVar(
'wgDBuser' ),
658 'wgDBpassword' => $this->
getVar(
'wgDBpassword' ),
667 return "# MySQL specific settings
668 \$wgDBprefix = \"{$prefix}\";
670 # MySQL table options to use during installation or update
671 \$wgDBTableOptions = \"{$tblOpts}\";
673 # Experimental charset support for MySQL 5.0.
674 \$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>", except if $wgWellFormedXml is off, in which case it returns the empty string w...
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.
static newFatal( $message)
Factory function for fatal errors.