39 'wgDBWindowsAuthentication',
43 '_InstallUser' =>
'sa',
44 '_InstallWindowsAuthentication' =>
'sqlauth',
45 '_WebWindowsAuthentication' =>
'sqlauth',
81 if ( $this->
getVar(
'_InstallWindowsAuthentication' ) ==
'windowsauth' ) {
82 $displayStyle =
'display: none;';
84 $displayStyle =
'display: block;';
91 $this->parent->getHelpBox(
'config-db-host-help' )
93 Html::openElement(
'fieldset' ) .
94 Html::element(
'legend', [],
wfMessage(
'config-db-wiki-settings' )->
text() ) .
95 $this->
getTextBox(
'wgDBname',
'config-db-name', [
'dir' =>
'ltr' ],
96 $this->parent->getHelpBox(
'config-db-name-help' ) ) .
97 $this->
getTextBox(
'wgDBmwschema',
'config-db-schema', [
'dir' =>
'ltr' ],
98 $this->parent->getHelpBox(
'config-db-schema-help' ) ) .
99 $this->
getTextBox(
'wgDBprefix',
'config-db-prefix', [
'dir' =>
'ltr' ],
100 $this->parent->getHelpBox(
'config-db-prefix-help' ) ) .
101 Html::closeElement(
'fieldset' ) .
102 Html::openElement(
'fieldset' ) .
103 Html::element(
'legend', [],
wfMessage(
'config-db-install-account' )->
text() ) .
105 'var' =>
'_InstallWindowsAuthentication',
106 'label' =>
'config-mssql-auth',
107 'itemLabelPrefix' =>
'config-mssql-',
108 'values' => [
'sqlauth',
'windowsauth' ],
111 'class' =>
'showHideRadio',
112 'rel' =>
'dbCredentialBox',
115 'class' =>
'hideShowRadio',
116 'rel' =>
'dbCredentialBox',
119 'help' => $this->parent->getHelpBox(
'config-mssql-install-auth' )
121 Html::openElement(
'div', [
'id' =>
'dbCredentialBox',
'style' => $displayStyle ] ) .
124 'config-db-username',
126 $this->parent->getHelpBox(
'config-db-install-username' )
130 'config-db-password',
132 $this->parent->getHelpBox(
'config-db-install-password' )
134 Html::closeElement(
'div' ) .
135 Html::closeElement(
'fieldset' );
149 if ( !strlen( $newValues[
'wgDBserver'] ) ) {
150 $status->fatal(
'config-missing-db-host' );
152 if ( !strlen( $newValues[
'wgDBname'] ) ) {
153 $status->fatal(
'config-missing-db-name' );
154 } elseif ( !preg_match(
'/^[a-z0-9_]+$/i', $newValues[
'wgDBname'] ) ) {
155 $status->fatal(
'config-invalid-db-name', $newValues[
'wgDBname'] );
157 if ( !preg_match(
'/^[a-z0-9_]*$/i', $newValues[
'wgDBmwschema'] ) ) {
158 $status->fatal(
'config-invalid-schema', $newValues[
'wgDBmwschema'] );
160 if ( !preg_match(
'/^[a-z0-9_]*$/i', $newValues[
'wgDBprefix'] ) ) {
161 $status->fatal(
'config-invalid-db-prefix', $newValues[
'wgDBprefix'] );
168 if ( $newValues[
'wgDBmwschema'] ===
'' ) {
169 $this->
setVar(
'wgDBmwschema',
'dbo' );
176 '_InstallWindowsAuthentication'
190 $version = $conn->getServerVersion();
191 if ( version_compare( $version, $this->minimumVersion ) < 0 ) {
192 return Status::newFatal(
'config-mssql-old', $this->minimumVersion, $version );
205 $password = $this->
getVar(
'_InstallPassword' );
207 if ( $this->
getVar(
'_InstallWindowsAuthentication' ) ==
'windowsauth' ) {
209 $wgDBWindowsAuthentication =
true;
215 $db = Database::factory(
'mssql', [
216 'host' => $this->
getVar(
'wgDBserver' ),
218 'password' => $password,
221 'schema' => $this->
getVar(
'wgDBmwschema' ),
222 'tablePrefix' => $this->
getVar(
'wgDBprefix' ) ] );
223 $db->prepareStatements(
false );
224 $db->scrollableCursor(
false );
227 $status->fatal(
'config-connection-error',
$e->getMessage() );
238 $this->parent->showStatusError(
$status );
246 $conn->selectDB( $this->
getVar(
'wgDBname' ) );
248 # Normal user and password are selected after this step, so for now
249 # just copy these two
250 $wgDBuser = $this->
getVar(
'_InstallUser' );
251 $wgDBpassword = $this->
getVar(
'_InstallPassword' );
268 $res = $conn->query(
"SELECT permission_name FROM sys.fn_my_permissions( NULL, 'SERVER' )" );
270 'ALTER ANY LOGIN' =>
false,
271 'CONTROL SERVER' =>
false,
274 foreach (
$res as $row ) {
275 $serverPrivs[$row->permission_name] =
true;
278 if ( !$serverPrivs[
'ALTER ANY LOGIN'] ) {
289 'DELETE' => [
'DELETE',
'CONTROL SERVER' ],
290 'EXECUTE' => [
'EXECUTE',
'CONTROL SERVER' ],
291 'INSERT' => [
'INSERT',
'CONTROL SERVER' ],
292 'SELECT' => [
'SELECT',
'CONTROL SERVER' ],
293 'UPDATE' => [
'UPDATE',
'CONTROL SERVER' ],
296 $grantOptions = array_flip( $this->webUserPrivs );
299 $schemaPrivs = $dbPrivs = [
307 $dbPrivs[
'ALTER ANY USER'] =
false;
310 $conn->selectDB( $this->
getVar(
'wgDBname' ) );
311 $res = $conn->query(
"SELECT permission_name FROM sys.fn_my_permissions( NULL, 'DATABASE' )" );
313 foreach (
$res as $row ) {
314 $dbPrivs[$row->permission_name] =
true;
318 if ( !$dbPrivs[
'ALTER ANY USER'] ) {
324 $res = $conn->query(
"SELECT permission_name FROM sys.fn_my_permissions( "
325 .
"'{$this->getVar( 'wgDBmwschema' )}', 'SCHEMA' )" );
327 foreach (
$res as $row ) {
328 $schemaPrivs[$row->permission_name] =
true;
334 foreach ( $this->webUserPrivs
as $permission ) {
335 if ( ( isset( $schemaPrivs[$permission] ) && $schemaPrivs[$permission] )
336 || ( isset( $dbPrivs[$implied[$permission][0]] )
337 && $dbPrivs[$implied[$permission][0]] )
338 || ( isset( $serverPrivs[$implied[$permission][1]] )
339 && $serverPrivs[$implied[$permission][1]] )
341 unset( $grantOptions[$permission] );
345 if ( count( $grantOptions ) ) {
358 $noCreateMsg =
false;
360 $noCreateMsg =
'config-db-web-no-create-privs';
363 $wrapperStyle = $this->
getVar(
'_SameAccount' ) ?
'display: none' :
'';
364 $displayStyle = $this->
getVar(
'_WebWindowsAuthentication' ) ==
'windowsauth'
367 $s = Html::openElement(
'fieldset' ) .
368 Html::element(
'legend', [],
wfMessage(
'config-db-web-account' )->
text() ) .
370 '_SameAccount',
'config-db-web-account-same',
371 [
'class' =>
'hideShowRadio',
'rel' =>
'dbOtherAccount' ]
373 Html::openElement(
'div', [
'id' =>
'dbOtherAccount',
'style' => $wrapperStyle ] ) .
375 'var' =>
'_WebWindowsAuthentication',
376 'label' =>
'config-mssql-auth',
377 'itemLabelPrefix' =>
'config-mssql-',
378 'values' => [
'sqlauth',
'windowsauth' ],
381 'class' =>
'showHideRadio',
382 'rel' =>
'dbCredentialBox',
385 'class' =>
'hideShowRadio',
386 'rel' =>
'dbCredentialBox',
389 'help' => $this->parent->getHelpBox(
'config-mssql-web-auth' )
391 Html::openElement(
'div', [
'id' =>
'dbCredentialBox',
'style' => $displayStyle ] ) .
392 $this->
getTextBox(
'wgDBuser',
'config-db-username' ) .
394 Html::closeElement(
'div' );
396 if ( $noCreateMsg ) {
399 $s .= $this->
getCheckBox(
'_CreateDBAccount',
'config-db-web-create' );
402 $s .= Html::closeElement(
'div' ) . Html::closeElement(
'fieldset' );
416 '_WebWindowsAuthentication'
419 if ( $this->
getVar(
'_SameAccount' ) ) {
420 $this->
setVar(
'_WebWindowsAuthentication', $this->
getVar(
'_InstallWindowsAuthentication' ) );
421 $this->
setVar(
'wgDBuser', $this->
getVar(
'_InstallUser' ) );
422 $this->
setVar(
'wgDBpassword', $this->
getVar(
'_InstallPassword' ) );
425 if ( $this->
getVar(
'_WebWindowsAuthentication' ) ==
'windowsauth' ) {
426 $this->
setVar(
'wgDBuser',
'' );
427 $this->
setVar(
'wgDBpassword',
'' );
428 $this->
setVar(
'wgDBWindowsAuthentication',
true );
430 $this->
setVar(
'wgDBWindowsAuthentication',
false );
433 if ( $this->
getVar(
'_CreateDBAccount' )
434 && $this->
getVar(
'_WebWindowsAuthentication' ) ==
'sqlauth'
435 && strval( $this->
getVar(
'wgDBpassword' ) ) ==
''
437 return Status::newFatal(
'config-db-password-empty', $this->
getVar(
'wgDBuser' ) );
443 $this->
setVar(
'_CreateDBAccount',
false );
446 $create = $this->
getVar(
'_CreateDBAccount' );
452 $password = $this->
getVar(
'wgDBpassword' );
454 if ( $this->
getVar(
'_WebWindowsAuthentication' ) ==
'windowsauth' ) {
455 $user =
'windowsauth';
456 $password =
'windowsauth';
460 Database::factory(
'mssql', [
461 'host' => $this->
getVar(
'wgDBserver' ),
463 'password' => $password,
466 'tablePrefix' => $this->
getVar(
'wgDBprefix' ),
467 'schema' => $this->
getVar(
'wgDBmwschema' ),
470 return Status::newFatal(
'config-connection-error',
$e->getMessage() );
474 return Status::newGood();
478 # Add our user callback to installSteps, right before the tables are created.
481 'callback' => [ $this,
'setupUser' ],
483 $this->parent->addInstallStep( $callback,
'tables' );
496 $dbName = $this->
getVar(
'wgDBname' );
497 $schemaName = $this->
getVar(
'wgDBmwschema' );
500 "CREATE DATABASE " . $conn->addIdentifierQuotes( $dbName ),
504 $conn->selectDB( $dbName );
507 "CREATE SCHEMA " . $conn->addIdentifierQuotes( $schemaName ),
513 "CREATE FULLTEXT CATALOG " . $conn->addIdentifierQuotes( $schemaName ),
526 $dbUser = $this->
getVar(
'wgDBuser' );
527 if ( $dbUser == $this->
getVar(
'_InstallUser' )
528 || ( $this->
getVar(
'_InstallWindowsAuthentication' ) ==
'windowsauth'
529 && $this->
getVar(
'_WebWindowsAuthentication' ) ==
'windowsauth' ) ) {
530 return Status::newGood();
538 $dbName = $this->
getVar(
'wgDBname' );
539 $this->db->selectDB( $dbName );
540 $password = $this->
getVar(
'wgDBpassword' );
541 $schemaName = $this->
getVar(
'wgDBmwschema' );
543 if ( $this->
getVar(
'_WebWindowsAuthentication' ) ==
'windowsauth' ) {
544 $dbUser =
'windowsauth';
545 $password =
'windowsauth';
548 if ( $this->
getVar(
'_CreateDBAccount' ) ) {
551 $tryToCreate =
false;
554 $escUser = $this->db->addIdentifierQuotes( $dbUser );
555 $escDb = $this->db->addIdentifierQuotes( $dbName );
556 $escSchema = $this->db->addIdentifierQuotes( $schemaName );
557 $grantableNames = [];
558 if ( $tryToCreate ) {
559 $escPass = $this->db->addQuotes( $password );
564 $this->db->selectDB(
'master' );
565 $logintype = $this->
getVar(
'_WebWindowsAuthentication' ) ==
'windowsauth'
567 :
"WITH PASSWORD = $escPass";
568 $this->db->query(
"CREATE LOGIN $escUser $logintype" );
569 $this->db->selectDB( $dbName );
570 $this->db->query(
"CREATE USER $escUser FOR LOGIN $escUser WITH DEFAULT_SCHEMA = $escSchema" );
572 $grantableNames[] = $dbUser;
574 $this->db->rollback();
575 $status->warning(
'config-install-user-create-failed', $dbUser, $dqe->getText() );
580 $this->db->selectDB( $dbName );
581 $this->db->query(
"CREATE USER $escUser FOR LOGIN $escUser WITH DEFAULT_SCHEMA = $escSchema" );
583 $grantableNames[] = $dbUser;
585 $this->db->rollback();
586 $status->warning(
'config-install-user-create-failed', $dbUser, $dqe->getText() );
589 $status->warning(
'config-install-user-alreadyexists', $dbUser );
590 $grantableNames[] = $dbUser;
595 $this->db->selectDB( $dbName );
596 foreach ( $grantableNames
as $name ) {
600 'BACKUP DATABASE',
'BACKUP LOG',
'CREATE FUNCTION',
'CREATE PROCEDURE',
601 'CREATE TABLE',
'CREATE VIEW',
'CREATE FULLTEXT CATALOG',
'SHOWPLAN'
603 $fullPrivList = implode(
', ', $fullPrivArr );
605 $this->db->query(
"GRANT $fullPrivList ON DATABASE :: $escDb TO $escUser", __METHOD__ );
606 $this->db->query(
"GRANT CONTROL ON SCHEMA :: $escSchema TO $escUser", __METHOD__ );
611 $privList = implode(
', ', $this->webUserPrivs );
612 $this->db->rollback();
614 $this->db->query(
"GRANT $privList ON SCHEMA :: $escSchema TO $escUser", __METHOD__ );
617 $this->db->rollback();
618 $status->fatal(
'config-install-user-grant-failed', $dbUser, $dqe->getText() );
624 $this->db->query(
"GRANT SHOWPLAN ON DATABASE :: $escDb TO $escUser", __METHOD__ );
634 $status = parent::createTables();
638 $searchindex = $this->db->tableName(
'searchindex' );
639 $schema = $this->db->addIdentifierQuotes( $this->
getVar(
'wgDBmwschema' ) );
641 $this->db->query(
"CREATE FULLTEXT INDEX ON $searchindex (si_title, si_text) "
642 .
"KEY INDEX si_page ON $schema" );
644 $status->fatal(
'config-install-tables-failed', $dqe->getText() );
654 return array_merge( parent::getGlobalDefaults(), [
655 'wgDBmwschema' =>
'mediawiki',
665 $res = $this->db->selectField(
'sys.sql_logins', 1, [
'name' =>
$user ] );
676 $res = $this->db->selectField(
'sys.sysusers', 1, [
'name' =>
$user ] );
686 $res = $this->db->selectField(
'sys.databases', 1, [
'name' => $dbName ] );
697 $res = $this->db->selectField(
'sys.schemas', 1, [
'name' => $schemaName ] );
708 $res = $this->db->selectField(
'sys.fulltext_catalogs', 1, [
'name' => $catalogName ] );
719 'wgDBname' => $this->
getVar(
'wgDBname' ),
720 'wgDBmwschema' => $this->
getVar(
'wgDBmwschema' ),
721 'wgDBuser' => $this->
getVar(
'wgDBuser' ),
722 'wgDBpassword' => $this->
getVar(
'wgDBpassword' ),
727 $schema = LocalSettingsGenerator::escapePhpString( $this->
getVar(
'wgDBmwschema' ) );
728 $prefix = LocalSettingsGenerator::escapePhpString( $this->
getVar(
'wgDBprefix' ) );
729 $windowsauth = $this->
getVar(
'wgDBWindowsAuthentication' ) ?
'true' :
'false';
731 return "# MSSQL specific settings
732\$wgDBWindowsAuthentication = {$windowsauth};
733\$wgDBmwschema = \"{$schema}\";
734\$wgDBprefix = \"{$prefix}\";";
$wgDBuser
Database username.
$wgDBWindowsAuthentication
Use Windows Authentication instead of $wgDBuser / $wgDBpassword for MS SQL Server.
$wgDBpassword
Database user's password.
Base class for DBMS-specific installation helper classes.
static checkExtension( $name)
Convenience function.
Database $db
The database connection.
getPasswordBox( $var, $label, $attribs=[], $helpData="")
Get a labelled password box to configure a local variable.
setVarsFromRequest( $varNames)
Convenience function to set variables based on form data.
getCheckBox( $var, $label, $attribs=[], $helpData="")
Get a labelled checkbox to configure a local boolean variable.
getConnection()
Connect to the database using the administrative user/password currently defined in the session.
getVar( $var, $default=null)
Get a variable, taking local defaults into account.
getTextBox( $var, $label, $attribs=[], $helpData="")
Get a labelled text box to configure a local variable.
setVar( $name, $value)
Convenience alias for $this->parent->setVar()
setupSchemaVars()
Set appropriate schema variables in the current database connection.
getRadioSet( $params)
Get a set of labelled radio buttons.
Class for setting up the MediaWiki database using Microsoft SQL Server.
canCreateAccounts()
Return true if the install user can create accounts.
getSchemaVars()
Get variables to substitute into tables.sql and the SQL patch files.
getLocalSettings()
Get the DBMS-specific options for LocalSettings.php generation.
userExists( $user)
Try to see if the user account exists We assume we already have the appropriate database selected.
getGlobalDefaults()
Get a name=>value map of MW configuration globals for the default values.
catalogExists( $catalogName)
Try to see if a given fulltext catalog exists We assume we already have the appropriate database sele...
databaseExists( $dbName)
Try to see if a given database exists.
preInstall()
Allow DB installers a chance to make last-minute changes before installation occurs.
createTables()
Create database tables from scratch.
loginExists( $user)
Try to see if the login exists.
preUpgrade()
Allow DB installers a chance to make checks before upgrade.
submitConnectForm()
Set variables based on the request array, assuming it was submitted via the form returned by getConne...
schemaExists( $schemaName)
Try to see if a given schema exists We assume we already have the appropriate database selected.
when a variable name is used in a it is silently declared as a new local masking the global
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
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
this hook is for auditing only RecentChangesLinked and Watchlist RecentChangesLinked and Watchlist e g Watchlist 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
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 local account $user
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 "<div ...>$1</div>"). - flags Integer display flags(NO_ACTION_LINK, NO_EXTRA_USER_LINKS) 'LogException':Called before an exception(or PHP error) is logged. This is meant for integration with external error aggregation services
Allows to change the fields on the form that will be generated $name
returning false will NOT prevent logging $e
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