Go to the documentation of this file.
47 '_MysqlEngine' =>
'InnoDB',
48 '_MysqlCharset' =>
'binary',
49 '_InstallUser' =>
'root',
61 'CREATE TEMPORARY TABLES',
86 $this->parent->getHelpBox(
'config-db-host-help' )
90 $this->
getTextBox(
'wgDBname',
'config-db-name', [
'dir' =>
'ltr' ],
91 $this->parent->getHelpBox(
'config-db-name-help' ) ) .
92 $this->
getTextBox(
'wgDBprefix',
'config-db-prefix', [
'dir' =>
'ltr' ],
93 $this->parent->getHelpBox(
'config-db-prefix-help' ) ) .
104 if ( !strlen( $newValues[
'wgDBserver'] ) ) {
105 $status->fatal(
'config-missing-db-host' );
107 if ( !strlen( $newValues[
'wgDBname'] ) ) {
108 $status->fatal(
'config-missing-db-name' );
109 } elseif ( !preg_match(
'/^[a-z0-9+_-]+$/i', $newValues[
'wgDBname'] ) ) {
110 $status->fatal(
'config-invalid-db-name', $newValues[
'wgDBname'] );
112 if ( !preg_match(
'/^[a-z0-9_-]*$/i', $newValues[
'wgDBprefix'] ) ) {
113 $status->fatal(
'config-invalid-db-prefix', $newValues[
'wgDBprefix'] );
136 $version = $conn->getServerVersion();
137 if ( version_compare( $version, $this->minimumVersion ) < 0 ) {
138 return Status::newFatal(
'config-mysql-old', $this->minimumVersion, $version );
150 $db = Database::factory(
'mysql', [
151 'host' => $this->
getVar(
'wgDBserver' ),
152 'user' => $this->
getVar(
'_InstallUser' ),
153 'password' => $this->
getVar(
'_InstallPassword' ),
156 'tablePrefix' => $this->
getVar(
'wgDBprefix' ) ] );
159 $status->fatal(
'config-connection-error',
$e->getMessage() );
170 $this->parent->showStatusError(
$status );
178 $conn->selectDB( $this->
getVar(
'wgDBname' ) );
180 # Determine existing default character set
181 if ( $conn->tableExists(
"revision", __METHOD__ ) ) {
183 $res = $conn->query(
"SHOW TABLE STATUS LIKE '$revision'", __METHOD__ );
184 $row = $conn->fetchObject(
$res );
186 $this->parent->showMessage(
'config-show-table-status' );
187 $existingSchema =
false;
188 $existingEngine =
false;
190 if ( preg_match(
'/^latin1/', $row->Collation ) ) {
191 $existingSchema =
'latin1';
192 } elseif ( preg_match(
'/^utf8/', $row->Collation ) ) {
193 $existingSchema =
'utf8';
194 } elseif ( preg_match(
'/^binary/', $row->Collation ) ) {
195 $existingSchema =
'binary';
197 $existingSchema =
false;
198 $this->parent->showMessage(
'config-unknown-collation' );
200 if ( isset( $row->Engine ) ) {
201 $existingEngine = $row->Engine;
203 $existingEngine = $row->Type;
207 $existingSchema =
false;
208 $existingEngine =
false;
211 if ( $existingSchema && $existingSchema != $this->
getVar(
'_MysqlCharset' ) ) {
212 $this->
setVar(
'_MysqlCharset', $existingSchema );
214 if ( $existingEngine && $existingEngine != $this->
getVar(
'_MysqlEngine' ) ) {
215 $this->
setVar(
'_MysqlEngine', $existingEngine );
218 # Normal user and password are selected after this step, so for now
219 # just copy these two
221 $wgDBpassword = $this->
getVar(
'_InstallPassword' );
229 return str_replace( [ $escapeChar,
'%',
'_' ],
230 [
"{$escapeChar}{$escapeChar}",
"{$escapeChar}%",
"{$escapeChar}_" ],
248 $res = $conn->query(
'SHOW ENGINES', __METHOD__ );
249 foreach (
$res as $row ) {
250 if ( $row->Support ==
'YES' || $row->Support ==
'DEFAULT' ) {
251 $engines[] = $row->Engine;
254 $engines = array_intersect( $this->supportedEngines, $engines );
265 return [
'binary',
'utf8' ];
282 $currentName = $conn->selectField(
'',
'CURRENT_USER()',
'', __METHOD__ );
283 $parts = explode(
'@', $currentName );
284 if (
count( $parts ) != 2 ) {
287 $quotedUser = $conn->addQuotes( $parts[0] ) .
288 '@' . $conn->addQuotes( $parts[1] );
292 $res = $conn->select(
'INFORMATION_SCHEMA.USER_PRIVILEGES',
'*',
293 [
'GRANTEE' => $quotedUser ], __METHOD__ );
294 $insertMysql =
false;
295 $grantOptions = array_flip( $this->webUserPrivs );
296 foreach (
$res as $row ) {
297 if ( $row->PRIVILEGE_TYPE ==
'INSERT' ) {
300 if ( $row->IS_GRANTABLE ) {
301 unset( $grantOptions[$row->PRIVILEGE_TYPE] );
306 if ( !$insertMysql ) {
307 $row = $conn->selectRow(
'INFORMATION_SCHEMA.SCHEMA_PRIVILEGES',
'*',
309 'GRANTEE' => $quotedUser,
310 'TABLE_SCHEMA' =>
'mysql',
311 'PRIVILEGE_TYPE' =>
'INSERT',
318 if ( !$insertMysql ) {
323 $res = $conn->select(
'INFORMATION_SCHEMA.SCHEMA_PRIVILEGES',
'*',
325 'GRANTEE' => $quotedUser,
328 foreach (
$res as $row ) {
330 if ( preg_match( $regex, $this->
getVar(
'wgDBname' ) ) ) {
331 unset( $grantOptions[$row->PRIVILEGE_TYPE] );
334 if (
count( $grantOptions ) ) {
347 $r = preg_quote( $wildcard,
'/' );
360 $noCreateMsg =
false;
362 $noCreateMsg =
'config-db-web-no-create-privs';
369 if ( !in_array( $this->
getVar(
'_MysqlEngine' ), $engines ) ) {
370 $this->
setVar(
'_MysqlEngine', reset( $engines ) );
374 'id' =>
'dbMyisamWarning'
376 $myisamWarning =
'config-mysql-myisam-dep';
377 if (
count( $engines ) === 1 ) {
378 $myisamWarning =
'config-mysql-only-myisam-dep';
380 $s .= $this->parent->getWarningBox(
wfMessage( $myisamWarning )->
text() );
383 if ( $this->
getVar(
'_MysqlEngine' ) !=
'MyISAM' ) {
385 $s .=
'$(\'#dbMyisamWarning\').hide();';
389 if (
count( $engines ) >= 2 ) {
394 'var' =>
'_MysqlEngine',
395 'label' =>
'config-mysql-engine',
396 'itemLabelPrefix' =>
'config-mysql-',
397 'values' => $engines,
400 'class' =>
'showHideRadio',
401 'rel' =>
'dbMyisamWarning'
404 'class' =>
'hideShowRadio',
405 'rel' =>
'dbMyisamWarning'
409 $s .= $this->parent->getHelpBox(
'config-mysql-engine-help' );
414 if ( !in_array( $this->
getVar(
'_MysqlCharset' ), $charsets ) ) {
415 $this->
setVar(
'_MysqlCharset', reset( $charsets ) );
419 if (
count( $charsets ) >= 2 ) {
424 'var' =>
'_MysqlCharset',
425 'label' =>
'config-mysql-charset',
426 'itemLabelPrefix' =>
'config-mysql-',
427 'values' => $charsets
429 $s .= $this->parent->getHelpBox(
'config-mysql-charset-help' );
448 $this->
setVar(
'_CreateDBAccount',
false );
451 $create = $this->
getVar(
'_CreateDBAccount' );
457 Database::factory(
'mysql', [
458 'host' => $this->
getVar(
'wgDBserver' ),
459 'user' => $this->
getVar(
'wgDBuser' ),
460 'password' => $this->
getVar(
'wgDBpassword' ),
463 'tablePrefix' => $this->
getVar(
'wgDBprefix' )
473 if ( !in_array( $this->
getVar(
'_MysqlEngine' ), $engines ) ) {
474 $this->
setVar(
'_MysqlEngine', reset( $engines ) );
477 if ( !in_array( $this->
getVar(
'_MysqlCharset' ), $charsets ) ) {
478 $this->
setVar(
'_MysqlCharset', reset( $charsets ) );
485 # Add our user callback to installSteps, right before the tables are created.
488 'callback' => [ $this,
'setupUser' ],
490 $this->parent->addInstallStep( $callback,
'tables' );
503 $dbName = $this->
getVar(
'wgDBname' );
504 if ( !$conn->selectDB( $dbName ) ) {
506 "CREATE DATABASE " . $conn->addIdentifierQuotes( $dbName ) .
"CHARACTER SET utf8",
509 $conn->selectDB( $dbName );
520 $dbUser = $this->
getVar(
'wgDBuser' );
521 if ( $dbUser == $this->
getVar(
'_InstallUser' ) ) {
530 $dbName = $this->
getVar(
'wgDBname' );
531 $this->db->selectDB( $dbName );
532 $server = $this->
getVar(
'wgDBserver' );
533 $password = $this->
getVar(
'wgDBpassword' );
534 $grantableNames = [];
536 if ( $this->
getVar(
'_CreateDBAccount' ) ) {
539 Database::factory(
'mysql', [
542 'password' => $password,
545 'tablePrefix' => $this->
getVar(
'wgDBprefix' )
548 $tryToCreate =
false;
554 $tryToCreate =
false;
557 if ( $tryToCreate ) {
561 'localhost.localdomain',
565 $createHostList = array_unique( $createHostList );
566 $escPass = $this->db->addQuotes( $password );
568 foreach ( $createHostList
as $host ) {
572 $this->db->begin( __METHOD__ );
573 $this->db->query(
"CREATE USER $fullName IDENTIFIED BY $escPass", __METHOD__ );
574 $this->db->commit( __METHOD__ );
575 $grantableNames[] = $fullName;
577 if ( $this->db->lastErrno() == 1396 ) {
579 $this->db->rollback( __METHOD__ );
580 $status->warning(
'config-install-user-alreadyexists', $dbUser );
581 $grantableNames[] = $fullName;
586 $this->db->rollback( __METHOD__ );
587 $status->warning(
'config-install-user-create-failed', $dbUser, $dqe->getMessage() );
591 $status->warning(
'config-install-user-alreadyexists', $dbUser );
592 $grantableNames[] = $fullName;
599 $dbAllTables = $this->db->addIdentifierQuotes( $dbName ) .
'.*';
600 foreach ( $grantableNames
as $name ) {
602 $this->db->begin( __METHOD__ );
603 $this->db->query(
"GRANT ALL PRIVILEGES ON $dbAllTables TO $name", __METHOD__ );
604 $this->db->commit( __METHOD__ );
606 $this->db->rollback( __METHOD__ );
607 $status->fatal(
'config-install-user-grant-failed', $dbUser, $dqe->getMessage() );
621 return $this->db->addQuotes(
$name ) .
'@' . $this->db->addQuotes( $host );
633 $res = $this->db->selectRow(
'mysql.user', [
'Host',
'User' ],
634 [
'Host' => $host,
'User' =>
$user ], __METHOD__ );
650 if ( $this->
getVar(
'_MysqlEngine' ) !==
null ) {
653 if ( $this->
getVar(
'_MysqlCharset' ) !==
null ) {
654 $options[] =
'DEFAULT CHARSET=' . $this->
getVar(
'_MysqlCharset' );
668 'wgDBname' => $this->
getVar(
'wgDBname' ),
669 'wgDBuser' => $this->
getVar(
'wgDBuser' ),
670 'wgDBpassword' => $this->
getVar(
'wgDBpassword' ),
679 return "# MySQL specific settings
680 \$wgDBprefix = \"{$prefix}\";
682 # MySQL table options to use during installation or update
683 \$wgDBTableOptions = \"{$tblOpts}\";
685 # Experimental charset support for MySQL 5.0.
686 \$wgDBmysql5 = {$dbmysql5};";
getTableOptions()
Return any table options to be applied to all tables that don't override them.
likeToRegex( $wildcard)
Convert a wildcard (as used in LIKE) to a regex Slashes are escaped, slash terminators included.
getEngines()
Get a list of storage engines that are available and supported.
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.
this hook is for auditing only RecentChangesLinked and Watchlist RecentChangesLinked and Watchlist Do not use this to implement individual filters if they are compatible with the ChangesListFilter and ChangesListFilterGroup structure use sub classes of those in conjunction with the ChangesListSpecialPageStructuredFilters hook This hook can be used to implement filters that do not implement that or custom behavior that is not an individual filter e g Watchlist and Watchlist you will want to construct new ChangesListBooleanFilter or ChangesListStringOptionsFilter objects When constructing you specify which group they belong to You can reuse existing or create your you must register them with $special registerFilterGroup removed from all revisions and log entries to which it was applied This gives extensions a chance to take it off their books as the deletion has already been partly carried out by this point or something similar the user will be unable to create the tag set $status
preInstall()
Allow DB installers a chance to make last-minute changes before installation occurs.
getLocalSettings()
Get the DBMS-specific options for LocalSettings.php generation.
as see the revision history and available at free of to any person obtaining a copy of this software and associated documentation to deal in the Software without including without limitation the rights to use
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
static newFatal( $message)
Factory function for fatal errors.
getTextBox( $var, $label, $attribs=[], $helpData="")
Get a labelled text box to configure a local variable.
Allows to change the fields on the form that will be generated $name
static openElement( $element, $attribs=null)
This opens an XML element.
$wgDBpassword
Database user's password.
injection txt This is an overview of how MediaWiki makes use of dependency injection The design described here grew from the discussion of RFC T384 The term dependency this means that anything an object needs to operate should be injected from the the object itself should only know narrow no concrete implementation of the logic it relies on The requirement to inject everything typically results in an architecture that based on two main types of and essentially stateless service objects that use other service objects to operate on the value objects As of the beginning MediaWiki is only starting to use the DI approach Much of the code still relies on global state or direct resulting in a highly cyclical dependency which acts as the top level factory for services in MediaWiki which can be used to gain access to default instances of various services MediaWikiServices however also allows new services to be defined and default services to be redefined Services are defined or redefined by providing a callback the instantiator that will return a new instance of the service When it will create an instance of MediaWikiServices and populate it with the services defined in the files listed by thereby bootstrapping the DI framework Per $wgServiceWiringFiles lists includes ServiceWiring php
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>".
submitWebUserBox()
Submit the form from getWebUserBox().
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...
when a variable name is used in a it is silently declared as a new masking the global
getWebUserBox( $noCreateMsg=false)
Get a standard web-user fieldset.
getRadioSet( $params)
Get a set of labelled radio buttons.
preUpgrade()
Allow DB installers a chance to make checks before upgrade.
div flags Integer display flags(NO_ACTION_LINK, NO_EXTRA_USER_LINKS) 'LogException' returning false will NOT prevent logging $e
getVar( $var, $default=null)
Get a variable, taking local defaults into account.
static newGood( $value=null)
Factory function for good results.
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.
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
static openElement( $element, $attribs=[])
Identical to rawElement(), but has no third parameter and omits the end tag (and the self-closing '/'...
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.
either a unescaped string or a HtmlArmor object after in associative array form externallinks including delete and has completed for all link tables whether this was an auto creation 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 "<
$wgDBuser
Database username.
Database $db
The database connection.
static element( $element, $attribs=[], $contents='')
Identical to rawElement(), but HTML-escapes $contents (like Xml::element()).
canCreateAccounts()
Return true if the install user can create accounts.
this hook is for auditing only RecentChangesLinked and Watchlist RecentChangesLinked and Watchlist Do not use this to implement individual filters if they are compatible with the ChangesListFilter and ChangesListFilterGroup structure use sub classes of those in conjunction with the ChangesListSpecialPageStructuredFilters hook This hook can be used to implement filters that do not implement that or custom behavior that is not an individual filter e g Watchlist and Watchlist you will want to construct new ChangesListBooleanFilter or ChangesListStringOptionsFilter objects When constructing you specify which group they belong to You can reuse existing or create your you must register them with $special registerFilterGroup removed from all revisions and log entries to which it was applied This gives extensions a chance to take it off their books as the deletion has already been partly carried out by this point or something similar the user will be unable to create the tag set and then return false from the hook function Ensure you consume the ChangeTagAfterDelete hook to carry out custom deletion actions as context called by AbstractContent::getParserOutput May be used to override the normal model specific rendering of page content as context as context $options
escapeLikeInternal( $s, $escapeChar='`')