From aa9ef623ecdbb74978c3dd27a262dc5c7ee69046 Mon Sep 17 00:00:00 2001 From: Aaron Schulz Date: Tue, 20 Sep 2016 08:15:39 -0700 Subject: [PATCH] Set an initial dummy domain in Database::__construct() This avoids errors when LoadBalancer calls getWikiId() in reallyOpenConnection() after a failed connection. Change-Id: Idc3d93ae39be09f2da277df57cdc5a564cb3408d --- includes/libs/rdbms/database/Database.php | 10 +++++++--- 1 file changed, 7 insertions(+), 3 deletions(-) diff --git a/includes/libs/rdbms/database/Database.php b/includes/libs/rdbms/database/Database.php index a5b928494d..901afd175d 100644 --- a/includes/libs/rdbms/database/Database.php +++ b/includes/libs/rdbms/database/Database.php @@ -281,6 +281,9 @@ abstract class Database implements IDatabase, LoggerAwareInterface { ? $params['queryLogger'] : new \Psr\Log\NullLogger(); + // Set initial dummy domain until open() sets the final DB/prefix + $this->currentDomain = DatabaseDomain::newUnspecified(); + if ( $user ) { $this->open( $server, $user, $password, $dbName ); } elseif ( $this->requiresDatabaseUser() ) { @@ -288,9 +291,10 @@ abstract class Database implements IDatabase, LoggerAwareInterface { } // Set the domain object after open() sets the relevant fields - $this->currentDomain = ( $this->mDBname != '' ) - ? new DatabaseDomain( $this->mDBname, null, $this->mTablePrefix ) - : DatabaseDomain::newUnspecified(); + if ( $this->mDBname != '' ) { + // Domains with server scope but a table prefix are not used by IDatabase classes + $this->currentDomain = new DatabaseDomain( $this->mDBname, null, $this->mTablePrefix ); + } } /** -- 2.20.1