Go to the documentation of this file.
46 '_InstallUser' =>
'postgres',
67 $this->parent->getHelpBox(
'config-db-host-help' )
69 $this->
getTextBox(
'wgDBport',
'config-db-port' ) .
76 $this->parent->getHelpBox(
'config-db-name-help' )
82 $this->parent->getHelpBox(
'config-db-schema-help' )
99 if ( !strlen( $newValues[
'wgDBname'] ) ) {
100 $status->fatal(
'config-missing-db-name' );
101 } elseif ( !preg_match(
'/^[a-zA-Z0-9_]+$/', $newValues[
'wgDBname'] ) ) {
102 $status->fatal(
'config-invalid-db-name', $newValues[
'wgDBname'] );
104 if ( !preg_match(
'/^[a-zA-Z0-9_]*$/', $newValues[
'wgDBmwschema'] ) ) {
105 $status->fatal(
'config-invalid-schema', $newValues[
'wgDBmwschema'] );
126 $version = $conn->getServerVersion();
127 if ( version_compare( $version, $this->minimumVersion ) < 0 ) {
128 return Status::newFatal(
'config-postgres-old', $this->minimumVersion, $version );
131 $this->
setVar(
'wgDBuser', $this->
getVar(
'_InstallUser' ) );
132 $this->
setVar(
'wgDBpassword', $this->
getVar(
'_InstallPassword' ) );
161 $db = Database::factory(
'postgres', [
162 'host' => $this->
getVar(
'wgDBserver' ),
163 'port' => $this->
getVar(
'wgDBport' ),
165 'password' => $password,
168 'keywordTableMap' => [
'user' =>
'mwuser',
'text' =>
'pagecontent' ],
172 $status->fatal(
'config-connection-error',
$e->getMessage() );
184 if ( isset( $this->pgConns[
$type] ) ) {
195 $conn->commit( __METHOD__ );
196 $this->pgConns[
$type] = $conn;
231 $this->
getVar(
'_InstallUser' ),
232 $this->
getVar(
'_InstallPassword' ) );
233 case 'create-schema':
235 $this->
getVar(
'_InstallUser' ),
236 $this->
getVar(
'_InstallPassword' ),
237 $this->
getVar(
'wgDBname' ),
238 $this->
getVar(
'wgDBmwschema' ) );
239 case 'create-tables':
246 $safeRole = $conn->addIdentifierQuotes( $this->
getVar(
'wgDBuser' ) );
247 $conn->query(
"SET ROLE $safeRole" );
252 throw new MWException(
"Invalid special connection type: \"$type\"" );
261 if ( !in_array( $this->
getVar(
'wgDBname' ), $dbs ) ) {
262 array_unshift( $dbs, $this->
getVar(
'wgDBname' ) );
266 foreach ( $dbs
as $db ) {
269 'host' => $this->
getVar(
'wgDBserver' ),
271 'password' => $password,
274 $conn = Database::factory(
'postgres', $p );
278 $error->getMessage() );
280 if ( $conn !==
false ) {
284 if ( $conn !==
false ) {
300 $superuser = $this->
getVar(
'_InstallUser' );
302 $row = $conn->selectRow(
'"pg_catalog"."pg_roles"',
'*',
303 [
'rolname' => $superuser ], __METHOD__ );
314 return $perms->rolsuper ===
't' || $perms->rolcreaterole ===
't';
323 return $perms->rolsuper ===
't';
328 $noCreateMsg =
false;
330 $noCreateMsg =
'config-db-web-no-create-privs';
343 $same = $this->
getVar(
'wgDBuser' ) === $this->
getVar(
'_InstallUser' );
354 $exists =
$status->value->roleExists( $this->
getVar(
'wgDBuser' ) );
359 $create = $this->
getVar(
'_CreateDBAccount' );
361 $this->
setVar(
'_CreateDBAccount',
false );
365 if ( !$create && !$exists ) {
367 $msg =
'config-install-user-missing-create';
369 $msg =
'config-install-user-missing';
382 $this->
getVar(
'wgDBuser' ),
383 $this->
getVar(
'wgDBpassword' ) );
413 $installerId = $conn->selectField(
'"pg_catalog"."pg_roles"',
'oid',
414 [
'rolname' => $this->
getVar(
'_InstallUser' ) ], __METHOD__ );
415 $webId = $conn->selectField(
'"pg_catalog"."pg_roles"',
'oid',
416 [
'rolname' => $this->
getVar(
'wgDBuser' ) ], __METHOD__ );
418 return $this->
isRoleMember( $conn, $installerId, $webId, $this->maxRoleSearchDepth );
429 protected function isRoleMember( $conn, $targetMember, $group, $maxDepth ) {
430 if ( $targetMember === $group ) {
435 $res = $conn->select(
'"pg_catalog"."pg_auth_members"', [
'member' ],
436 [
'roleid' => $group ], __METHOD__ );
437 foreach (
$res as $row ) {
438 if ( $row->member == $targetMember ) {
444 if ( $maxDepth > 0 ) {
445 if ( $this->
isRoleMember( $conn, $targetMember, $row->member, $maxDepth - 1 ) ) {
458 'callback' => [ $this,
'setupUser' ],
461 'name' =>
'pg-commit',
462 'callback' => [ $this,
'commitChanges' ],
465 'name' =>
'pg-plpgsql',
466 'callback' => [ $this,
'setupPLpgSQL' ],
470 'callback' => [ $this,
'setupSchema' ]
473 if ( $this->
getVar(
'_CreateDBAccount' ) ) {
474 $this->parent->addInstallStep( $createDbAccount,
'database' );
476 $this->parent->addInstallStep( $commitCB,
'interwiki' );
477 $this->parent->addInstallStep( $plpgCB,
'database' );
478 $this->parent->addInstallStep( $schemaCB,
'database' );
488 $dbName = $this->
getVar(
'wgDBname' );
490 $exists = $conn->selectField(
'"pg_catalog"."pg_database"',
'1',
491 [
'datname' => $dbName ], __METHOD__ );
493 $safedb = $conn->addIdentifierQuotes( $dbName );
494 $conn->query(
"CREATE DATABASE $safedb", __METHOD__ );
509 $schema = $this->
getVar(
'wgDBmwschema' );
510 $safeschema = $conn->addIdentifierQuotes( $schema );
511 $safeuser = $conn->addIdentifierQuotes( $this->
getVar(
'wgDBuser' ) );
512 if ( !$conn->schemaExists( $schema ) ) {
514 $conn->query(
"CREATE SCHEMA $safeschema AUTHORIZATION $safeuser" );
517 $this->
getVar(
'_InstallUser' ), $schema );
522 $conn->determineCoreSchema( $schema );
528 $this->db->commit( __METHOD__ );
534 if ( !$this->
getVar(
'_CreateDBAccount' ) ) {
544 $safeuser = $conn->addIdentifierQuotes( $this->
getVar(
'wgDBuser' ) );
545 $safepass = $conn->addQuotes( $this->
getVar(
'wgDBpassword' ) );
548 $userExists = $conn->roleExists( $this->
getVar(
'wgDBuser' ) );
549 if ( !$userExists ) {
552 $sql =
"CREATE ROLE $safeuser NOCREATEDB LOGIN PASSWORD $safepass";
558 $sql .=
' ROLE' . $conn->addIdentifierQuotes( $this->
getVar(
'_InstallUser' ) );
561 $conn->query( $sql, __METHOD__ );
564 $this->
getVar(
'wgDBuser' ), $e->getMessage() );
572 $port = $this->
getVar(
'wgDBport' );
573 $schema = $this->
getVar(
'wgDBmwschema' );
575 return "# Postgres specific settings
576 \$wgDBport = \"{$port}\";
577 \$wgDBmwschema = \"{$schema}\";";
583 # Normal user and password are selected after this step, so for now
584 # just copy these two
585 $wgDBuser = $this->
getVar(
'_InstallUser' );
586 $wgDBpassword = $this->
getVar(
'_InstallPassword' );
590 $schema = $this->
getVar(
'wgDBmwschema' );
600 if ( $conn->tableExists(
'archive' ) ) {
601 $status->warning(
'config-install-tables-exist' );
607 $conn->begin( __METHOD__ );
609 if ( !$conn->schemaExists( $schema ) ) {
610 $status->fatal(
'config-install-pg-schema-not-exist' );
615 if ( $error !==
true ) {
616 $conn->reportQueryError( $error, 0,
'', __METHOD__ );
617 $conn->rollback( __METHOD__ );
618 $status->fatal(
'config-install-tables-failed', $error );
620 $conn->commit( __METHOD__ );
633 return array_merge( parent::getGlobalDefaults(), [
634 'wgDBmwschema' =>
'mediawiki',
650 $exists = $conn->selectField(
'"pg_catalog"."pg_language"', 1,
651 [
'lanname' =>
'plpgsql' ], __METHOD__ );
659 $exists = $conn->selectField(
660 [
'"pg_catalog"."pg_class"',
'"pg_catalog"."pg_namespace"' ],
663 'pg_namespace.oid=relnamespace',
664 'nspname' =>
'pg_catalog',
665 'relname' =>
'pg_pltemplate',
670 $conn->query(
'CREATE LANGUAGE plpgsql' );
preInstall()
Allow DB installers a chance to make last-minute changes before installation occurs.
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
openConnectionToAnyDB( $user, $password)
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
submitSettingsForm()
Set variables based on the request array, assuming it was submitted via the form return by getSetting...
static newFatal( $message)
Factory function for fatal errors.
getTextBox( $var, $label, $attribs=[], $helpData="")
Get a labelled text box to configure a local variable.
openConnectionWithParams( $user, $password, $dbName, $schema)
Open a PG connection with given parameters.
do that in ParserLimitReportFormat instead use this to modify the parameters of the image and a DIV can begin in one section and end in another Make sure your code can handle that case gracefully See the EditSectionClearerLink extension for an example zero but section is usually empty its values are the globals values before the output is cached my talk my contributions etc etc otherwise the built in rate limiting checks are if enabled allows for interception of redirect as a string mapping parameter names to values & $type
preUpgrade()
Allow DB installers a chance to make checks before upgrade.
$wgDBpassword
Database user's password.
isRoleMember( $conn, $targetMember, $group, $maxDepth)
Recursive helper for canCreateObjectsForWebUser().
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>".
createTables()
Create database tables from scratch.
submitWebUserBox()
Submit the form from getWebUserBox().
getInstallUserPermissions()
openPgConnection( $type)
Get a connection of a specific PostgreSQL-specific type.
getGlobalDefaults()
Get a name=>value map of MW configuration globals for the default values.
when a variable name is used in a it is silently declared as a new masking the global
getSchemaPath( $db)
Return a path to the DBMS-specific schema file, otherwise default to tables.sql.
getWebUserBox( $noCreateMsg=false)
Get a standard web-user fieldset.
getPgConnection( $type)
Get a special type of connection.
submitConnectForm()
Set variables based on the request array, assuming it was submitted via the form returned by getConne...
div flags Integer display flags(NO_ACTION_LINK, NO_EXTRA_USER_LINKS) 'LogException' returning false will NOT prevent logging $e
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.
static newGood( $value=null)
Factory function for good results.
getLocalSettings()
Get the DBMS-specific options for LocalSettings.php generation.
submitInstallUserBox()
Submit a standard install user fieldset.
Base class for DBMS-specific installation helper classes.
setupDatabase()
Create the database and return a Status object indicating success or failure.
canCreateObjectsForWebUser()
Returns true if the install user is able to create objects owned by the web user, false otherwise.
openConnection()
Open a connection to the database using the administrative user/password currently defined in the ses...
enableLB()
Set up LBFactory so that wfGetDB() etc.
getSettingsForm()
Get HTML for a web form that retrieves settings used for installation.
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.
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()).
Class for setting up the MediaWiki database using Postgres.
getConnectForm()
Get HTML for a web form that configures this database.
getName()
Return the internal name, e.g.