installer: Fix "relation 'user' does not exist" error for Postgres
authorTimo Tijhof <krinklemail@gmail.com>
Fri, 24 Feb 2017 03:39:03 +0000 (19:39 -0800)
committerTimo Tijhof <krinklemail@gmail.com>
Fri, 24 Feb 2017 03:39:03 +0000 (19:39 -0800)
commit9b0cfff5aa4d6cf1ba23e0a333e081a928a720ab
tree595e428df3663809a32cd57c87c9569adff917f7
parent407f6b6be8aae4e3792e07f8cc6cefe8d53ce2a4
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
includes/db/MWLBFactory.php
includes/installer/MssqlInstaller.php
includes/installer/PostgresInstaller.php