97 if ( $this->hasOption(
'save-failed' ) ) {
98 $this->saveFailed = $this->getOption(
'save-failed' );
101 $this->stripParametersEnabled = $this->hasOption(
'strip-parameters' );
102 $this->showParsedOutput = $this->hasOption(
'show-parsed-output' );
104 $this->showDiff = $this->hasOption(
'show-diff' );
105 if ( $this->showDiff ) {
106 $bin = $this->getOption(
'diff-bin', getenv(
'DIFF' ) );
114 $this->options = ParserOptions::newFromUser( $user );
141 $parser1Name = $this->getOption(
'parser1' );
142 $parser2Name = $this->getOption(
'parser2' );
144 self::checkParserLocally( $parser1Name );
145 self::checkParserLocally( $parser2Name );
147 $parser1 =
new $parser1Name();
148 $parser2 =
new $parser2Name();
153 $this->error(
"Page {$title->getPrefixedText()} does not contain wikitext "
154 .
"but {$content->getModel()}\n" );
160 '@phan-var WikitextContent $content';
161 $text = strval( $content->getText() );
163 $output1 = $parser1->parse( $text, $title, $this->options );
164 $output2 = $parser2->parse( $text, $title, $this->options );
166 if ( $output1->getText() != $output2->getText() ) {
168 $this->error(
"Parsing for {$title->getPrefixedText()} differs\n" );
170 if ( $this->saveFailed ) {
172 $this->saveFailed .
'/' . rawurlencode( $title->getPrefixedText() ) .
".txt",
176 if ( $this->showDiff ) {
178 explode(
"\n", $this->stripParameters( $output1->getText() ) ),
179 explode(
"\n", $this->stripParameters( $output2->getText() ) )
182 $unifiedDiff = $formatter->format( $diffs );
184 $this->output( $unifiedDiff );
187 $this->output( $title->getPrefixedText() .
"\tOK\n" );
189 if ( $this->showParsedOutput ) {
190 $this->output( $this->stripParameters( $output1->getText() ) );