r70041 MediaWiki - Code Review archive

Repository:MediaWiki
Revision:r70040‎ | r70041 | r70042 >
Date:20:44, 27 July 2010
Author:platonides
Status:ok
Tags:
Comment:
Commit some renderDump improvements
Modified paths:
  • /trunk/phase3/maintenance/renderDump.php (modified) (history)

Diff [purge]

Index: trunk/phase3/maintenance/renderDump.php
@@ -39,19 +39,34 @@
4040 parent::__construct();
4141 $this->mDescription = "Take page text out of an XML dump file and render basic HTML out to files";
4242 $this->addOption( 'output-dir', 'The directory to output the HTML files to', true, true );
 43+ $this->addOption( 'prefix', 'Prefix for the rendered files (defaults to wiki)', false, true );
 44+ $this->addOption( 'parser', 'Use an alternative parser class', false, true );
4345 }
4446
4547 public function execute() {
4648 $this->outputDirectory = $this->getOption( 'output-dir' );
 49+ $this->prefix = $this->getOption( 'prefix', 'wiki' );
4750 $this->startTime = wfTime();
4851
 52+ if ( $this->hasOption( 'parser' ) ) {
 53+ global $wgParserConf;
 54+ $wgParserConf['class'] = $this->getOption( 'parser' );
 55+ $this->prefix .= "-{$wgParserConf['class']}";
 56+ }
 57+
4958 $source = new ImportStreamSource( $this->getStdin() );
5059 $importer = new WikiImporter( $source );
5160
5261 $importer->setRevisionCallback(
5362 array( &$this, 'handleRevision' ) );
5463
55 - return $importer->doImport();
 64+ $importer->doImport();
 65+
 66+ $delta = wfTime() - $this->startTime;
 67+ $this->error( "Rendered {$this->count} pages in " . round($delta, 2) . " seconds " );
 68+ if ($delta > 0)
 69+ $this->error( round($this->count / $delta, 2) . " pages/sec" );
 70+ $this->error( "\n" );
5671 }
5772
5873 /**
@@ -59,6 +74,8 @@
6075 * @param $rev Revision
6176 */
6277 public function handleRevision( $rev ) {
 78+ global $wgParserConf;
 79+
6380 $title = $rev->getTitle();
6481 if ( !$title ) {
6582 $this->error( "Got bogus revision with null title!" );
@@ -69,15 +86,15 @@
7087 $this->count++;
7188
7289 $sanitized = rawurlencode( $display );
73 - $filename = sprintf( "%s/wiki-%07d-%s.html",
 90+ $filename = sprintf( "%s/%s-%07d-%s.html",
7491 $this->outputDirectory,
 92+ $this->prefix,
7593 $this->count,
7694 $sanitized );
7795 $this->output( sprintf( "%s\n", $filename, $display ) );
7896
79 - // fixme (what?)
8097 $user = new User();
81 - $parser = new Parser();
 98+ $parser = new $wgParserConf['class']();
8299 $options = ParserOptions::newFromUser( $user );
83100
84101 $output = $parser->parse( $rev->getText(), $title, $options );

Status & tagging log