Index: branches/REL1_17/phase3/includes/installer/PostgresUpdater.php |
— | — | @@ -79,6 +79,7 @@ |
80 | 80 | array( 'addPgField', 'logging', 'log_id', "INTEGER NOT NULL PRIMARY KEY DEFAULT nextval('logging_log_id_seq')" ), |
81 | 81 | array( 'addPgField', 'logging', 'log_params', 'TEXT' ), |
82 | 82 | array( 'addPgField', 'mwuser', 'user_editcount', 'INTEGER' ), |
| 83 | + array( 'addPgField', 'mwuser', 'user_hidden', 'SMALLINT NOT NULL DEFAULT 0' ), |
83 | 84 | array( 'addPgField', 'mwuser', 'user_newpass_time', 'TIMESTAMPTZ' ), |
84 | 85 | array( 'addPgField', 'oldimage', 'oi_deleted', 'SMALLINT NOT NULL DEFAULT 0' ), |
85 | 86 | array( 'addPgField', 'oldimage', 'oi_major_mime', "TEXT NOT NULL DEFAULT 'unknown'" ), |
Index: branches/REL1_17/phase3/includes/installer/Installer.i18n.php |
— | — | @@ -253,7 +253,7 @@ |
254 | 254 | Use only ASCII letters (a-z, A-Z), numbers (0-9), underscores (_) and hyphens (-).', |
255 | 255 | 'config-connection-error' => '$1. |
256 | 256 | |
257 | | -Check the host, username and password and try again.', |
| 257 | +Check the host, username and password below and try again.', |
258 | 258 | 'config-invalid-schema' => 'Invalid schema for MediaWiki "$1". |
259 | 259 | Use only ASCII letters (a-z, A-Z), numbers (0-9) and underscores (_).', |
260 | 260 | 'config-db-sys-create-oracle' => 'Installer only supports using a SYSDBA account for creating a new account.', |
Index: branches/REL1_17/phase3/includes/installer/SqliteInstaller.php |
— | — | @@ -103,7 +103,7 @@ |
104 | 104 | return Status::newGood(); |
105 | 105 | } |
106 | 106 | |
107 | | - public function openConnection( $dbName = null ) { |
| 107 | + public function openConnection() { |
108 | 108 | global $wgSQLiteDataDir; |
109 | 109 | |
110 | 110 | $status = Status::newGood(); |
Index: branches/REL1_17/phase3/includes/installer/DatabaseInstaller.php |
— | — | @@ -102,7 +102,7 @@ |
103 | 103 | * |
104 | 104 | * @return Status |
105 | 105 | */ |
106 | | - public abstract function openConnection( $dbName = null ); |
| 106 | + public abstract function openConnection(); |
107 | 107 | |
108 | 108 | /** |
109 | 109 | * Create the database and return a Status object indicating success or |
— | — | @@ -121,14 +121,11 @@ |
122 | 122 | * |
123 | 123 | * @return Status |
124 | 124 | */ |
125 | | - public function getConnection( $dbName = null ) { |
126 | | - if ( isset($this->db) && $this->db ) { /* Weirdly get E_STRICT |
127 | | - * errors without the |
128 | | - * isset */ |
| 125 | + public function getConnection() { |
| 126 | + if ( $this->db ) { |
129 | 127 | return Status::newGood( $this->db ); |
130 | 128 | } |
131 | | - |
132 | | - $status = $this->openConnection( $dbName ); |
| 129 | + $status = $this->openConnection(); |
133 | 130 | if ( $status->isOK() ) { |
134 | 131 | $this->db = $status->value; |
135 | 132 | // Enable autocommit |
Index: branches/REL1_17/phase3/includes/installer/MysqlInstaller.php |
— | — | @@ -111,7 +111,7 @@ |
112 | 112 | return $status; |
113 | 113 | } |
114 | 114 | |
115 | | - public function openConnection( $dbName = null ) { |
| 115 | + public function openConnection() { |
116 | 116 | $status = Status::newGood(); |
117 | 117 | try { |
118 | 118 | $db = new DatabaseMysql( |
Index: branches/REL1_17/phase3/includes/installer/OracleInstaller.php |
— | — | @@ -127,7 +127,7 @@ |
128 | 128 | return $status; |
129 | 129 | } |
130 | 130 | |
131 | | - public function openConnection( $dbName = null ) { |
| 131 | + public function openConnection() { |
132 | 132 | $status = Status::newGood(); |
133 | 133 | try { |
134 | 134 | $db = new DatabaseOracle( |
Index: branches/REL1_17/phase3/includes/installer/PostgresInstaller.php |
— | — | @@ -101,31 +101,22 @@ |
102 | 102 | return $status; |
103 | 103 | } |
104 | 104 | |
105 | | - public function openConnection( $dbName = null ) { |
| 105 | + public function openConnection() { |
106 | 106 | $status = Status::newGood(); |
107 | 107 | try { |
108 | 108 | if ( $this->useAdmin ) { |
109 | | - if ( $dbName === null ) $dbName = 'postgres'; |
110 | | - |
111 | 109 | $db = new DatabasePostgres( |
112 | 110 | $this->getVar( 'wgDBserver' ), |
113 | 111 | $this->getVar( '_InstallUser' ), |
114 | 112 | $this->getVar( '_InstallPassword' ), |
115 | | - $dbName ); |
| 113 | + 'postgres' ); |
116 | 114 | } else { |
117 | | - if ( $dbName === null ) $dbName = $this->getVar( 'wgDBname' ); |
118 | | - |
119 | 115 | $db = new DatabasePostgres( |
120 | 116 | $this->getVar( 'wgDBserver' ), |
121 | 117 | $this->getVar( 'wgDBuser' ), |
122 | 118 | $this->getVar( 'wgDBpassword' ), |
123 | | - $dbName ); |
| 119 | + $this->getVar( 'wgDBname' ) ); |
124 | 120 | } |
125 | | - |
126 | | - if( $db === null ) throw new DBConnectionError("Unknown problem while connecting."); |
127 | | - $safeschema = $db->addIdentifierQuotes( $this->getVar( 'wgDBmwschema' ) ); |
128 | | - if( $db->schemaExists( $this->getVar( 'wgDBmwschema' ) ) ) $db->query( "SET search_path = $safeschema" ); |
129 | | - |
130 | 121 | $status->value = $db; |
131 | 122 | } catch ( DBConnectionError $e ) { |
132 | 123 | $status->fatal( 'config-connection-error', $e->getMessage() ); |
— | — | @@ -143,15 +134,15 @@ |
144 | 135 | |
145 | 136 | $superuser = $this->getVar( '_InstallUser' ); |
146 | 137 | |
147 | | - $rights = $conn->selectField( 'pg_catalog.pg_roles', |
148 | | - 'CASE WHEN rolsuper then 1 |
149 | | - WHEN rolcreatedb then 2 |
150 | | - ELSE 3 |
151 | | - END as rights', |
152 | | - array( 'rolname' => $superuser ), __METHOD__ |
| 138 | + $rights = $conn->selectField( 'pg_catalog.pg_user', |
| 139 | + 'CASE WHEN usesuper IS TRUE THEN |
| 140 | + CASE WHEN usecreatedb IS TRUE THEN 3 ELSE 1 END |
| 141 | + ELSE CASE WHEN usecreatedb IS TRUE THEN 2 ELSE 0 END |
| 142 | + END AS rights', |
| 143 | + array( 'usename' => $superuser ), __METHOD__ |
153 | 144 | ); |
154 | 145 | |
155 | | - if( !$rights || $rights == 3 ) { |
| 146 | + if( !$rights || ( $rights != 1 && $rights != 3 ) ) { |
156 | 147 | return false; |
157 | 148 | } |
158 | 149 | |
— | — | @@ -235,12 +226,11 @@ |
236 | 227 | $rows = $conn->numRows( $conn->query( $SQL ) ); |
237 | 228 | $safedb = $conn->addIdentifierQuotes( $dbName ); |
238 | 229 | if( !$rows ) { |
239 | | - $conn->query( "CREATE DATABASE $safedb", __METHOD__ ); |
240 | | - $conn->query( "GRANT ALL ON DATABASE $safedb to $safeuser", __METHOD__ ); |
| 230 | + $conn->query( "CREATE DATABASE $safedb OWNER $safeuser", __METHOD__ ); |
241 | 231 | } else { |
242 | | - $conn->query( "GRANT ALL ON DATABASE $safedb TO $safeuser", __METHOD__ ); |
| 232 | + $conn->query( "ALTER DATABASE $safedb OWNER TO $safeuser", __METHOD__ ); |
243 | 233 | } |
244 | | - |
| 234 | + |
245 | 235 | // Now that we've established the real database exists, connect to it |
246 | 236 | // Because we do not want the same connection, forcibly expire the existing conn |
247 | 237 | $this->db = null; |
— | — | @@ -297,18 +287,17 @@ |
298 | 288 | $safeschema = $this->db->addIdentifierQuotes( $schema ); |
299 | 289 | |
300 | 290 | $rows = $this->db->numRows( |
301 | | - $this->db->query( "SELECT 1 FROM pg_catalog.pg_roles WHERE rolname = $safeusercheck" ) |
| 291 | + $this->db->query( "SELECT 1 FROM pg_catalog.pg_shadow WHERE usename = $safeusercheck" ) |
302 | 292 | ); |
303 | 293 | if ( $rows < 1 ) { |
304 | | - $res = $this->db->query( "CREATE ROLE $safeuser NOCREATEDB LOGIN PASSWORD $safepass", __METHOD__ ); |
| 294 | + $res = $this->db->query( "CREATE USER $safeuser NOCREATEDB PASSWORD $safepass", __METHOD__ ); |
305 | 295 | if ( $res !== true && !( $res instanceOf ResultWrapper ) ) { |
306 | 296 | $status->fatal( 'config-install-user-failed', $this->getVar( 'wgDBuser' ), $res ); |
307 | 297 | } |
308 | 298 | if( $status->isOK() ) { |
309 | | - $this->db->query("ALTER ROLE $safeuser LOGIN"); |
| 299 | + $this->db->query("ALTER USER $safeuser SET search_path = $safeschema"); |
310 | 300 | } |
311 | 301 | } |
312 | | - $this->db->query("ALTER ROLE $safeuser SET search_path = $safeschema, public"); |
313 | 302 | |
314 | 303 | return $status; |
315 | 304 | } |
— | — | @@ -348,11 +337,12 @@ |
349 | 338 | |
350 | 339 | $this->db->begin( __METHOD__ ); |
351 | 340 | |
352 | | - // getConnection() should have already selected the schema if it exists |
353 | 341 | if( !$this->db->schemaExists( $schema ) ) { |
354 | 342 | $status->error( 'config-install-pg-schema-not-exist' ); |
355 | 343 | return $status; |
356 | 344 | } |
| 345 | + $safeschema = $this->db->addIdentifierQuotes( $schema ); |
| 346 | + $this->db->query( "SET search_path = $safeschema" ); |
357 | 347 | $error = $this->db->sourceFile( $this->db->getSchema() ); |
358 | 348 | if( $error !== true ) { |
359 | 349 | $this->db->reportQueryError( $error, 0, '', __METHOD__ ); |
— | — | @@ -369,18 +359,12 @@ |
370 | 360 | } |
371 | 361 | |
372 | 362 | public function setupPLpgSQL() { |
373 | | - $this->db = null; |
374 | 363 | $this->useAdmin = true; |
375 | | - $dbName = $this->getVar( 'wgDBname' ); |
376 | | - $status = $this->getConnection( $dbName ); |
| 364 | + $status = $this->getConnection(); |
377 | 365 | if ( !$status->isOK() ) { |
378 | 366 | return $status; |
379 | 367 | } |
380 | | - $this->db = $status->value; |
381 | 368 | |
382 | | - /* Admin user has to be connected to the db it just |
383 | | - created to satisfy ownership requirements for |
384 | | - "CREATE LANGAUGE" */ |
385 | 369 | $rows = $this->db->numRows( |
386 | 370 | $this->db->query( "SELECT 1 FROM pg_catalog.pg_language WHERE lanname = 'plpgsql'" ) |
387 | 371 | ); |
— | — | @@ -389,6 +373,7 @@ |
390 | 374 | $SQL = "SELECT 1 FROM pg_catalog.pg_class c JOIN pg_catalog.pg_namespace n ON (n.oid = c.relnamespace) ". |
391 | 375 | "WHERE relname = 'pg_pltemplate' AND nspname='pg_catalog'"; |
392 | 376 | $rows = $this->db->numRows( $this->db->query( $SQL ) ); |
| 377 | + $dbName = $this->getVar( 'wgDBname' ); |
393 | 378 | if ( $rows >= 1 ) { |
394 | 379 | $result = $this->db->query( 'CREATE LANGUAGE plpgsql' ); |
395 | 380 | if ( !$result ) { |