jenkins-bot has submitted this change and it was merged. ( 
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(-)

Approvals:
  BryanDavis: Looks good to me, approved
  jenkins-bot: Verified



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: merged
Gerrit-Change-Id: I7af58c4beffc4908a93c0c1d8ab1aec9d4ec57c6
Gerrit-PatchSet: 1
Gerrit-Project: mediawiki/core
Gerrit-Branch: master
Gerrit-Owner: Krinkle <krinklem...@gmail.com>
Gerrit-Reviewer: BryanDavis <bda...@wikimedia.org>
Gerrit-Reviewer: Krinkle <krinklem...@gmail.com>
Gerrit-Reviewer: jenkins-bot <>

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

Reply via email to