Aaron Schulz has uploaded a new change for review.
https://gerrit.wikimedia.org/r/50261
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 maintenance/sql.php
1 file changed, 11 insertions(+), 3 deletions(-)
git pull ssh://gerrit.wikimedia.org:29418/mediawiki/core
refs/changes/61/50261/1
diff --git a/maintenance/sql.php b/maintenance/sql.php
index 9b0b576..2c20cc8 100644
--- a/maintenance/sql.php
+++ b/maintenance/sql.php
@@ -33,12 +33,20 @@
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 );
+ $this->addOption( 'source', 'Run the contents of SQL file',
false, true );
}
public function execute() {
- $dbw = wfGetDB( DB_MASTER );
- if ( $this->hasArg() ) {
- $fileName = $this->getArg();
+ // 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->hasOption( 'source' ) ) {
+ $fileName = $this->getOption( 'source' );
$file = fopen( $fileName, '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: newchange
Gerrit-Change-Id: I6e8c10bc772d4a26c38f2ed8ae5787c8d130bd4c
Gerrit-PatchSet: 1
Gerrit-Project: mediawiki/core
Gerrit-Branch: master
Gerrit-Owner: Aaron Schulz <[email protected]>
_______________________________________________
MediaWiki-commits mailing list
[email protected]
https://lists.wikimedia.org/mailman/listinfo/mediawiki-commits