X-Git-Url: http://git.heureux-cyclage.org/?a=blobdiff_plain;f=maintenance%2FrunBatchedQuery.php;h=e1139164c5906dd35290a17b5267eb3e9095f2dd;hb=38c7f444e1c13327e203ce4e2890826782b39876;hp=dd3680c983635a430dced36dcb1bcc353eb17b75;hpb=26505b170adb24a6ae68945920db322c9382e470;p=lhc%2Fweb%2Fwiklou.git diff --git a/maintenance/runBatchedQuery.php b/maintenance/runBatchedQuery.php index dd3680c983..e1139164c5 100644 --- a/maintenance/runBatchedQuery.php +++ b/maintenance/runBatchedQuery.php @@ -19,17 +19,22 @@ * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. * http://www.gnu.org/copyleft/gpl.html * + * @file * @ingroup Maintenance */ -require_once( dirname( __FILE__ ) . '/Maintenance.php' ); +require_once( __DIR__ . '/Maintenance.php' ); +/** + * Maintenance script to run a database query in batches and wait for slaves. + * + * @ingroup Maintenance + */ class BatchedQueryRunner extends Maintenance { public function __construct() { parent::__construct(); $this->mDescription = "Run a query repeatedly until it affects 0 rows, and wait for slaves in between.\n" . "NOTE: You need to set a LIMIT clause yourself."; - $this->addOption( 'wait', "Wait for replication lag to go down to this value. Default: 5", false, true ); } public function execute() { @@ -37,16 +42,15 @@ class BatchedQueryRunner extends Maintenance { $this->error( "No query specified. Specify the query as a command line parameter.", true ); $query = $this->getArg(); - $wait = $this->getOption( 'wait', 5 ); $n = 1; - $dbw = wfGetDb( DB_MASTER ); + $dbw = wfGetDB( DB_MASTER ); do { $this->output( "Batch $n: " ); $n++; $dbw->query( $query, __METHOD__ ); $affected = $dbw->affectedRows(); $this->output( "$affected rows\n" ); - wfWaitForSlaves( $wait ); + wfWaitForSlaves(); } while ( $affected > 0 ); }