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

Change subject: Made sql.php except a "cluster" option and cleaned up the 
arguments.
......................................................................


Made sql.php except a "cluster" option and cleaned up the arguments.

* This lets people choose to run the script on some external cluster
  instead of only the primary cluster for a given wiki ID.

Change-Id: I6e8c10bc772d4a26c38f2ed8ae5787c8d130bd4c
---
M RELEASE-NOTES-1.21
M maintenance/sql.php
2 files changed, 12 insertions(+), 4 deletions(-)

Approvals:
  Hashar: Looks good to me, approved
  jenkins-bot: Verified



diff --git a/RELEASE-NOTES-1.21 b/RELEASE-NOTES-1.21
index 3afd4bf..8fccf3b 100644
--- a/RELEASE-NOTES-1.21
+++ b/RELEASE-NOTES-1.21
@@ -99,6 +99,8 @@
 * WikiText now permits the use of WAI-ARIA's role="presentation" inside of
   html elements and tables. This allows presentational markup, especially
   tables. To be marked up as such.
+* maintenance/sql.php learned the --cluster option. Let you run the script
+  on some external cluster instead of the primary cluster for a given wiki.
 
 === Bug fixes in 1.21 ===
 * (bug 40353) SpecialDoubleRedirect should support interwiki redirects.
diff --git a/maintenance/sql.php b/maintenance/sql.php
index 9b0b576..ef1ec54 100644
--- a/maintenance/sql.php
+++ b/maintenance/sql.php
@@ -33,13 +33,19 @@
        public function __construct() {
                parent::__construct();
                $this->mDescription = "Send SQL queries to a MediaWiki 
database";
+               $this->addOption( 'cluster', 'Use an external cluster by name', 
false, true );
        }
 
        public function execute() {
-               $dbw = wfGetDB( DB_MASTER );
-               if ( $this->hasArg() ) {
-                       $fileName = $this->getArg();
-                       $file = fopen( $fileName, 'r' );
+               // Get a DB handle (with this wiki's DB select) from the 
appropriate load balancer
+               if ( $this->hasOption( 'cluster' ) ) {
+                       $lb = wfGetLBFactory()->getExternalLB( 
$this->getOption( 'cluster' ) );
+                       $dbw = $lb->getConnection( DB_MASTER ); // master for 
external LB
+               } else {
+                       $dbw = wfGetDB( DB_MASTER ); // master for primary LB 
for this wiki
+               }
+               if ( $this->hasArg( 0 ) ) {
+                       $file = fopen( $this->getArg( 0 ), 'r' );
                        if ( !$file ) {
                                $this->error( "Unable to open input file", true 
);
                        }

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

Gerrit-MessageType: merged
Gerrit-Change-Id: I6e8c10bc772d4a26c38f2ed8ae5787c8d130bd4c
Gerrit-PatchSet: 3
Gerrit-Project: mediawiki/core
Gerrit-Branch: master
Gerrit-Owner: Aaron Schulz <[email protected]>
Gerrit-Reviewer: Asher <[email protected]>
Gerrit-Reviewer: Hashar <[email protected]>
Gerrit-Reviewer: jenkins-bot

_______________________________________________
MediaWiki-commits mailing list
[email protected]
https://lists.wikimedia.org/mailman/listinfo/mediawiki-commits

Reply via email to