Go to the documentation of this file.
42 '_InstallUser' =>
'postgres',
63 $this->parent->getHelpBox(
'config-db-host-help' )
65 $this->
getTextBox(
'wgDBport',
'config-db-port' ) .
72 $this->parent->getHelpBox(
'config-db-name-help' )
78 $this->parent->getHelpBox(
'config-db-schema-help' )
87 'wgDBserver',
'wgDBport',
'wgDBname',
'wgDBmwschema',
88 '_InstallUser',
'_InstallPassword'
93 if ( !strlen( $newValues[
'wgDBname'] ) ) {
94 $status->fatal(
'config-missing-db-name' );
95 } elseif ( !preg_match(
'/^[a-zA-Z0-9_]+$/', $newValues[
'wgDBname'] ) ) {
96 $status->fatal(
'config-invalid-db-name', $newValues[
'wgDBname'] );
98 if ( !preg_match(
'/^[a-zA-Z0-9_]*$/', $newValues[
'wgDBmwschema'] ) ) {
99 $status->fatal(
'config-invalid-schema', $newValues[
'wgDBmwschema'] );
101 if ( !strlen( $newValues[
'_InstallUser'] ) ) {
102 $status->fatal(
'config-db-username-empty' );
104 if ( !strlen( $newValues[
'_InstallPassword'] ) ) {
105 $status->fatal(
'config-db-password-empty', $newValues[
'_InstallUser'] );
109 if ( $status->isOK() ) {
112 if ( !$status->isOK() ) {
117 if ( !$status->isOK() ) {
123 $conn = $status->value;
126 $version = $conn->getServerVersion();
127 if ( version_compare(
$version, $this->minimumVersion ) < 0 ) {
131 $this->
setVar(
'wgDBuser', $this->
getVar(
'_InstallUser' ) );
132 $this->
setVar(
'wgDBpassword', $this->
getVar(
'_InstallPassword' ) );
139 if ( $status->isOK() ) {
140 $this->db = $status->value;
161 $this->
getVar(
'wgDBserver' ),
166 $status->value =
$db;
168 $status->fatal(
'config-connection-error',
$e->getMessage() );
180 if ( isset( $this->pgConns[
$type] ) ) {
185 if ( $status->isOK() ) {
189 $conn = $status->value;
191 $conn->commit( __METHOD__ );
192 $this->pgConns[
$type] = $conn;
228 $this->
getVar(
'_InstallUser' ),
229 $this->
getVar(
'_InstallPassword' ) );
230 case 'create-schema':
232 $this->
getVar(
'_InstallUser' ),
233 $this->
getVar(
'_InstallPassword' ),
234 $this->
getVar(
'wgDBname' ) );
235 case 'create-tables':
237 if ( $status->isOK() ) {
241 $conn = $status->value;
242 $safeRole = $conn->addIdentifierQuotes( $this->
getVar(
'wgDBuser' ) );
243 $conn->query(
"SET ROLE $safeRole" );
248 throw new MWException(
"Invalid special connection type: \"$type\"" );
257 if ( !in_array( $this->
getVar(
'wgDBname' ), $dbs ) ) {
258 array_unshift( $dbs, $this->
getVar(
'wgDBname' ) );
262 foreach ( $dbs
as $db ) {
265 $this->
getVar(
'wgDBserver' ),
271 $status->fatal(
'config-pg-test-error',
$db,
274 if ( $conn !==
false ) {
278 if ( $conn !==
false ) {
287 if ( !$status->isOK() ) {
293 $conn = $status->value;
294 $superuser = $this->
getVar(
'_InstallUser' );
296 $row = $conn->selectRow(
'"pg_catalog"."pg_roles"',
'*',
297 array(
'rolname' => $superuser ), __METHOD__ );
308 return $perms->rolsuper ===
't' || $perms->rolcreaterole ===
't';
317 return $perms->rolsuper ===
't';
322 $noCreateMsg =
false;
324 $noCreateMsg =
'config-db-web-no-create-privs';
333 if ( !$status->isOK() ) {
337 $same = $this->
getVar(
'wgDBuser' ) === $this->
getVar(
'_InstallUser' );
345 if ( !$status->isOK() ) {
348 $exists = $status->value->roleExists( $this->
getVar(
'wgDBuser' ) );
353 $create = $this->
getVar(
'_CreateDBAccount' );
355 $this->
setVar(
'_CreateDBAccount',
false );
359 if ( !$create && !$exists ) {
361 $msg =
'config-install-user-missing-create';
363 $msg =
'config-install-user-missing';
376 $this->
getVar(
'wgDBuser' ),
377 $this->
getVar(
'wgDBpassword' ) );
378 if ( !$status->isOK() ) {
403 if ( !$status->isOK() ) {
406 $conn = $status->value;
407 $installerId = $conn->selectField(
'"pg_catalog"."pg_roles"',
'oid',
408 array(
'rolname' => $this->
getVar(
'_InstallUser' ) ), __METHOD__ );
409 $webId = $conn->selectField(
'"pg_catalog"."pg_roles"',
'oid',
410 array(
'rolname' => $this->
getVar(
'wgDBuser' ) ), __METHOD__ );
412 return $this->
isRoleMember( $conn, $installerId, $webId, $this->maxRoleSearchDepth );
423 protected function isRoleMember( $conn, $targetMember, $group, $maxDepth ) {
424 if ( $targetMember === $group ) {
429 $res = $conn->select(
'"pg_catalog"."pg_auth_members"',
array(
'member' ),
430 array(
'roleid' => $group ), __METHOD__ );
431 foreach (
$res as $row ) {
432 if ( $row->member == $targetMember ) {
438 if ( $maxDepth > 0 ) {
439 if ( $this->
isRoleMember( $conn, $targetMember, $row->member, $maxDepth - 1 ) ) {
450 $createDbAccount =
array(
452 'callback' =>
array( $this,
'setupUser' ),
455 'name' =>
'pg-commit',
456 'callback' =>
array( $this,
'commitChanges' ),
459 'name' =>
'pg-plpgsql',
460 'callback' =>
array( $this,
'setupPLpgSQL' ),
464 'callback' =>
array( $this,
'setupSchema' )
467 if ( $this->
getVar(
'_CreateDBAccount' ) ) {
468 $this->parent->addInstallStep( $createDbAccount,
'database' );
470 $this->parent->addInstallStep( $commitCB,
'interwiki' );
471 $this->parent->addInstallStep( $plpgCB,
'database' );
472 $this->parent->addInstallStep( $schemaCB,
'database' );
477 if ( !$status->isOK() ) {
480 $conn = $status->value;
482 $dbName = $this->
getVar(
'wgDBname' );
484 $exists = $conn->selectField(
'"pg_catalog"."pg_database"',
'1',
485 array(
'datname' => $dbName ), __METHOD__ );
487 $safedb = $conn->addIdentifierQuotes( $dbName );
488 $conn->query(
"CREATE DATABASE $safedb", __METHOD__ );
497 if ( !$status->isOK() ) {
500 $conn = $status->value;
503 $schema = $this->
getVar(
'wgDBmwschema' );
504 $safeschema = $conn->addIdentifierQuotes( $schema );
505 $safeuser = $conn->addIdentifierQuotes( $this->
getVar(
'wgDBuser' ) );
506 if ( !$conn->schemaExists( $schema ) ) {
508 $conn->query(
"CREATE SCHEMA $safeschema AUTHORIZATION $safeuser" );
511 $this->
getVar(
'_InstallUser' ), $schema );
516 $conn->determineCoreSchema( $schema );
522 $this->db->commit( __METHOD__ );
528 if ( !$this->
getVar(
'_CreateDBAccount' ) ) {
533 if ( !$status->isOK() ) {
536 $conn = $status->value;
538 $safeuser = $conn->addIdentifierQuotes( $this->
getVar(
'wgDBuser' ) );
539 $safepass = $conn->addQuotes( $this->
getVar(
'wgDBpassword' ) );
542 $userExists = $conn->roleExists( $this->
getVar(
'wgDBuser' ) );
543 if ( !$userExists ) {
546 $sql =
"CREATE ROLE $safeuser NOCREATEDB LOGIN PASSWORD $safepass";
552 $sql .=
' ROLE' . $conn->addIdentifierQuotes( $this->
getVar(
'_InstallUser' ) );
555 $conn->query( $sql, __METHOD__ );
558 $this->
getVar(
'wgDBuser' ), $e->getMessage() );
566 $port = $this->
getVar(
'wgDBport' );
567 $schema = $this->
getVar(
'wgDBmwschema' );
569 return "# Postgres specific settings
570 \$wgDBport = \"{$port}\";
571 \$wgDBmwschema = \"{$schema}\";";
575 global $wgDBuser, $wgDBpassword;
577 # Normal user and password are selected after this step, so for now
578 # just copy these two
579 $wgDBuser = $this->
getVar(
'_InstallUser' );
580 $wgDBpassword = $this->
getVar(
'_InstallPassword' );
584 $schema = $this->
getVar(
'wgDBmwschema' );
587 if ( !$status->isOK() ) {
594 $conn = $status->value;
596 if ( $conn->tableExists(
'archive' ) ) {
597 $status->warning(
'config-install-tables-exist' );
603 $conn->begin( __METHOD__ );
605 if ( !$conn->schemaExists( $schema ) ) {
606 $status->fatal(
'config-install-pg-schema-not-exist' );
610 $error = $conn->sourceFile( $conn->getSchemaPath() );
612 $conn->reportQueryError(
$error, 0,
'', __METHOD__ );
613 $conn->rollback( __METHOD__ );
614 $status->fatal(
'config-install-tables-failed',
$error );
616 $conn->commit( __METHOD__ );
619 if ( $status->isOk() ) {
630 if ( !$status->isOK() ) {
636 $conn = $status->value;
638 $exists = $conn->selectField(
'"pg_catalog"."pg_language"', 1,
639 array(
'lanname' =>
'plpgsql' ), __METHOD__ );
647 $exists = $conn->selectField(
648 array(
'"pg_catalog"."pg_class"',
'"pg_catalog"."pg_namespace"' ),
651 'pg_namespace.oid=relnamespace',
652 'nspname' =>
'pg_catalog',
653 'relname' =>
'pg_pltemplate',
658 $conn->query(
'CREATE LANGUAGE plpgsql' );
preInstall()
Allow DB installers a chance to make last-minute changes before installation occurs.
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
openConnectionToAnyDB( $user, $password)
submitSettingsForm()
Set variables based on the request array, assuming it was submitted via the form return by getSetting...
static newGood( $value=null)
Factory function for good results.
preUpgrade()
Allow DB installers a chance to make checks before upgrade.
isRoleMember( $conn, $targetMember, $group, $maxDepth)
Recursive helper for canCreateObjectsForWebUser().
getTextBox( $var, $label, $attribs=array(), $helpData="")
Get a labelled text box to configure a local variable.
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 '/'...
openConnectionWithParams( $user, $password, $dbName)
Open a PG connection with given parameters.
createTables()
Create database tables from scratch.
static element( $element, $attribs=array(), $contents='')
Identical to rawElement(), but HTML-escapes $contents (like Xml::element()).
submitWebUserBox()
Submit the form from getWebUserBox().
getInstallUserPermissions()
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 "<
openPgConnection( $type)
Get a connection of a specific PostgreSQL-specific type.
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
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...
DatabaseBase $db
The database connection.
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.
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.
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
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
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.
usually copyright or history_copyright This message must be in HTML not wikitext $subpages will be ignored and the rest of subPageSubtitle() will run. 'SkinTemplateBuildNavUrlsNav_urlsAfterPermalink' whether MediaWiki currently thinks this is a CSS JS page Hooks may change this value to override the return value of Title::isCssOrJsPage(). 'TitleIsAlwaysKnown' whether MediaWiki currently thinks this page is known isMovable() always returns false. $title whether MediaWiki currently thinks this page is movable Hooks may change this value to override the return value of Title::isMovable(). 'TitleIsWikitextPage' whether MediaWiki currently thinks this is a wikitext page Hooks may change this value to override the return value of Title::isWikitextPage() 'TitleMove' use UploadVerification and UploadVerifyFile instead where the first element is the message key and the remaining elements are used as parameters to the message based on mime etc Preferred in most cases over UploadVerification object with all info about the upload string as detected by MediaWiki Handlers will typically only apply for specific mime types object & $error
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.
static newFatal( $message)
Factory function for fatal errors.