MediaWiki REL1_34
preprocessDump.php
Go to the documentation of this file.
1<?php
30
31require_once __DIR__ . '/dumpIterator.php';
32
40
41 /* Variables for dressing up as a parser */
42 public $mTitle = 'PreprocessDump';
43 public $mPPNodeCount = 0;
46
47 public function getStripList() {
48 $parser = MediaWikiServices::getInstance()->getParser();
49
50 return $parser->getStripList();
51 }
52
53 public function __construct() {
54 parent::__construct();
55 $this->addOption( 'cache', 'Use and populate the preprocessor cache.', false, false );
56 $this->addOption( 'preprocessor', 'Preprocessor to use.', false, false );
57 }
58
59 public function getDbType() {
61 }
62
63 public function checkOptions() {
65
66 if ( !$this->hasOption( 'cache' ) ) {
67 $wgPreprocessorCacheThreshold = false;
68 }
69
70 if ( $this->hasOption( 'preprocessor' ) ) {
71 $name = $this->getOption( 'preprocessor' );
72 } elseif ( isset( $wgParserConf['preprocessorClass'] ) ) {
73 $name = $wgParserConf['preprocessorClass'];
74 } else {
75 $name = Preprocessor_DOM::class;
76 }
77
78 $parser = MediaWikiServices::getInstance()->getParser();
79 $parser->firstCallInit();
80 $this->mPreprocessor = new $name( $parser );
81 }
82
87 public function processRevision( $rev ) {
88 $content = $rev->getContent( RevisionRecord::RAW );
89
90 if ( $content->getModel() !== CONTENT_MODEL_WIKITEXT ) {
91 return;
92 }
94 '@phan-var WikitextContent $content';
95
96 try {
97 $this->mPreprocessor->preprocessToObj( strval( $content->getText() ), 0 );
98 } catch ( Exception $e ) {
99 $this->error( "Caught exception " . $e->getMessage() . " in "
100 . $rev->getTitle()->getPrefixedText() );
101 }
102 }
103}
104
106require_once RUN_MAINTENANCE_IF_MAIN;
$wgPreprocessorCacheThreshold
Preprocessor caching threshold Setting it to 'false' will disable the preprocessor cache.
$wgParserConf
Parser configuration.
const RUN_MAINTENANCE_IF_MAIN
Base class for interating over a dump.
error( $err, $die=0)
Throw an error to the user.
const DB_NONE
Constants for DB access type.
hasOption( $name)
Checks to see if a particular option exists.
addOption( $name, $description, $required=false, $withArg=false, $shortName=false, $multiOccurrence=false)
Add a parameter to the script.
getOption( $name, $default=null)
Get an option, or return the default.
MediaWikiServices is the service locator for the application scope of MediaWiki.
Page revision base class.
Maintenance script that takes page text out of an XML dump file and preprocesses it to obj.
__construct()
Default constructor.
getDbType()
Does the script need different DB access? By default, we give Maintenance scripts normal rights to th...
Preprocessor $mPreprocessor
processRevision( $rev)
Callback function for each revision, preprocessToObj()
const CONTENT_MODEL_WIKITEXT
Definition Defines.php:224
$maintClass
$content
Definition router.php:78