3 * Take page text out of an XML dump file and preprocess it to obj.
4 * It may be useful for getting preprocessor statistics or filling the
7 * Copyright (C) 2011 Platonides - http://www.mediawiki.org/
9 * This program is free software; you can redistribute it and/or modify
10 * it under the terms of the GNU General Public License as published by
11 * the Free Software Foundation; either version 2 of the License, or
12 * (at your option) any later version.
14 * This program is distributed in the hope that it will be useful,
15 * but WITHOUT ANY WARRANTY; without even the implied warranty of
16 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
17 * GNU General Public License for more details.
19 * You should have received a copy of the GNU General Public License along
20 * with this program; if not, write to the Free Software Foundation, Inc.,
21 * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
22 * http://www.gnu.org/copyleft/gpl.html
25 * @ingroup Maintenance
28 require_once( dirname( __FILE__
) . '/dumpIterator.php' );
30 class PreprocessDump
extends DumpIterator
{
32 /* Variables for dressing up as a parser */
33 public $mTitle = 'PreprocessDump';
34 public $mPPNodeCount = 0;
36 public function getStripList() {
38 return $wgParser->getStripList();
41 public function __construct() {
42 parent
::__construct();
43 $this->addOption( 'cache', 'Use and populate the preprocessor cache.', false, false );
44 $this->addOption( 'preprocessor', 'Preprocessor to use.', false, false );
47 public function getDbType() {
48 return Maintenance
::DB_NONE
;
51 public function checkOptions() {
52 global $wgParser, $wgParserConf, $wgPreprocessorCacheThreshold;
54 if ( !$this->hasOption( 'cache' ) ) {
55 $wgPreprocessorCacheThreshold = false;
58 if ( $this->hasOption( 'preprocessor' ) ) {
59 $name = $this->getOption( 'preprocessor' );
60 } elseif ( isset( $wgParserConf['preprocessorClass'] ) ) {
61 $name = $wgParserConf['preprocessorClass'];
63 $name = 'Preprocessor_DOM';
66 $wgParser->firstCallInit();
67 $this->mPreprocessor
= new $name( $this );
71 * Callback function for each revision, preprocessToObj()
72 * @param $rev Revision
74 public function processRevision( $rev ) {
76 $this->mPreprocessor
->preprocessToObj( $rev->getText(), 0 );
79 $this->error("Caught exception " . $e->getMessage() . " in " . $rev->getTitle()->getPrefixedText() );
84 $maintClass = "PreprocessDump";
85 require_once( RUN_MAINTENANCE_IF_MAIN
);