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."; } public function execute() { if ( !$this->hasArg() ) { $this->error( "No query specified. Specify the query as a command line parameter.", true ); } $query = $this->getArg(); $n = 1; $dbw = wfGetDB( DB_MASTER ); do { $this->output( "Batch $n: " ); $n++; $dbw->query( $query, __METHOD__ ); $affected = $dbw->affectedRows(); $this->output( "$affected rows\n" ); wfWaitForSlaves(); } while ( $affected > 0 ); } public function getDbType() { return Maintenance::DB_ADMIN; } } $maintClass = "BatchedQueryRunner"; require_once RUN_MAINTENANCE_IF_MAIN;