http://www.mediawiki.org/wiki/Special:Code/MediaWiki/89807
Revision: 89807
Author: mah
Date: 2011-06-09 22:30:52 +0000 (Thu, 09 Jun 2011)
Log Message:
-----------
revert r88929
Modified Paths:
--------------
branches/REL1_17/phase3/includes/installer/DatabaseInstaller.php
branches/REL1_17/phase3/includes/installer/Installer.i18n.php
branches/REL1_17/phase3/includes/installer/MysqlInstaller.php
branches/REL1_17/phase3/includes/installer/OracleInstaller.php
branches/REL1_17/phase3/includes/installer/PostgresInstaller.php
branches/REL1_17/phase3/includes/installer/PostgresUpdater.php
branches/REL1_17/phase3/includes/installer/SqliteInstaller.php
Modified: branches/REL1_17/phase3/includes/installer/DatabaseInstaller.php
===================================================================
--- branches/REL1_17/phase3/includes/installer/DatabaseInstaller.php
2011-06-09 22:17:00 UTC (rev 89806)
+++ branches/REL1_17/phase3/includes/installer/DatabaseInstaller.php
2011-06-09 22:30:52 UTC (rev 89807)
@@ -102,7 +102,7 @@
*
* @return Status
*/
- public abstract function openConnection( $dbName = null );
+ public abstract function openConnection();
/**
* Create the database and return a Status object indicating success or
@@ -121,14 +121,11 @@
*
* @return Status
*/
- public function getConnection( $dbName = null ) {
- if ( isset($this->db) && $this->db ) { /* Weirdly get E_STRICT
-
* errors without the
-
* isset */
+ public function getConnection() {
+ if ( $this->db ) {
return Status::newGood( $this->db );
}
-
- $status = $this->openConnection( $dbName );
+ $status = $this->openConnection();
if ( $status->isOK() ) {
$this->db = $status->value;
// Enable autocommit
Modified: branches/REL1_17/phase3/includes/installer/Installer.i18n.php
===================================================================
--- branches/REL1_17/phase3/includes/installer/Installer.i18n.php
2011-06-09 22:17:00 UTC (rev 89806)
+++ branches/REL1_17/phase3/includes/installer/Installer.i18n.php
2011-06-09 22:30:52 UTC (rev 89807)
@@ -253,7 +253,7 @@
Use only ASCII letters (a-z, A-Z), numbers (0-9), underscores (_) and hyphens
(-).',
'config-connection-error' => '$1.
-Check the host, username and password and try again.',
+Check the host, username and password below and try again.',
'config-invalid-schema' => 'Invalid schema for MediaWiki "$1".
Use only ASCII letters (a-z, A-Z), numbers (0-9) and underscores (_).',
'config-db-sys-create-oracle' => 'Installer only supports using a
SYSDBA account for creating a new account.',
Modified: branches/REL1_17/phase3/includes/installer/MysqlInstaller.php
===================================================================
--- branches/REL1_17/phase3/includes/installer/MysqlInstaller.php
2011-06-09 22:17:00 UTC (rev 89806)
+++ branches/REL1_17/phase3/includes/installer/MysqlInstaller.php
2011-06-09 22:30:52 UTC (rev 89807)
@@ -111,7 +111,7 @@
return $status;
}
- public function openConnection( $dbName = null ) {
+ public function openConnection() {
$status = Status::newGood();
try {
$db = new DatabaseMysql(
Modified: branches/REL1_17/phase3/includes/installer/OracleInstaller.php
===================================================================
--- branches/REL1_17/phase3/includes/installer/OracleInstaller.php
2011-06-09 22:17:00 UTC (rev 89806)
+++ branches/REL1_17/phase3/includes/installer/OracleInstaller.php
2011-06-09 22:30:52 UTC (rev 89807)
@@ -127,7 +127,7 @@
return $status;
}
- public function openConnection( $dbName = null ) {
+ public function openConnection() {
$status = Status::newGood();
try {
$db = new DatabaseOracle(
Modified: branches/REL1_17/phase3/includes/installer/PostgresInstaller.php
===================================================================
--- branches/REL1_17/phase3/includes/installer/PostgresInstaller.php
2011-06-09 22:17:00 UTC (rev 89806)
+++ branches/REL1_17/phase3/includes/installer/PostgresInstaller.php
2011-06-09 22:30:52 UTC (rev 89807)
@@ -101,31 +101,22 @@
return $status;
}
- public function openConnection( $dbName = null ) {
+ public function openConnection() {
$status = Status::newGood();
try {
if ( $this->useAdmin ) {
- if ( $dbName === null ) $dbName = 'postgres';
-
$db = new DatabasePostgres(
$this->getVar( 'wgDBserver' ),
$this->getVar( '_InstallUser' ),
$this->getVar( '_InstallPassword' ),
- $dbName );
+ 'postgres' );
} else {
- if ( $dbName === null ) $dbName =
$this->getVar( 'wgDBname' );
-
$db = new DatabasePostgres(
$this->getVar( 'wgDBserver' ),
$this->getVar( 'wgDBuser' ),
$this->getVar( 'wgDBpassword' ),
- $dbName );
+ $this->getVar( 'wgDBname' ) );
}
-
- if( $db === null ) throw new DBConnectionError("Unknown
problem while connecting.");
- $safeschema = $db->addIdentifierQuotes( $this->getVar(
'wgDBmwschema' ) );
- if( $db->schemaExists( $this->getVar( 'wgDBmwschema' )
) ) $db->query( "SET search_path = $safeschema" );
-
$status->value = $db;
} catch ( DBConnectionError $e ) {
$status->fatal( 'config-connection-error',
$e->getMessage() );
@@ -143,15 +134,15 @@
$superuser = $this->getVar( '_InstallUser' );
- $rights = $conn->selectField( 'pg_catalog.pg_roles',
- 'CASE WHEN rolsuper then 1
- WHEN rolcreatedb then 2
- ELSE 3
- END as rights',
- array( 'rolname' => $superuser ), __METHOD__
+ $rights = $conn->selectField( 'pg_catalog.pg_user',
+ 'CASE WHEN usesuper IS TRUE THEN
+ CASE WHEN usecreatedb IS TRUE THEN 3 ELSE 1 END
+ ELSE CASE WHEN usecreatedb IS TRUE THEN 2 ELSE
0 END
+ END AS rights',
+ array( 'usename' => $superuser ), __METHOD__
);
- if( !$rights || $rights == 3 ) {
+ if( !$rights || ( $rights != 1 && $rights != 3 ) ) {
return false;
}
@@ -235,12 +226,11 @@
$rows = $conn->numRows( $conn->query( $SQL ) );
$safedb = $conn->addIdentifierQuotes( $dbName );
if( !$rows ) {
- $conn->query( "CREATE DATABASE $safedb", __METHOD__ );
- $conn->query( "GRANT ALL ON DATABASE $safedb to
$safeuser", __METHOD__ );
+ $conn->query( "CREATE DATABASE $safedb OWNER
$safeuser", __METHOD__ );
} else {
- $conn->query( "GRANT ALL ON DATABASE $safedb TO
$safeuser", __METHOD__ );
+ $conn->query( "ALTER DATABASE $safedb OWNER TO
$safeuser", __METHOD__ );
}
-
+
// Now that we've established the real database exists, connect
to it
// Because we do not want the same connection, forcibly expire
the existing conn
$this->db = null;
@@ -297,18 +287,17 @@
$safeschema = $this->db->addIdentifierQuotes( $schema );
$rows = $this->db->numRows(
- $this->db->query( "SELECT 1 FROM pg_catalog.pg_roles
WHERE rolname = $safeusercheck" )
+ $this->db->query( "SELECT 1 FROM pg_catalog.pg_shadow
WHERE usename = $safeusercheck" )
);
if ( $rows < 1 ) {
- $res = $this->db->query( "CREATE ROLE $safeuser
NOCREATEDB LOGIN PASSWORD $safepass", __METHOD__ );
+ $res = $this->db->query( "CREATE USER $safeuser
NOCREATEDB PASSWORD $safepass", __METHOD__ );
if ( $res !== true && !( $res instanceOf ResultWrapper
) ) {
$status->fatal( 'config-install-user-failed',
$this->getVar( 'wgDBuser' ), $res );
}
if( $status->isOK() ) {
- $this->db->query("ALTER ROLE $safeuser LOGIN");
+ $this->db->query("ALTER USER $safeuser SET
search_path = $safeschema");
}
}
- $this->db->query("ALTER ROLE $safeuser SET search_path =
$safeschema, public");
return $status;
}
@@ -348,11 +337,12 @@
$this->db->begin( __METHOD__ );
- // getConnection() should have already selected the schema if
it exists
if( !$this->db->schemaExists( $schema ) ) {
$status->error( 'config-install-pg-schema-not-exist' );
return $status;
}
+ $safeschema = $this->db->addIdentifierQuotes( $schema );
+ $this->db->query( "SET search_path = $safeschema" );
$error = $this->db->sourceFile( $this->db->getSchema() );
if( $error !== true ) {
$this->db->reportQueryError( $error, 0, '', __METHOD__
);
@@ -369,18 +359,12 @@
}
public function setupPLpgSQL() {
- $this->db = null;
$this->useAdmin = true;
- $dbName = $this->getVar( 'wgDBname' );
- $status = $this->getConnection( $dbName );
+ $status = $this->getConnection();
if ( !$status->isOK() ) {
return $status;
}
- $this->db = $status->value;
- /* Admin user has to be connected to the db it just
- created to satisfy ownership requirements for
- "CREATE LANGAUGE" */
$rows = $this->db->numRows(
$this->db->query( "SELECT 1 FROM pg_catalog.pg_language
WHERE lanname = 'plpgsql'" )
);
@@ -389,6 +373,7 @@
$SQL = "SELECT 1 FROM pg_catalog.pg_class c JOIN
pg_catalog.pg_namespace n ON (n.oid = c.relnamespace) ".
"WHERE relname = 'pg_pltemplate' AND
nspname='pg_catalog'";
$rows = $this->db->numRows( $this->db->query( $SQL ) );
+ $dbName = $this->getVar( 'wgDBname' );
if ( $rows >= 1 ) {
$result = $this->db->query( 'CREATE LANGUAGE
plpgsql' );
if ( !$result ) {
Modified: branches/REL1_17/phase3/includes/installer/PostgresUpdater.php
===================================================================
--- branches/REL1_17/phase3/includes/installer/PostgresUpdater.php
2011-06-09 22:17:00 UTC (rev 89806)
+++ branches/REL1_17/phase3/includes/installer/PostgresUpdater.php
2011-06-09 22:30:52 UTC (rev 89807)
@@ -79,6 +79,7 @@
array( 'addPgField', 'logging', 'log_id',
"INTEGER NOT NULL PRIMARY KEY DEFAULT nextval('logging_log_id_seq')" ),
array( 'addPgField', 'logging', 'log_params',
'TEXT' ),
array( 'addPgField', 'mwuser', 'user_editcount',
'INTEGER' ),
+ array( 'addPgField', 'mwuser', 'user_hidden',
'SMALLINT NOT NULL DEFAULT 0' ),
array( 'addPgField', 'mwuser',
'user_newpass_time', 'TIMESTAMPTZ' ),
array( 'addPgField', 'oldimage', 'oi_deleted',
'SMALLINT NOT NULL DEFAULT 0' ),
array( 'addPgField', 'oldimage', 'oi_major_mime',
"TEXT NOT NULL DEFAULT 'unknown'" ),
Modified: branches/REL1_17/phase3/includes/installer/SqliteInstaller.php
===================================================================
--- branches/REL1_17/phase3/includes/installer/SqliteInstaller.php
2011-06-09 22:17:00 UTC (rev 89806)
+++ branches/REL1_17/phase3/includes/installer/SqliteInstaller.php
2011-06-09 22:30:52 UTC (rev 89807)
@@ -103,7 +103,7 @@
return Status::newGood();
}
- public function openConnection( $dbName = null ) {
+ public function openConnection() {
global $wgSQLiteDataDir;
$status = Status::newGood();
_______________________________________________
MediaWiki-CVS mailing list
[email protected]
https://lists.wikimedia.org/mailman/listinfo/mediawiki-cvs