X-Git-Url: http://git.cyclocoop.org/?a=blobdiff_plain;f=maintenance%2FcompareParsers.php;h=fabc2571333ef948905089b3a4805b3eefd37393;hb=d966178eadf6f5e30f4049c844fdb6afe827501f;hp=a3337173c228a4630736ecb9a7d75668f47f0712;hpb=40f85ac347a6edf38b82896ebf97da4b786eb3a0;p=lhc%2Fweb%2Fwiklou.git diff --git a/maintenance/compareParsers.php b/maintenance/compareParsers.php index a3337173c2..fabc257133 100644 --- a/maintenance/compareParsers.php +++ b/maintenance/compareParsers.php @@ -28,7 +28,7 @@ * @ingroup Maintenance */ -require_once( __DIR__ . '/dumpIterator.php' ); +require_once __DIR__ . '/dumpIterator.php'; /** * Maintenance script to take page text out of an XML dump file and render @@ -55,8 +55,8 @@ class CompareParsers extends DumpIterator { } public function checkOptions() { - if ( $this->hasOption('save-failed') ) { - $this->saveFailed = $this->getOption('save-failed'); + if ( $this->hasOption( 'save-failed' ) ) { + $this->saveFailed = $this->getOption( 'save-failed' ); } $this->stripParametersEnabled = $this->hasOption( 'strip-parameters' ); @@ -87,8 +87,9 @@ class CompareParsers extends DumpIterator { public function conclusions() { $this->error( "{$this->failed} failed revisions out of {$this->count}" ); - if ($this->count > 0) + if ( $this->count > 0 ) { $this->output( " (" . ( $this->failed / $this->count ) . "%)\n" ); + } } function stripParameters( $text ) { @@ -114,15 +115,24 @@ class CompareParsers extends DumpIterator { $parser1 = new $parser1Name(); $parser2 = new $parser2Name(); - $output1 = $parser1->parse( $rev->getText(), $title, $this->options ); - $output2 = $parser2->parse( $rev->getText(), $title, $this->options ); + $content = $rev->getContent(); + + if ( $content->getModel() !== CONTENT_MODEL_WIKITEXT ) { + $this->error( "Page {$title->getPrefixedText()} does not contain wikitext but {$content->getModel()}\n" ); + return; + } + + $text = strval( $content->getNativeData() ); + + $output1 = $parser1->parse( $text, $title, $this->options ); + $output2 = $parser2->parse( $text, $title, $this->options ); if ( $output1->getText() != $output2->getText() ) { $this->failed++; $this->error( "Parsing for {$title->getPrefixedText()} differs\n" ); if ( $this->saveFailed ) { - file_put_contents( $this->saveFailed . '/' . rawurlencode( $title->getPrefixedText() ) . ".txt", $rev->getText()); + file_put_contents( $this->saveFailed . '/' . rawurlencode( $title->getPrefixedText() ) . ".txt", $text ); } if ( $this->showDiff ) { $this->output( wfDiff( $this->stripParameters( $output1->getText() ), $this->stripParameters( $output2->getText() ), '' ) ); @@ -146,4 +156,4 @@ class CompareParsers extends DumpIterator { } $maintClass = "CompareParsers"; -require_once( RUN_MAINTENANCE_IF_MAIN ); +require_once RUN_MAINTENANCE_IF_MAIN;