MediaWiki REL1_35
preprocessDump.php
Go to the documentation of this file.
1<?php
29
30require_once __DIR__ . '/dumpIterator.php';
31
39
40 /* Variables for dressing up as a parser */
41 public $mTitle = 'PreprocessDump';
42 public $mPPNodeCount = 0;
45
46 public function getStripList() {
47 $parser = MediaWikiServices::getInstance()->getParser();
48
49 return $parser->getStripList();
50 }
51
52 public function __construct() {
53 parent::__construct();
54 $this->addOption( 'cache', 'Use and populate the preprocessor cache.', false, false );
55 $this->addOption( 'preprocessor', 'This option is ignored', false, false );
56 }
57
58 public function getDbType() {
60 }
61
62 public function checkOptions() {
64
65 if ( !$this->hasOption( 'cache' ) ) {
66 $wgPreprocessorCacheThreshold = false;
67 }
68
69 $parser = MediaWikiServices::getInstance()->getParser();
70 $parser->firstCallInit();
71 $this->mPreprocessor = new Preprocessor_Hash( $parser );
72 }
73
78 public function processRevision( WikiRevision $rev ) {
79 $content = $rev->getContent();
80
81 if ( $content->getModel() !== CONTENT_MODEL_WIKITEXT ) {
82 return;
83 }
85 '@phan-var WikitextContent $content';
86
87 try {
88 $this->mPreprocessor->preprocessToObj( strval( $content->getText() ), 0 );
89 } catch ( Exception $e ) {
90 $this->error( "Caught exception " . $e->getMessage() . " in "
91 . $rev->getTitle()->getPrefixedText() );
92 }
93 }
94}
95
96$maintClass = PreprocessDump::class;
97require_once RUN_MAINTENANCE_IF_MAIN;
$wgPreprocessorCacheThreshold
Preprocessor caching threshold Setting it to 'false' will disable the preprocessor cache.
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 was set.
addOption( $name, $description, $required=false, $withArg=false, $shortName=false, $multiOccurrence=false)
Add a parameter to the script.
MediaWikiServices is the service locator for the application scope of MediaWiki.
Maintenance script that takes page text out of an XML dump file and preprocesses it to obj.
checkOptions()
Stub function for processing additional options.
processRevision(WikiRevision $rev)
Callback function for each revision, preprocessToObj()
__construct()
Default constructor.
getDbType()
Does the script need different DB access? By default, we give Maintenance scripts normal rights to th...
Preprocessor $mPreprocessor
Differences from DOM schema:
Represents a revision, log entry or upload during the import process.
getContent( $role=SlotRecord::MAIN)
const CONTENT_MODEL_WIKITEXT
Definition Defines.php:225
$maintClass
$content
Definition router.php:76