Krinkle has uploaded a new change for review. ( 
https://gerrit.wikimedia.org/r/339594 )

Change subject: installer: Fix "relation 'user' does not exist" error for 
Postgres
......................................................................

installer: Fix "relation 'user' does not exist" error for Postgres

On Travis CI, the Postgres build has been failing very early on
in the installer (before phpunit) due to a database error:

> Creating administrator user account.. DBQueryError at Database.php:1059
> Query: SELECT user_id FROM "user" WHERE user_name = 'Admin' LIMIT 1
> Function: User::idForName
> Error: 42P01 ERROR:  relation "user" does not exist
> LINE 1: SELECT /* User::idForName  */ user_id FROM "user" ...

This is because the installer makes its own Database object without
involving ServiceWiring or MWLBFactory, which means wgDBport and
(more importantly) 'keywordTableMap' don't get applied.

While keywordTableMap doesn't matter during the database installation,
after the installer is done updating GlobalVarConfig and resetting
MediaWikiServices, DatabaseInstaller::enableLB takes that homemade
connection and injects it into MediaWikiServices by redefining
the 'DBLoadBalancerFactory' service. Which then affects all use
of wfGetDB(), such as from User::idForName().

Bug: T30162
Bug: T75174
Bug: T75176
Change-Id: I7af58c4beffc4908a93c0c1d8ab1aec9d4ec57c6
---
M includes/db/MWLBFactory.php
M includes/installer/MssqlInstaller.php
M includes/installer/PostgresInstaller.php
3 files changed, 8 insertions(+), 1 deletion(-)


  git pull ssh://gerrit.wikimedia.org:29418/mediawiki/core 
refs/changes/94/339594/1

diff --git a/includes/db/MWLBFactory.php b/includes/db/MWLBFactory.php
index 0186222..fe063f2 100644
--- a/includes/db/MWLBFactory.php
+++ b/includes/db/MWLBFactory.php
@@ -59,6 +59,9 @@
                        'readOnlyReason' => wfConfiguredReadOnlyReason(),
                ];
 
+               // When making changes here, remember to also specify 
MediaWiki-specific options
+               // for Database classes in the relevant Installer subclass.
+               // Such as MysqlInstaller::openConnection and 
PostgresInstaller::openConnectionWithParams.
                if ( $lbConf['class'] === 'LBFactorySimple' ) {
                        if ( isset( $lbConf['servers'] ) ) {
                                // Server array is already explicitly 
configured; leave alone
diff --git a/includes/installer/MssqlInstaller.php 
b/includes/installer/MssqlInstaller.php
index 5e8ed3f..d6efeb2 100644
--- a/includes/installer/MssqlInstaller.php
+++ b/includes/installer/MssqlInstaller.php
@@ -214,6 +214,7 @@
                try {
                        $db = Database::factory( 'mssql', [
                                'host' => $this->getVar( 'wgDBserver' ),
+                               'port' => $this->getVar( 'wgDBport' ),
                                'user' => $user,
                                'password' => $password,
                                'dbname' => false,
diff --git a/includes/installer/PostgresInstaller.php 
b/includes/installer/PostgresInstaller.php
index 6dfa28b..906768f 100644
--- a/includes/installer/PostgresInstaller.php
+++ b/includes/installer/PostgresInstaller.php
@@ -156,10 +156,13 @@
                try {
                        $db = Database::factory( 'postgres', [
                                'host' => $this->getVar( 'wgDBserver' ),
+                               'port' => $this->getVar( 'wgDBport' ),
                                'user' => $user,
                                'password' => $password,
                                'dbname' => $dbName,
-                               'schema' => $schema ] );
+                               'schema' => $schema,
+                               'keywordTableMap' => [ 'user' => 'mwuser', 
'text' => 'pagecontent' ],
+                       ] );
                        $status->value = $db;
                } catch ( DBConnectionError $e ) {
                        $status->fatal( 'config-connection-error', 
$e->getMessage() );

-- 
To view, visit https://gerrit.wikimedia.org/r/339594
To unsubscribe, visit https://gerrit.wikimedia.org/r/settings

Gerrit-MessageType: newchange
Gerrit-Change-Id: I7af58c4beffc4908a93c0c1d8ab1aec9d4ec57c6
Gerrit-PatchSet: 1
Gerrit-Project: mediawiki/core
Gerrit-Branch: master
Gerrit-Owner: Krinkle <krinklem...@gmail.com>

_______________________________________________
MediaWiki-commits mailing list
MediaWiki-commits@lists.wikimedia.org
https://lists.wikimedia.org/mailman/listinfo/mediawiki-commits

Reply via email to