MediaWiki  1.23.2
runBatchedQuery.php
Go to the documentation of this file.
1 <?php
26 require_once __DIR__ . '/Maintenance.php';
27 
34  public function __construct() {
35  parent::__construct();
36  $this->mDescription = "Run a query repeatedly until it affects 0 rows, and wait for slaves in between.\n" .
37  "NOTE: You need to set a LIMIT clause yourself.";
38  }
39 
40  public function execute() {
41  if ( !$this->hasArg() ) {
42  $this->error( "No query specified. Specify the query as a command line parameter.", true );
43  }
44 
45  $query = $this->getArg();
46  $n = 1;
47  $dbw = wfGetDB( DB_MASTER );
48  do {
49  $this->output( "Batch $n: " );
50  $n++;
51  $dbw->query( $query, __METHOD__ );
52  $affected = $dbw->affectedRows();
53  $this->output( "$affected rows\n" );
55  } while ( $affected > 0 );
56  }
57 
58  public function getDbType() {
59  return Maintenance::DB_ADMIN;
60  }
61 }
62 
63 $maintClass = "BatchedQueryRunner";
64 require_once RUN_MAINTENANCE_IF_MAIN;
$maintClass
$maintClass
Definition: runBatchedQuery.php:63
DB_MASTER
const DB_MASTER
Definition: Defines.php:56
BatchedQueryRunner\getDbType
getDbType()
Does the script need different DB access? By default, we give Maintenance scripts normal rights to th...
Definition: runBatchedQuery.php:58
php
skin txt MediaWiki includes four core it has been set as the default in MediaWiki since the replacing Monobook it had been been the default skin since before being replaced by Vector largely rewritten in while keeping its appearance Several legacy skins were removed in the as the burden of supporting them became too heavy to bear Those in etc for skin dependent CSS etc for skin dependent JavaScript These can also be customised on a per user by etc This feature has led to a wide variety of user styles becoming that gallery is a good place to ending in php
Definition: skin.txt:62
wfGetDB
& wfGetDB( $db, $groups=array(), $wiki=false)
Get a Database object.
Definition: GlobalFunctions.php:3650
$n
$n
Definition: RandomTest.php:76
BatchedQueryRunner\__construct
__construct()
Default constructor.
Definition: runBatchedQuery.php:34
RUN_MAINTENANCE_IF_MAIN
require_once RUN_MAINTENANCE_IF_MAIN
Definition: maintenance.txt:50
Maintenance\hasArg
hasArg( $argId=0)
Does a given argument exist?
Definition: Maintenance.php:236
Maintenance
Abstract maintenance class for quickly writing and churning out maintenance scripts with minimal effo...
Definition: maintenance.txt:39
BatchedQueryRunner\execute
execute()
Do the actual work.
Definition: runBatchedQuery.php:40
wfWaitForSlaves
wfWaitForSlaves( $maxLag=false, $wiki=false, $cluster=false)
Modern version of wfWaitForSlaves().
Definition: GlobalFunctions.php:3795
Maintenance\DB_ADMIN
const DB_ADMIN
Definition: Maintenance.php:59
BatchedQueryRunner
Maintenance script to run a database query in batches and wait for slaves.
Definition: runBatchedQuery.php:33
Maintenance\error
error( $err, $die=0)
Throw an error to the user.
Definition: Maintenance.php:333
Maintenance\output
output( $out, $channel=null)
Throw some output to the user.
Definition: Maintenance.php:314
Maintenance\getArg
getArg( $argId=0, $default=null)
Get an argument.
Definition: Maintenance.php:246
$query
return true to allow those checks to and false if checking is done use this to change the tables headers temp or archived zone change it to an object instance and return false override the list derivative used the name of the old file when set the default code will be skipped add a value to it if you want to add a cookie that have to vary cache options can modify $query
Definition: hooks.txt:1105