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