summaryrefslogtreecommitdiff
path: root/maintenance/compareParsers.php
diff options
context:
space:
mode:
authorPierre Schmitz <pierre@archlinux.de>2013-01-18 16:46:04 +0100
committerPierre Schmitz <pierre@archlinux.de>2013-01-18 16:46:04 +0100
commit63601400e476c6cf43d985f3e7b9864681695ed4 (patch)
treef7846203a952e38aaf66989d0a4702779f549962 /maintenance/compareParsers.php
parent8ff01378c9e0207f9169b81966a51def645b6a51 (diff)
Update to MediaWiki 1.20.2
this update includes: * adjusted Arch Linux skin * updated FluxBBAuthPlugin * patch for https://bugzilla.wikimedia.org/show_bug.cgi?id=44024
Diffstat (limited to 'maintenance/compareParsers.php')
-rw-r--r--maintenance/compareParsers.php47
1 files changed, 27 insertions, 20 deletions
diff --git a/maintenance/compareParsers.php b/maintenance/compareParsers.php
index 4fe4e4d0..a3337173 100644
--- a/maintenance/compareParsers.php
+++ b/maintenance/compareParsers.php
@@ -6,8 +6,9 @@
*
* Templates etc are pulled from the local wiki database, not from the dump.
*
- * Copyright (C) 2011 Platonides - http://www.mediawiki.org/
- *
+ * Copyright © 2011 Platonides
+ * http://www.mediawiki.org/
+ *
* This program is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation; either version 2 of the License, or
@@ -26,9 +27,15 @@
* @file
* @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
+ * basic HTML out to files.
+ *
+ * @ingroup Maintenance
+ */
class CompareParsers extends DumpIterator {
private $count = 0;
@@ -51,10 +58,10 @@ class CompareParsers extends DumpIterator {
if ( $this->hasOption('save-failed') ) {
$this->saveFailed = $this->getOption('save-failed');
}
-
+
$this->stripParametersEnabled = $this->hasOption( 'strip-parameters' );
$this->showParsedOutput = $this->hasOption( 'show-parsed-output' );
-
+
$this->showDiff = $this->hasOption( 'show-diff' );
if ( $this->showDiff ) {
$bin = $this->getOption( 'diff-bin', getenv( 'DIFF' ) );
@@ -63,10 +70,10 @@ class CompareParsers extends DumpIterator {
$wgDiff = $bin;
}
}
-
- $user = new User();
+
+ $user = new User();
$this->options = ParserOptions::newFromUser( $user );
-
+
if ( $this->hasOption( 'tidy' ) ) {
global $wgUseTidy;
if ( !$wgUseTidy ) {
@@ -74,46 +81,46 @@ class CompareParsers extends DumpIterator {
}
$this->options->setTidy( true );
}
-
+
$this->failed = 0;
}
-
- public function conclusions() {
+
+ public function conclusions() {
$this->error( "{$this->failed} failed revisions out of {$this->count}" );
if ($this->count > 0)
$this->output( " (" . ( $this->failed / $this->count ) . "%)\n" );
}
-
+
function stripParameters( $text ) {
if ( !$this->stripParametersEnabled ) {
return $text;
}
return preg_replace( '/(<a) [^>]+>/', '$1>', $text );
}
-
+
/**
* Callback function for each revision, parse with both parsers and compare
* @param $rev Revision
*/
public function processRevision( $rev ) {
$title = $rev->getTitle();
-
+
$parser1Name = $this->getOption( 'parser1' );
$parser2Name = $this->getOption( 'parser2' );
-
+
self::checkParserLocally( $parser1Name );
self::checkParserLocally( $parser2Name );
-
+
$parser1 = new $parser1Name();
$parser2 = new $parser2Name();
-
+
$output1 = $parser1->parse( $rev->getText(), $title, $this->options );
$output2 = $parser2->parse( $rev->getText(), $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());
}
@@ -127,7 +134,7 @@ class CompareParsers extends DumpIterator {
}
}
}
-
+
private static function checkParserLocally( $parserName ) {
/* Look for the parser in a file appropiately named in the current folder */
if ( !class_exists( $parserName ) && file_exists( "$parserName.php" ) ) {