MediaWiki  1.23.2
preprocessDump.php
Go to the documentation of this file.
1 <?php
28 require_once __DIR__ . '/dumpIterator.php';
29 
37 
38  /* Variables for dressing up as a parser */
39  public $mTitle = 'PreprocessDump';
40  public $mPPNodeCount = 0;
41 
42  public function getStripList() {
44  return $wgParser->getStripList();
45  }
46 
47  public function __construct() {
48  parent::__construct();
49  $this->addOption( 'cache', 'Use and populate the preprocessor cache.', false, false );
50  $this->addOption( 'preprocessor', 'Preprocessor to use.', false, false );
51  }
52 
53  public function getDbType() {
54  return Maintenance::DB_NONE;
55  }
56 
57  public function checkOptions() {
58  global $wgParser, $wgParserConf, $wgPreprocessorCacheThreshold;
59 
60  if ( !$this->hasOption( 'cache' ) ) {
61  $wgPreprocessorCacheThreshold = false;
62  }
63 
64  if ( $this->hasOption( 'preprocessor' ) ) {
65  $name = $this->getOption( 'preprocessor' );
66  } elseif ( isset( $wgParserConf['preprocessorClass'] ) ) {
67  $name = $wgParserConf['preprocessorClass'];
68  } else {
69  $name = 'Preprocessor_DOM';
70  }
71 
72  $wgParser->firstCallInit();
73  $this->mPreprocessor = new $name( $this );
74  }
75 
80  public function processRevision( $rev ) {
81  $content = $rev->getContent( Revision::RAW );
82 
83  if ( $content->getModel() !== CONTENT_MODEL_WIKITEXT ) {
84  return;
85  }
86 
87  try {
88  $this->mPreprocessor->preprocessToObj( strval( $content->getNativeData() ), 0 );
89  } catch ( Exception $e ) {
90  $this->error( "Caught exception " . $e->getMessage() . " in " . $rev->getTitle()->getPrefixedText() );
91  }
92  }
93 }
94 
95 $maintClass = "PreprocessDump";
96 require_once RUN_MAINTENANCE_IF_MAIN;
PreprocessDump
Maintenance script that takes page text out of an XML dump file and preprocesses it to obj.
Definition: preprocessDump.php:36
php
skin txt MediaWiki includes four core it has been set as the default in MediaWiki since the replacing Monobook it had been been the default skin since before being replaced by Vector largely rewritten in while keeping its appearance Several legacy skins were removed in the as the burden of supporting them became too heavy to bear Those in etc for skin dependent CSS etc for skin dependent JavaScript These can also be customised on a per user by etc This feature has led to a wide variety of user styles becoming that gallery is a good place to ending in php
Definition: skin.txt:62
PreprocessDump\$mPPNodeCount
$mPPNodeCount
Definition: preprocessDump.php:40
Maintenance\addOption
addOption( $name, $description, $required=false, $withArg=false, $shortName=false)
Add a parameter to the script.
Definition: Maintenance.php:169
RUN_MAINTENANCE_IF_MAIN
require_once RUN_MAINTENANCE_IF_MAIN
Definition: maintenance.txt:50
CONTENT_MODEL_WIKITEXT
const CONTENT_MODEL_WIKITEXT
Definition: Defines.php:283
PreprocessDump\__construct
__construct()
Default constructor.
Definition: preprocessDump.php:47
PreprocessDump\getStripList
getStripList()
Definition: preprocessDump.php:42
PreprocessDump\checkOptions
checkOptions()
Definition: preprocessDump.php:57
global
when a variable name is used in a it is silently declared as a new masking the global
Definition: design.txt:93
PreprocessDump\getDbType
getDbType()
Does the script need different DB access? By default, we give Maintenance scripts normal rights to th...
Definition: preprocessDump.php:53
$maintClass
$maintClass
Definition: preprocessDump.php:95
PreprocessDump\$mTitle
$mTitle
Definition: preprocessDump.php:39
$name
Allows to change the fields on the form that will be generated $name
Definition: hooks.txt:336
Revision\RAW
const RAW
Definition: Revision.php:74
Maintenance\DB_NONE
const DB_NONE
Constants for DB access type.
Definition: Maintenance.php:57
DumpIterator
Base class for interating over a dump.
Definition: dumpIterator.php:36
$rev
presenting them properly to the user as errors is done by the caller return true use this to change the list i e etc $rev
Definition: hooks.txt:1337
Maintenance\getOption
getOption( $name, $default=null)
Get an option, or return the default.
Definition: Maintenance.php:191
$wgParser
$wgParser
Definition: Setup.php:567
Maintenance\error
error( $err, $die=0)
Throw an error to the user.
Definition: Maintenance.php:333
PreprocessDump\processRevision
processRevision( $rev)
Callback function for each revision, preprocessToObj()
Definition: preprocessDump.php:80
Maintenance\hasOption
hasOption( $name)
Checks to see if a particular param exists.
Definition: Maintenance.php:181
$e
if( $useReadline) $e
Definition: eval.php:66