r59025 MediaWiki - Code Review archive

Repository:MediaWiki
Revision:r59024‎ | r59025 | r59026 >
Date:21:05, 13 November 2009
Author:siebrand
Status:deferred
Tags:
Comment:
Allow suppression of progress report
Modified paths:
  • /trunk/extensions/Translate/scripts/createMessageIndex.php (modified) (history)
  • /trunk/extensions/Translate/utils/MessageIndexRebuilder.php (modified) (history)

Diff [purge]

Index: trunk/extensions/Translate/scripts/createMessageIndex.php
@@ -14,4 +14,27 @@
1515
1616 require( dirname( __FILE__ ) . '/cli.inc' );
1717
18 -MessageIndexRebuilder::execute();
\ No newline at end of file
 18+function showUsage() {
 19+ STDERR( <<<EOT
 20+Message index creation command line script
 21+
 22+Usage: php createMessageIndex.php [options...]
 23+
 24+Options:
 25+ --help Show this help text
 26+ --progress Report on progress (default: false)
 27+
 28+EOT
 29+);
 30+ exit( 1 );
 31+}
 32+
 33+if ( isset( $options['help'] ) ) {
 34+ showUsage();
 35+}
 36+
 37+if ( isset( $options['progress'] ) ) {
 38+ MessageIndexRebuilder::execute();
 39+} else {
 40+ MessageIndexRebuilder::execute( false );
 41+}
Index: trunk/extensions/Translate/utils/MessageIndexRebuilder.php
@@ -13,14 +13,18 @@
1414 */
1515
1616 class MessageIndexRebuilder {
17 - public static function execute() {
 17+ protected $reportProgress;
1818
 19+ public static function execute( $reportProgress = true ) {
1920 $groups = MessageGroups::singleton()->getGroups();
2021
2122 $hugearray = array();
2223 $postponed = array();
2324
24 - STDOUT( "Working with ", 'main' );
 25+ if( $reportProgress ) {
 26+ STDOUT( "Working with ", 'main' );
 27+ $this->reportProgress = true;
 28+ }
2529
2630 foreach ( $groups as $g ) {
2731 if ( !$g->exists() ) continue;
@@ -36,7 +40,7 @@
3741 foreach ( $postponed as $g ) {
3842 self::checkAndAdd( $hugearray, $g, true );
3943 }
40 -
 44+
4145 global $wgCacheDirectory;
4246 $filename = "$wgCacheDirectory/translate_messageindex.cdb";
4347 $writer = CdbWriter::open( $filename );
@@ -60,7 +64,9 @@
6165
6266 $id = $g->getId();
6367
64 - STDOUT( "$id ", 'main' );
 68+ if( $this->reportProgress ) {
 69+ STDOUT( "$id ", 'main' );
 70+ }
6571
6672 $namespace = $g->getNamespace();
6773
@@ -92,4 +98,4 @@
9399 }
94100 unset( $id ); // Disconnect the previous references to this $id
95101 }
96 -}
\ No newline at end of file
 102+}

Follow-up revisions

RevisionCommit summaryAuthorDate
r59026Follow-up r59025. Something about "Using $this when not in object context".siebrand21:09, 13 November 2009
r59054--quiet is a standard option in the Translate commandline scripts, so updatin...siebrand08:46, 14 November 2009

Status & tagging log