29require_once __DIR__ .
'/Maintenance.php';
47 parent::__construct();
50 :
'(disabled; requires PHP zlib module)';
53 :
'(disabled; requires PHP bzip2 module)';
58dumpBackup.php, and saves them into the current wiki.
60Compressed XML
files may be read directly:
63 .7z (
if 7za executable is in PATH)
65Note that
for very large data
sets, importDump.php may be
slow; there are
66alternate methods which can be much faster
for full site
restoration:
70 $this->stderr =
fopen(
"php://stderr",
"wt" );
72 'Report position and speed after every n pages processed',
false,
true );
74 'Import only the pages from namespaces belonging to the list of ' .
75 'pipe-separated namespace names or namespace indexes',
false,
true );
76 $this->
addOption(
'rootpage',
'Pages will be imported as subpages of the specified page',
78 $this->
addOption(
'dry-run',
'Parse dump without actually importing pages' );
79 $this->
addOption(
'debug',
'Output extra verbose debug information' );
80 $this->
addOption(
'uploads',
'Process file upload data if included (experimental)' );
83 'Disable link table updates. Is faster but leaves the wiki in an inconsistent state'
85 $this->
addOption(
'image-base-path',
'Import files from a specified path',
false,
true );
86 $this->
addOption(
'skip-to',
'Start from nth page by skipping first n-1 pages',
false,
true );
87 $this->
addOption(
'username-prefix',
'Prefix for interwiki usernames',
false,
true );
89 'Treat all usernames as interwiki. ' .
90 'The default is to assign edits to local users where they exist.',
93 $this->
addArg(
'file',
'Dump file to import [else use stdin]',
false );
98 $this->
fatalError(
"Wiki is in read-only mode; you'll need to disable it for import to work." );
101 $this->reportingInterval =
intval( $this->
getOption(
'report', 100 ) );
102 if ( !$this->reportingInterval ) {
103 $this->reportingInterval = 100;
106 $this->dryRun = $this->
hasOption(
'dry-run' );
107 $this->uploads = $this->
hasOption(
'uploads' );
108 if ( $this->
hasOption(
'image-base-path' ) ) {
109 $this->imageBasePath = $this->
getOption(
'image-base-path' );
111 if ( $this->
hasOption(
'namespaces' ) ) {
115 if ( $this->
hasArg( 0 ) ) {
121 $this->
output(
"Done!\n" );
122 $this->
output(
"You might want to run rebuildrecentchanges.php to regenerate RecentChanges,\n" );
123 $this->
output(
"and initSiteStats.php to update page and revision counts\n" );
128 $this->nsFilter =
false;
136 $contLang = MediaWikiServices::getInstance()->getContentLanguage();
137 $result = $contLang->getNsIndex( $namespace );
138 if ( $result !==
false ) {
141 $ns =
intval( $namespace );
142 if (
strval( $ns ) === $namespace && $contLang->getNsText( $ns ) !==
false ) {
145 $this->
fatalError(
"Unknown namespace text / index specified: $namespace" );
155 if ( $obj instanceof
Title ) {
158 $title = $obj->getTitle();
160 $title = $obj->title;
162 throw new MWException(
"Cannot get namespace of object in " . __METHOD__ );
170 $ns = $title->getNamespace();
183 $title =
$rev->getTitle();
185 $this->
progress(
"Got bogus revision with null title!" );
197 if ( !$this->dryRun ) {
207 if ( $this->uploads ) {
211 $this->uploadCount++;
213 $this->
progress(
"upload: " . $revision->getFilename() );
215 if ( !$this->dryRun ) {
220 return $dbw->deadlockLoop( [ $revision,
'importUpload' ] );
234 if ( !$this->dryRun ) {
240 if ( $final xor ( $this->pageCount % $this->reportingInterval == 0 ) ) {
246 if ( !$this->mQuiet ) {
247 $delta =
microtime(
true ) - $this->startTime;
249 $rate =
sprintf(
"%.2f", $this->pageCount / $delta );
250 $revrate =
sprintf(
"%.2f", $this->revCount / $delta );
255 # Logs dumps don't have page tallies
256 if ( $this->pageCount ) {
257 $this->
progress(
"$this->pageCount ($rate pages/sec $revrate revs/sec)" );
259 $this->
progress(
"$this->revCount ($revrate revs/sec)" );
266 fwrite( $this->stderr, $string .
"\n" );
271 $filename =
'compress.zlib://' . $filename;
273 $filename =
'compress.bzip2://' . $filename;
275 $filename =
'mediawiki.compress.7z://' . $filename;
278 $file =
fopen( $filename,
'rt' );
284 $file =
fopen(
'php://stdin',
'rt' );
285 if ( self::posix_isatty( $file ) ) {
299 $importer->disableStatisticsUpdate();
302 $importer->setDebug(
true );
304 if ( $this->
hasOption(
'no-updates' ) ) {
305 $importer->setNoUpdates(
true );
307 if ( $this->
hasOption(
'username-prefix' ) ) {
308 $importer->setUsernamePrefix(
314 $statusRootPage = $importer->setTargetRootPage( $this->
getOption(
'rootpage' ) );
315 if ( !$statusRootPage->isGood() ) {
317 $this->
fatalError( $statusRootPage->getMessage()->text() );
323 $importer->setPageOffset( $nthPage );
324 $this->pageCount = $nthPage - 1;
326 $importer->setPageCallback( [ $this,
'reportPage' ] );
327 $importer->setNoticeCallback(
function ( $msg,
$params ) {
330 $this->importCallback = $importer->setRevisionCallback(
331 [ $this,
'handleRevision' ] );
332 $this->uploadCallback = $importer->setUploadCallback(
333 [ $this,
'handleUpload' ] );
334 $this->logItemCallback = $importer->setLogItemCallback(
335 [ $this,
'handleLogItem' ] );
336 if ( $this->uploads ) {
337 $importer->setImportUploads(
true );
339 if ( $this->imageBasePath ) {
340 $importer->setImageBasePath( $this->imageBasePath );
343 if ( $this->dryRun ) {
344 $importer->setPageOutCallback(
null );
347 return $importer->doImport();
and that you know you can do these things To protect your we need to make restrictions that forbid anyone to deny you these rights or to ask you to surrender the rights These restrictions translate to certain responsibilities for you if you distribute copies of the or if you modify it For if you distribute copies of such a whether gratis or for a you must give the recipients all the rights that you have You must make sure that receive or can get the source code And you must show them these terms so they know their rights We protect your rights with two and(2) offer you this license which gives you legal permission to copy
c Accompany it with the information you received as to the offer to distribute corresponding source complete source code means all the source code for all modules it plus any associated interface definition files
wfWaitForSlaves( $ifWritesSince=null, $wiki=false, $cluster=false, $timeout=null)
Waits for the replica DBs to catch up to the master position.
wfReadOnly()
Check whether the wiki is in read-only mode.
Maintenance script that imports XML dump files into the current wiki.
importFromFile( $filename)
execute()
Do the actual work.
__construct()
Default constructor.
importFromHandle( $handle)
setNsfilter(array $namespaces)
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...
addArg( $arg, $description, $required=true)
Add some args that are needed.
output( $out, $channel=null)
Throw some output to the user.
hasArg( $argId=0)
Does a given argument exist?
getDB( $db, $groups=[], $wiki=false)
Returns a database to be used by current maintenance script.
hasOption( $name)
Checks to see if a particular option exists.
getArg( $argId=0, $default=null)
Get an argument.
addDescription( $text)
Set the description text.
maybeHelp( $force=false)
Maybe show the help.
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.
fatalError( $msg, $exitCode=1)
Output a message and terminate the current script.
Represents a title within MediaWiki.
XML file reader for the page data importer.
Represents a revision, log entry or upload during the import process.
The ContentHandler facility adds support for arbitrary content types on wiki pages
Use of locking reads(e.g. the FOR UPDATE clause) is not advised. They are poorly implemented in InnoDB and will cause regular deadlock errors. It 's also surprisingly easy to cripple the wiki with lock contention. Instead of locking reads
namespace being checked & $result
namespace and then decline to actually register it & $namespaces
either a unescaped string or a HtmlArmor object after in associative array form externallinks including delete and has completed for all link tables whether this was an auto creation use $formDescriptor instead default is conds Array Extra conditions for the No matching items in log is displayed if loglist is empty msgKey Array If you want a nice box with a set this to the key of the message First element is the message additional optional elements are parameters for the key that are processed with wfMessage() -> params() ->parseAsBlock() - offset Set to overwrite offset parameter in $wgRequest set to '' to unset offset - wrap String Wrap the message in html(usually something like "<div ...>$1</div>"). - flags Integer display flags(NO_ACTION_LINK, NO_EXTRA_USER_LINKS) 'LogException':Called before an exception(or PHP error) is logged. This is meant for integration with external error aggregation services
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
script(document.cookie)%253c/script%253e</pre ></div > !! end !! test XSS is escaped(inline) !!input< source lang
require_once RUN_MAINTENANCE_IF_MAIN
The wiki should then use memcached to cache various data To use multiple just add more items to the array To increase the weight of a make its entry a array("192.168.0.1:11211", 2))
scripts txt MediaWiki primary scripts are in the root directory of the software Users should only use these scripts to access the wiki There are also some php that aren t primary scripts but helper files and won t work if they are accessed directly by the web Primary see https