X-Git-Url: https://git.heureux-cyclage.org/?a=blobdiff_plain;f=maintenance%2FcompareParsers.php;h=1f3ac1c3b3230be7144b2b69611d38715e0c092b;hb=fd57f6d153913af8c15d0cb4d5c2a84e075d4367;hp=9d7f5c7793a424f5687d887002e129b8ae9c0bf9;hpb=cf4da8140bb49803360bcf610ff88d3c19cd07b0;p=lhc%2Fweb%2Fwiklou.git diff --git a/maintenance/compareParsers.php b/maintenance/compareParsers.php index 9d7f5c7793..1f3ac1c3b3 100644 --- a/maintenance/compareParsers.php +++ b/maintenance/compareParsers.php @@ -28,7 +28,7 @@ * @ingroup Maintenance */ -require_once( dirname( __FILE__ ) . '/dumpIterator.php' ); +require_once( __DIR__ . '/dumpIterator.php' ); /** * Maintenance script to take page text out of an XML dump file and render @@ -114,15 +114,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() ), '' ) );