jenkins-bot has submitted this change and it was merged.

Change subject: Allow having the database table be on an external cluster
......................................................................


Allow having the database table be on an external cluster

This is necessary for Wikimedia usage where the table will be on the
extension1 cluster in the wikishared table.

Change-Id: I4de9a66822d429cf45a2e46461f9022d164a8666
---
M README
M UrlShortener.utils.php
M extension.json
3 files changed, 14 insertions(+), 7 deletions(-)

Approvals:
  Aaron Schulz: Looks good to me, approved
  Legoktm: Looks good to me, approved
  jenkins-bot: Verified



diff --git a/README b/README
index ade9412..58faf97 100644
--- a/README
+++ b/README
@@ -36,6 +36,12 @@
 $wgUrlShortenerDBName = false;
 </source>
 
+If the database is on an external cluster, you will also need to configure 
that.
+
+<source lang="php">
+$wgUrlShortenerDBCluster = false;
+</source>
+
 === Allow arbitrary ports ===
 
 By default, only URLs with ports 80 and 443 are accepted and are automatically 
removed.
diff --git a/UrlShortener.utils.php b/UrlShortener.utils.php
index d8ab8b6..ae057e3 100755
--- a/UrlShortener.utils.php
+++ b/UrlShortener.utils.php
@@ -121,15 +121,15 @@
 
        /**
         * @param int $type DB_SLAVE or DB_MASTER
-        * @return DatabaseBase
+        * @return IDatabase
         */
        public static function getDB( $type ) {
-               global $wgUrlShortenerDBName;
-               if ( $wgUrlShortenerDBName !== false ) {
-                       return wfGetDB( $type, array(), $wgUrlShortenerDBName );
-               } else {
-                       return wfGetDB( $type );
-               }
+               global $wgUrlShortenerDBName, $wgUrlShortenerDBCluster;
+               $lb = $wgUrlShortenerDBCluster
+                       ? wfGetLBFactory()->getExternalLB( 
$wgUrlShortenerDBCluster )
+                       : wfGetLB( $wgUrlShortenerDBName );
+
+               return $lb->getConnectionRef( $type, array(), 
$wgUrlShortenerDBName );
        }
 
        /**
diff --git a/extension.json b/extension.json
index fa28fd1..1c94e4a 100644
--- a/extension.json
+++ b/extension.json
@@ -94,6 +94,7 @@
        },
        "config": {
                "UrlShortenerApprovedDomains": false,
+               "UrlShortenerDBCluster": false,
                "UrlShortenerDBName": false,
                "UrlShortenerDomainsWhitelist": false,
                "UrlShortenerIdSet": 
"023456789ABCDEFGHJKLMNOPQRSTUVWXYZabcdefghijkmnopqrstuvwxyz$-_.!",

-- 
To view, visit https://gerrit.wikimedia.org/r/247993
To unsubscribe, visit https://gerrit.wikimedia.org/r/settings

Gerrit-MessageType: merged
Gerrit-Change-Id: I4de9a66822d429cf45a2e46461f9022d164a8666
Gerrit-PatchSet: 3
Gerrit-Project: mediawiki/extensions/UrlShortener
Gerrit-Branch: master
Gerrit-Owner: Legoktm <legoktm.wikipe...@gmail.com>
Gerrit-Reviewer: Aaron Schulz <asch...@wikimedia.org>
Gerrit-Reviewer: Legoktm <legoktm.wikipe...@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