Go to the documentation of this file.
43 'wgDBWindowsAuthentication',
47 '_InstallUser' =>
'sa',
48 '_InstallWindowsAuthentication' =>
'sqlauth',
49 '_WebWindowsAuthentication' =>
'sqlauth',
85 if ( $this->
getVar(
'_InstallWindowsAuthentication' ) ==
'windowsauth' ) {
86 $displayStyle =
'display: none;';
88 $displayStyle =
'display: block;';
95 $this->parent->getHelpBox(
'config-db-host-help' )
99 $this->
getTextBox(
'wgDBname',
'config-db-name', [
'dir' =>
'ltr' ],
100 $this->parent->getHelpBox(
'config-db-name-help' ) ) .
101 $this->
getTextBox(
'wgDBmwschema',
'config-db-schema', [
'dir' =>
'ltr' ],
102 $this->parent->getHelpBox(
'config-db-schema-help' ) ) .
103 $this->
getTextBox(
'wgDBprefix',
'config-db-prefix', [
'dir' =>
'ltr' ],
104 $this->parent->getHelpBox(
'config-db-prefix-help' ) ) .
109 'var' =>
'_InstallWindowsAuthentication',
110 'label' =>
'config-mssql-auth',
111 'itemLabelPrefix' =>
'config-mssql-',
112 'values' => [
'sqlauth',
'windowsauth' ],
115 'class' =>
'showHideRadio',
116 'rel' =>
'dbCredentialBox',
119 'class' =>
'hideShowRadio',
120 'rel' =>
'dbCredentialBox',
123 'help' => $this->parent->getHelpBox(
'config-mssql-install-auth' )
125 Html::openElement(
'div', [
'id' =>
'dbCredentialBox',
'style' => $displayStyle ] ) .
128 'config-db-username',
130 $this->parent->getHelpBox(
'config-db-install-username' )
134 'config-db-password',
136 $this->parent->getHelpBox(
'config-db-install-password' )
153 if ( !strlen( $newValues[
'wgDBserver'] ) ) {
154 $status->fatal(
'config-missing-db-host' );
156 if ( !strlen( $newValues[
'wgDBname'] ) ) {
157 $status->fatal(
'config-missing-db-name' );
158 } elseif ( !preg_match(
'/^[a-z0-9_]+$/i', $newValues[
'wgDBname'] ) ) {
159 $status->fatal(
'config-invalid-db-name', $newValues[
'wgDBname'] );
161 if ( !preg_match(
'/^[a-z0-9_]*$/i', $newValues[
'wgDBmwschema'] ) ) {
162 $status->fatal(
'config-invalid-schema', $newValues[
'wgDBmwschema'] );
164 if ( !preg_match(
'/^[a-z0-9_]*$/i', $newValues[
'wgDBprefix'] ) ) {
165 $status->fatal(
'config-invalid-db-prefix', $newValues[
'wgDBprefix'] );
172 if ( $newValues[
'wgDBmwschema'] ===
'' ) {
173 $this->
setVar(
'wgDBmwschema',
'dbo' );
180 '_InstallWindowsAuthentication'
194 $version = $conn->getServerVersion();
195 if ( version_compare( $version, $this->minimumVersion ) < 0 ) {
196 return Status::newFatal(
'config-mssql-old', $this->minimumVersion, $version );
209 $password = $this->
getVar(
'_InstallPassword' );
211 if ( $this->
getVar(
'_InstallWindowsAuthentication' ) ==
'windowsauth' ) {
213 $wgDBWindowsAuthentication =
true;
219 $db = Database::factory(
'mssql', [
220 'host' => $this->
getVar(
'wgDBserver' ),
221 'port' => $this->
getVar(
'wgDBport' ),
223 'password' => $password,
226 'schema' => $this->
getVar(
'wgDBmwschema' ),
227 'tablePrefix' => $this->
getVar(
'wgDBprefix' ) ] );
228 $db->prepareStatements(
false );
229 $db->scrollableCursor(
false );
232 $status->fatal(
'config-connection-error',
$e->getMessage() );
243 $this->parent->showStatusError(
$status );
251 $conn->selectDB( $this->
getVar(
'wgDBname' ) );
253 # Normal user and password are selected after this step, so for now
254 # just copy these two
255 $wgDBuser = $this->
getVar(
'_InstallUser' );
256 $wgDBpassword = $this->
getVar(
'_InstallPassword' );
273 $res = $conn->query(
"SELECT permission_name FROM sys.fn_my_permissions( NULL, 'SERVER' )" );
275 'ALTER ANY LOGIN' =>
false,
276 'CONTROL SERVER' =>
false,
279 foreach (
$res as $row ) {
280 $serverPrivs[$row->permission_name] =
true;
283 if ( !$serverPrivs[
'ALTER ANY LOGIN'] ) {
294 'DELETE' => [
'DELETE',
'CONTROL SERVER' ],
295 'EXECUTE' => [
'EXECUTE',
'CONTROL SERVER' ],
296 'INSERT' => [
'INSERT',
'CONTROL SERVER' ],
297 'SELECT' => [
'SELECT',
'CONTROL SERVER' ],
298 'UPDATE' => [
'UPDATE',
'CONTROL SERVER' ],
301 $grantOptions = array_flip( $this->webUserPrivs );
304 $schemaPrivs = $dbPrivs = [
312 $dbPrivs[
'ALTER ANY USER'] =
false;
315 $conn->selectDB( $this->
getVar(
'wgDBname' ) );
316 $res = $conn->query(
"SELECT permission_name FROM sys.fn_my_permissions( NULL, 'DATABASE' )" );
318 foreach (
$res as $row ) {
319 $dbPrivs[$row->permission_name] =
true;
323 if ( !$dbPrivs[
'ALTER ANY USER'] ) {
329 $res = $conn->query(
"SELECT permission_name FROM sys.fn_my_permissions( "
330 .
"'{$this->getVar( 'wgDBmwschema' )}', 'SCHEMA' )" );
332 foreach (
$res as $row ) {
333 $schemaPrivs[$row->permission_name] =
true;
339 foreach ( $this->webUserPrivs
as $permission ) {
340 if ( ( isset( $schemaPrivs[$permission] ) && $schemaPrivs[$permission] )
341 || ( isset( $dbPrivs[$implied[$permission][0]] )
342 && $dbPrivs[$implied[$permission][0]] )
343 || ( isset( $serverPrivs[$implied[$permission][1]] )
344 && $serverPrivs[$implied[$permission][1]] )
346 unset( $grantOptions[$permission] );
350 if (
count( $grantOptions ) ) {
363 $noCreateMsg =
false;
365 $noCreateMsg =
'config-db-web-no-create-privs';
368 $wrapperStyle = $this->
getVar(
'_SameAccount' ) ?
'display: none' :
'';
369 $displayStyle = $this->
getVar(
'_WebWindowsAuthentication' ) ==
'windowsauth'
375 '_SameAccount',
'config-db-web-account-same',
376 [
'class' =>
'hideShowRadio',
'rel' =>
'dbOtherAccount' ]
378 Html::openElement(
'div', [
'id' =>
'dbOtherAccount',
'style' => $wrapperStyle ] ) .
380 'var' =>
'_WebWindowsAuthentication',
381 'label' =>
'config-mssql-auth',
382 'itemLabelPrefix' =>
'config-mssql-',
383 'values' => [
'sqlauth',
'windowsauth' ],
386 'class' =>
'showHideRadio',
387 'rel' =>
'dbCredentialBox',
390 'class' =>
'hideShowRadio',
391 'rel' =>
'dbCredentialBox',
394 'help' => $this->parent->getHelpBox(
'config-mssql-web-auth' )
396 Html::openElement(
'div', [
'id' =>
'dbCredentialBox',
'style' => $displayStyle ] ) .
397 $this->
getTextBox(
'wgDBuser',
'config-db-username' ) .
401 if ( $noCreateMsg ) {
404 $s .= $this->
getCheckBox(
'_CreateDBAccount',
'config-db-web-create' );
421 '_WebWindowsAuthentication'
424 if ( $this->
getVar(
'_SameAccount' ) ) {
425 $this->
setVar(
'_WebWindowsAuthentication', $this->
getVar(
'_InstallWindowsAuthentication' ) );
426 $this->
setVar(
'wgDBuser', $this->
getVar(
'_InstallUser' ) );
427 $this->
setVar(
'wgDBpassword', $this->
getVar(
'_InstallPassword' ) );
430 if ( $this->
getVar(
'_WebWindowsAuthentication' ) ==
'windowsauth' ) {
431 $this->
setVar(
'wgDBuser',
'' );
432 $this->
setVar(
'wgDBpassword',
'' );
433 $this->
setVar(
'wgDBWindowsAuthentication',
true );
435 $this->
setVar(
'wgDBWindowsAuthentication',
false );
438 if ( $this->
getVar(
'_CreateDBAccount' )
439 && $this->
getVar(
'_WebWindowsAuthentication' ) ==
'sqlauth'
440 && strval( $this->
getVar(
'wgDBpassword' ) ) ==
''
448 $this->
setVar(
'_CreateDBAccount',
false );
451 $create = $this->
getVar(
'_CreateDBAccount' );
457 $password = $this->
getVar(
'wgDBpassword' );
459 if ( $this->
getVar(
'_WebWindowsAuthentication' ) ==
'windowsauth' ) {
460 $user =
'windowsauth';
461 $password =
'windowsauth';
465 Database::factory(
'mssql', [
466 'host' => $this->
getVar(
'wgDBserver' ),
468 'password' => $password,
471 'tablePrefix' => $this->
getVar(
'wgDBprefix' ),
472 'schema' => $this->
getVar(
'wgDBmwschema' ),
483 # Add our user callback to installSteps, right before the tables are created.
486 'callback' => [ $this,
'setupUser' ],
488 $this->parent->addInstallStep( $callback,
'tables' );
501 $dbName = $this->
getVar(
'wgDBname' );
502 $schemaName = $this->
getVar(
'wgDBmwschema' );
505 "CREATE DATABASE " . $conn->addIdentifierQuotes( $dbName ),
509 $conn->selectDB( $dbName );
512 "CREATE SCHEMA " . $conn->addIdentifierQuotes( $schemaName ),
518 "CREATE FULLTEXT CATALOG " . $conn->addIdentifierQuotes( $schemaName ),
531 $dbUser = $this->
getVar(
'wgDBuser' );
532 if ( $dbUser == $this->
getVar(
'_InstallUser' )
533 || ( $this->
getVar(
'_InstallWindowsAuthentication' ) ==
'windowsauth'
534 && $this->
getVar(
'_WebWindowsAuthentication' ) ==
'windowsauth' ) ) {
543 $dbName = $this->
getVar(
'wgDBname' );
544 $this->db->selectDB( $dbName );
545 $password = $this->
getVar(
'wgDBpassword' );
546 $schemaName = $this->
getVar(
'wgDBmwschema' );
548 if ( $this->
getVar(
'_WebWindowsAuthentication' ) ==
'windowsauth' ) {
549 $dbUser =
'windowsauth';
550 $password =
'windowsauth';
553 if ( $this->
getVar(
'_CreateDBAccount' ) ) {
556 $tryToCreate =
false;
559 $escUser = $this->db->addIdentifierQuotes( $dbUser );
560 $escDb = $this->db->addIdentifierQuotes( $dbName );
561 $escSchema = $this->db->addIdentifierQuotes( $schemaName );
562 $grantableNames = [];
563 if ( $tryToCreate ) {
564 $escPass = $this->db->addQuotes( $password );
569 $this->db->selectDB(
'master' );
570 $logintype = $this->
getVar(
'_WebWindowsAuthentication' ) ==
'windowsauth'
572 :
"WITH PASSWORD = $escPass";
573 $this->db->query(
"CREATE LOGIN $escUser $logintype" );
574 $this->db->selectDB( $dbName );
575 $this->db->query(
"CREATE USER $escUser FOR LOGIN $escUser WITH DEFAULT_SCHEMA = $escSchema" );
577 $grantableNames[] = $dbUser;
579 $this->db->rollback();
580 $status->warning(
'config-install-user-create-failed', $dbUser, $dqe->getMessage() );
585 $this->db->selectDB( $dbName );
586 $this->db->query(
"CREATE USER $escUser FOR LOGIN $escUser WITH DEFAULT_SCHEMA = $escSchema" );
588 $grantableNames[] = $dbUser;
590 $this->db->rollback();
591 $status->warning(
'config-install-user-create-failed', $dbUser, $dqe->getMessage() );
594 $status->warning(
'config-install-user-alreadyexists', $dbUser );
595 $grantableNames[] = $dbUser;
600 $this->db->selectDB( $dbName );
601 foreach ( $grantableNames
as $name ) {
605 'BACKUP DATABASE',
'BACKUP LOG',
'CREATE FUNCTION',
'CREATE PROCEDURE',
606 'CREATE TABLE',
'CREATE VIEW',
'CREATE FULLTEXT CATALOG',
'SHOWPLAN'
608 $fullPrivList = implode(
', ', $fullPrivArr );
610 $this->db->query(
"GRANT $fullPrivList ON DATABASE :: $escDb TO $escUser", __METHOD__ );
611 $this->db->query(
"GRANT CONTROL ON SCHEMA :: $escSchema TO $escUser", __METHOD__ );
616 $privList = implode(
', ', $this->webUserPrivs );
617 $this->db->rollback();
619 $this->db->query(
"GRANT $privList ON SCHEMA :: $escSchema TO $escUser", __METHOD__ );
622 $this->db->rollback();
623 $status->fatal(
'config-install-user-grant-failed', $dbUser, $dqe->getMessage() );
629 $this->db->query(
"GRANT SHOWPLAN ON DATABASE :: $escDb TO $escUser", __METHOD__ );
639 $status = parent::createTables();
643 $searchindex = $this->db->tableName(
'searchindex' );
644 $schema = $this->db->addIdentifierQuotes( $this->
getVar(
'wgDBmwschema' ) );
646 $this->db->query(
"CREATE FULLTEXT INDEX ON $searchindex (si_title, si_text) "
647 .
"KEY INDEX si_page ON $schema" );
649 $status->fatal(
'config-install-tables-failed', $dqe->getMessage() );
659 return array_merge( parent::getGlobalDefaults(), [
660 'wgDBmwschema' =>
'mediawiki',
670 $res = $this->db->selectField(
'sys.sql_logins', 1, [
'name' =>
$user ] );
681 $res = $this->db->selectField(
'sys.sysusers', 1, [
'name' =>
$user ] );
691 $res = $this->db->selectField(
'sys.databases', 1, [
'name' => $dbName ] );
702 $res = $this->db->selectField(
'sys.schemas', 1, [
'name' => $schemaName ] );
713 $res = $this->db->selectField(
'sys.fulltext_catalogs', 1, [
'name' => $catalogName ] );
724 'wgDBname' => $this->
getVar(
'wgDBname' ),
725 'wgDBmwschema' => $this->
getVar(
'wgDBmwschema' ),
726 'wgDBuser' => $this->
getVar(
'wgDBuser' ),
727 'wgDBpassword' => $this->
getVar(
'wgDBpassword' ),
734 $windowsauth = $this->
getVar(
'wgDBWindowsAuthentication' ) ?
'true' :
'false';
736 return "# MSSQL specific settings
737 \$wgDBWindowsAuthentication = {$windowsauth};
738 \$wgDBmwschema = \"{$schema}\";
739 \$wgDBprefix = \"{$prefix}\";";
submitConnectForm()
Set variables based on the request array, assuming it was submitted via the form returned by getConne...
loginExists( $user)
Try to see if the login exists.
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
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
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
createTables()
Create database tables from scratch.
$wgDBpassword
Database user's password.
getLocalSettings()
Get the DBMS-specific options for LocalSettings.php generation.
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
static closeElement( $element)
Returns "</$element>".
$wgDBWindowsAuthentication
Use Windows Authentication instead of $wgDBuser / $wgDBpassword for MS SQL Server.
getPasswordBox( $var, $label, $attribs=[], $helpData="")
Get a labelled password box to configure a local variable.
getSchemaVars()
Get variables to substitute into tables.sql and the SQL patch files.
setupSchemaVars()
Set appropriate schema variables in the current database connection.
when a variable name is used in a it is silently declared as a new masking the global
getRadioSet( $params)
Get a set of labelled radio buttons.
catalogExists( $catalogName)
Try to see if a given fulltext catalog exists We assume we already have the appropriate database sele...
div flags Integer display flags(NO_ACTION_LINK, NO_EXTRA_USER_LINKS) 'LogException' returning false will NOT prevent logging $e
userExists( $user)
Try to see if the user account exists We assume we already have the appropriate database selected.
getVar( $var, $default=null)
Get a variable, taking local defaults into account.
static newGood( $value=null)
Factory function for good results.
preInstall()
Allow DB installers a chance to make last-minute changes before installation occurs.
schemaExists( $schemaName)
Try to see if a given schema exists We assume we already have the appropriate database selected.
Base class for DBMS-specific installation helper classes.
preUpgrade()
Allow DB installers a chance to make checks before upgrade.
databaseExists( $dbName)
Try to see if a given database exists.
Class for setting up the MediaWiki database using Microsoft SQL Server.
canCreateAccounts()
Return true if the install user can create accounts.
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()
setVarsFromRequest( $varNames)
Convenience function to set variables based on form data.
static escapePhpString( $string)
Returns the escaped version of a string of php code.
getGlobalDefaults()
Get a name=>value map of MW configuration globals for the default values.
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()).
getCheckBox( $var, $label, $attribs=[], $helpData="")
Get a labelled checkbox to configure a local boolean variable.