MediaWiki  REL1_19
preprocessDump.php
Go to the documentation of this file.
00001 <?php
00028 require_once( dirname( __FILE__ ) . '/dumpIterator.php' );
00029 
00030 class PreprocessDump extends DumpIterator {
00031 
00032         /* Variables for dressing up as a parser */
00033         public $mTitle = 'PreprocessDump';
00034         public $mPPNodeCount = 0;
00035 
00036         public function getStripList() {
00037                 global $wgParser;
00038                 return $wgParser->getStripList();
00039         }
00040 
00041         public function __construct() {
00042                 parent::__construct();
00043                 $this->addOption( 'cache', 'Use and populate the preprocessor cache.', false, false );
00044                 $this->addOption( 'preprocessor', 'Preprocessor to use.', false, false );
00045         }
00046 
00047         public function getDbType() {
00048                 return Maintenance::DB_NONE;
00049         }
00050 
00051         public function checkOptions() {
00052                 global $wgParser, $wgParserConf, $wgPreprocessorCacheThreshold;
00053 
00054                 if ( !$this->hasOption( 'cache' ) ) {
00055                         $wgPreprocessorCacheThreshold = false;
00056                 }
00057 
00058                 if ( $this->hasOption( 'preprocessor' ) ) {
00059                         $name = $this->getOption( 'preprocessor' );
00060                 } elseif ( isset( $wgParserConf['preprocessorClass'] ) ) {
00061                         $name = $wgParserConf['preprocessorClass'];
00062                 } else {
00063                         $name = 'Preprocessor_DOM';
00064                 }
00065 
00066                 $wgParser->firstCallInit();
00067                 $this->mPreprocessor = new $name( $this );
00068         }
00069 
00074         public function processRevision( $rev ) {
00075                 try {
00076                         $this->mPreprocessor->preprocessToObj( $rev->getText(), 0 );
00077                 }
00078                 catch(Exception $e) {
00079                         $this->error("Caught exception " . $e->getMessage() . " in " . $rev->getTitle()->getPrefixedText() );
00080                 }
00081         }
00082 }
00083 
00084 $maintClass = "PreprocessDump";
00085 require_once( RUN_MAINTENANCE_IF_MAIN );
00086