MediaWiki  REL1_24
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 
00045         return $wgParser->getStripList();
00046     }
00047 
00048     public function __construct() {
00049         parent::__construct();
00050         $this->addOption( 'cache', 'Use and populate the preprocessor cache.', false, false );
00051         $this->addOption( 'preprocessor', 'Preprocessor to use.', false, false );
00052     }
00053 
00054     public function getDbType() {
00055         return Maintenance::DB_NONE;
00056     }
00057 
00058     public function checkOptions() {
00059         global $wgParser, $wgParserConf, $wgPreprocessorCacheThreshold;
00060 
00061         if ( !$this->hasOption( 'cache' ) ) {
00062             $wgPreprocessorCacheThreshold = false;
00063         }
00064 
00065         if ( $this->hasOption( 'preprocessor' ) ) {
00066             $name = $this->getOption( 'preprocessor' );
00067         } elseif ( isset( $wgParserConf['preprocessorClass'] ) ) {
00068             $name = $wgParserConf['preprocessorClass'];
00069         } else {
00070             $name = 'Preprocessor_DOM';
00071         }
00072 
00073         $wgParser->firstCallInit();
00074         $this->mPreprocessor = new $name( $this );
00075     }
00076 
00081     public function processRevision( $rev ) {
00082         $content = $rev->getContent( Revision::RAW );
00083 
00084         if ( $content->getModel() !== CONTENT_MODEL_WIKITEXT ) {
00085             return;
00086         }
00087 
00088         try {
00089             $this->mPreprocessor->preprocessToObj( strval( $content->getNativeData() ), 0 );
00090         } catch ( Exception $e ) {
00091             $this->error( "Caught exception " . $e->getMessage() . " in "
00092                 . $rev->getTitle()->getPrefixedText() );
00093         }
00094     }
00095 }
00096 
00097 $maintClass = "PreprocessDump";
00098 require_once RUN_MAINTENANCE_IF_MAIN;