r95457 MediaWiki - Code Review archive

Repository:MediaWiki
Revision:r95456‎ | r95457 | r95458 >
Date:05:15, 25 August 2011
Author:bawolff
Status:ok
Tags:
Comment:
Move the check for if a Maintenance script supports --batch-size away from addDefaultParams()
and to setBatchSize(), since setBatchSize is usually called in a subclass constructor after
parent:__construct() which is after addDefaultParams() is called.

Upside of this is lots of scripts supporting --batch-size now list it in their help output.
Modified paths:
  • /trunk/phase3/RELEASE-NOTES-1.19 (modified) (history)
  • /trunk/phase3/maintenance/Maintenance.php (modified) (history)

Diff [purge]

Index: trunk/phase3/maintenance/Maintenance.php
@@ -248,6 +248,20 @@
249249 */
250250 protected function setBatchSize( $s = 0 ) {
251251 $this->mBatchSize = $s;
 252+
 253+ // If we support $mBatchSize, show the option.
 254+ // Used to be in addDefaultParams, but in order for that to
 255+ // work, subclasses would have to call this function in the constructor
 256+ // before they called parent::__construct which is just weird
 257+ // (and really wasn't done).
 258+ if ( $this->mBatchSize ) {
 259+ $this->addOption( 'batch-size', 'Run this many operations ' .
 260+ 'per batch, default: ' . $this->mBatchSize, false, true );
 261+ if ( isset( $this->mParams['batch-size'] ) ) {
 262+ // This seems a little ugly...
 263+ $this->mDependantParameters['batch-size'] = $this->mParams['batch-size'];
 264+ }
 265+ }
252266 }
253267
254268 /**
@@ -418,11 +432,7 @@
419433 $this->addOption( 'dbuser', 'The DB user to use for this script', false, true );
420434 $this->addOption( 'dbpass', 'The password to use for this script', false, true );
421435 }
422 - // If we support $mBatchSize, show the option
423 - if ( $this->mBatchSize ) {
424 - $this->addOption( 'batch-size', 'Run this many operations ' .
425 - 'per batch, default: ' . $this->mBatchSize, false, true );
426 - }
 436+
427437 # Save additional script dependant options to display
428438 # them separately in help
429439 $this->mDependantParameters = array_diff_key( $this->mParams, $this->mGenericParameters );
Index: trunk/phase3/RELEASE-NOTES-1.19
@@ -72,6 +72,7 @@
7373 used
7474 * (bug 28649) Avoiding half truncated multi-byte unicode characters when
7575 truncating log comments.
 76+* Show --batch-size option in help of maintenance scripts that support it
7677
7778 === API changes in 1.19 ===
7879 * (bug 19838) siprop=interwikimap can now use the interwiki cache.

Status & tagging log