29require_once __DIR__ .
'/Maintenance.php';
42 parent::__construct();
44 $this->
addOption(
'file',
'File with text to run.',
false,
true );
45 $this->
addOption(
'dump',
'XML dump to execute all revisions.',
false,
true );
46 $this->
addOption(
'from',
'Article from XML dump to start from.',
false,
true );
51 $this->
error(
"You must provide a file or dump",
true );
59 $revision->setText( file_get_contents( $this->
getOption(
'file' ) ) );
60 $revision->setTitle( Title::newFromText(
61 rawurldecode( basename( $this->
getOption(
'file' ),
'.txt' ) )
68 $this->startTime = microtime(
true );
70 if ( $this->
getOption(
'dump' ) ==
'-' ) {
73 $this->
error(
"Sorry, I don't support dump filenames yet. "
74 .
"Use - and provide it on stdin on the meantime.",
true );
78 $importer->setRevisionCallback(
79 [ $this,
'handleRevision' ] );
83 $importer->doImport();
88 $this->
error(
"Done {$this->count} revisions in " . round( $delta, 2 ) .
" seconds " );
90 $this->
error( round( $this->count / $delta, 2 ) .
" pages/sec" );
93 # Perform the memory_get_peak_usage() when all the other data has been
94 # output so there's no damage if it dies. It is only available since
95 # 5.2.0 (since 5.2.1 if you haven't compiled with --enable-memory-limit)
96 $this->
error(
"Memory peak usage of " . memory_get_peak_usage() .
" bytes\n" );
100 parent::finalSetup();
106 $wgHooks[
'InterwikiLoadPrefix'][] =
'DumpIterator::disableInterwikis';
111 # Title::newFromText will check on each namespaced article if it's an interwiki.
112 # We always answer that it is not.
125 $this->
error(
"Got bogus revision with null title!" );
131 if ( isset( $this->
from ) ) {
135 $this->
output(
"Skipped " . ( $this->count - 1 ) .
" pages\n" );
166 parent::__construct();
167 $this->
addDescription(
'Runs a regex in the revisions from a dump' );
168 $this->
addOption(
'regex',
'Searching regex',
true,
true );
179 if ( preg_match( $this->
getOption(
'regex' ),
$rev->getContent()->getTextForSearchIndex() ) ) {
180 $this->
output(
$rev->getTitle() .
" matches at edit from " .
$rev->getTimestamp() .
"\n" );
Apache License January AND DISTRIBUTION Definitions License shall mean the terms and conditions for and distribution as defined by Sections through of this document Licensor shall mean the copyright owner or entity authorized by the copyright owner that is granting the License Legal Entity shall mean the union of the acting entity and all other entities that control are controlled by or are under common control with that entity For the purposes of this definition control direct or to cause the direction or management of such whether by contract or including but not limited to software source documentation and configuration files Object form shall mean any form resulting from mechanical transformation or translation of a Source including but not limited to compiled object generated and conversions to other media types Work shall mean the work of whether in Source or Object made available under the as indicated by a copyright notice that is included in or attached to the whether in Source or Object that is based or other modifications as a an original work of authorship For the purposes of this Derivative Works shall not include works that remain separable from
$wgUseDatabaseMessages
Translation using MediaWiki: namespace.
$wgLocalisationCacheConf
Localisation cache configuration.
Base class for interating over a dump.
static disableInterwikis( $prefix, &$data)
__construct()
Default constructor.
execute()
Do the actual work.
finalSetup()
Handle some last-minute setup here.
handleRevision( $rev)
Callback function for each revision, child classes should override processRevision instead.
Imports a XML dump from a file (either from file upload, files on disk, or HTTP)
Abstract maintenance class for quickly writing and churning out maintenance scripts with minimal effo...
error( $err, $die=0)
Throw an error to the user.
const DB_NONE
Constants for DB access type.
getStdin( $len=null)
Return input from stdin.
hasOption( $name)
Checks to see if a particular param exists.
getDbType()
Does the script need different DB access? By default, we give Maintenance scripts normal rights to th...
addDescription( $text)
Set the description text.
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.
Maintenance script that runs a regex in the revisions from a dump.
__construct()
Default constructor.
getDbType()
Does the script need different DB access? By default, we give Maintenance scripts normal rights to th...
XML file reader for the page data importer.
Represents a revision, log entry or upload during the import process.
design txt This is a brief overview of the new design More thorough and up to date information is available on the documentation wiki at etc Handles the details of getting and saving to the user table of the and dealing with sessions and cookies OutputPage Encapsulates the entire HTML page that will be sent in response to any server request It is used by calling its functions to add in any and then calling output() to send it all. It could be easily changed to send incrementally if that becomes useful
when a variable name is used in a it is silently declared as a new local masking the global
namespace and then decline to actually register it file or subcat img or subcat $title
$wgHooks['ArticleShow'][]
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
injection txt This is an overview of how MediaWiki makes use of dependency injection The design described here grew from the discussion of RFC T384 The term dependency this means that anything an object needs to operate should be injected from the the object itself should only know narrow no concrete implementation of the logic it relies on The requirement to inject everything typically results in an architecture that based on two main types of and essentially stateless service objects that use other service objects to operate on the value objects As of the beginning MediaWiki is only starting to use the DI approach Much of the code still relies on global state or direct resulting in a highly cyclical dependency which acts as the top level factory for services in MediaWiki which can be used to gain access to default instances of various services MediaWikiServices however also allows new services to be defined and default services to be redefined Services are defined or redefined by providing a callback the instantiator that will return a new instance of the service When it will create an instance of MediaWikiServices and populate it with the services defined in the files listed by thereby bootstrapping the DI framework Per $wgServiceWiringFiles lists includes ServiceWiring php
require_once RUN_MAINTENANCE_IF_MAIN