From: Aaron Schulz Date: Tue, 20 Sep 2016 15:15:39 +0000 (-0700) Subject: Set an initial dummy domain in Database::__construct() X-Git-Tag: 1.31.0-rc.0~5452^2 X-Git-Url: http://git.cyclocoop.org/%22.%20generer_url_ecrire%28%22sites_tous%22%2C%22%22%29.%20%22?a=commitdiff_plain;h=aa9ef623ecdbb74978c3dd27a262dc5c7ee69046;p=lhc%2Fweb%2Fwiklou.git Set an initial dummy domain in Database::__construct() This avoids errors when LoadBalancer calls getWikiId() in reallyOpenConnection() after a failed connection. Change-Id: Idc3d93ae39be09f2da277df57cdc5a564cb3408d --- 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 ); + } } /**