jenkins-bot has submitted this change and it was merged.
Change subject: Use false instead of null to indicate local wiki DB.
......................................................................
Use false instead of null to indicate local wiki DB.
This restores consistency with the conventions used by LoadBalancer.
Change-Id: I84ff19c77ab2f1858863bc0aec7147f739055bda
---
M client/includes/store/sql/ConnectionManager.php
1 file changed, 11 insertions(+), 11 deletions(-)
Approvals:
Aude: Looks good to me, approved
jenkins-bot: Verified
diff --git a/client/includes/store/sql/ConnectionManager.php
b/client/includes/store/sql/ConnectionManager.php
index 4cfc4d4..000da2f 100644
--- a/client/includes/store/sql/ConnectionManager.php
+++ b/client/includes/store/sql/ConnectionManager.php
@@ -4,6 +4,7 @@
use DatabaseBase;
use IDatabase;
+use InvalidArgumentException;
use LoadBalancer;
/**
@@ -20,15 +21,22 @@
private $loadBalancer;
/**
- * @var string|null
+ * The symbolic name of the target database, or false for the local
wiki's database.
+ *
+ * @var string|false
*/
private $dbName;
/**
* @param LoadBalancer $loadBalancer
- * @param string|null $dbName Optional, defaults to current wiki.
+ * @param string|false $dbName Optional, defaults to current wiki.
+ * This follows the convention for database names used by
$loadBalancer.
*/
- public function __construct( LoadBalancer $loadBalancer, $dbName = null
) {
+ public function __construct( LoadBalancer $loadBalancer, $dbName =
false ) {
+ if ( !is_string( $dbName ) && $dbName !== false ) {
+ throw new InvalidArgumentException( '$dbName must be a
string, or false.' );
+ }
+
$this->loadBalancer = $loadBalancer;
$this->dbName = $dbName;
}
@@ -37,10 +45,6 @@
* @return DatabaseBase
*/
public function getReadConnection() {
- if ( $this->dbName === null ) {
- return $this->loadBalancer->getConnection( DB_READ );
- }
-
return $this->loadBalancer->getConnection( DB_READ, array(),
$this->dbName );
}
@@ -48,10 +52,6 @@
* @return DatabaseBase
*/
private function getWriteConnection() {
- if ( $this->dbName === null ) {
- return $this->loadBalancer->getConnection( DB_WRITE );
- }
-
return $this->loadBalancer->getConnection( DB_WRITE, array(),
$this->dbName );
}
--
To view, visit https://gerrit.wikimedia.org/r/189486
To unsubscribe, visit https://gerrit.wikimedia.org/r/settings
Gerrit-MessageType: merged
Gerrit-Change-Id: I84ff19c77ab2f1858863bc0aec7147f739055bda
Gerrit-PatchSet: 1
Gerrit-Project: mediawiki/extensions/Wikibase
Gerrit-Branch: master
Gerrit-Owner: Daniel Kinzler <[email protected]>
Gerrit-Reviewer: Aude <[email protected]>
Gerrit-Reviewer: jenkins-bot <>
_______________________________________________
MediaWiki-commits mailing list
[email protected]
https://lists.wikimedia.org/mailman/listinfo/mediawiki-commits