MediaWiki master
MediaWiki\Export\WikiExporter Class Reference
Collaboration diagram for MediaWiki\Export\WikiExporter:

Public Member Functions

 __construct ( $db, CommentStore $commentStore, HookContainer $hookContainer, RevisionStore $revisionStore, TitleParser $titleParser, $history=self::CURRENT, $text=self::TEXT, $limitNamespaces=null)
 
 allLogs ()
 
 allPages ()
 Dumps a series of page and revision records for all pages in the database, either including complete history or only the most recent version.
 
 closeStream ()
 
 logsByRange ( $start, $end)
 
 openStream ()
 
 pageByName ( $name)
 
 pageByTitle (PageIdentity $page)
 
 pagesByName ( $names)
 
 pagesByRange ( $start, $end, $orderRevs)
 Dumps a series of page and revision records for those pages in the database falling within the page_id range given.
 
 revsByRange ( $start, $end)
 Dumps a series of page and revision records for those pages in the database with revisions falling within the rev_id range given.
 
 setOutputSink (&$sink)
 Set the DumpOutput or DumpFilter object which will receive various row objects and XML output for filtering.
 
 setSchemaVersion ( $schemaVersion)
 

Static Public Member Functions

static schemaVersion ()
 Returns the default export schema version, as defined by the XmlDumpSchemaVersion setting.
 

Public Attributes

string $author_list = ""
 
bool $dumpUploadFileContents = false
 
bool $dumpUploads = false
 
bool $list_authors = false
 Return distinct author list (when not returning full history)
 
DumpOutput $sink
 
int $text
 
const CURRENT = 2
 
const FULL = 1
 
const LOGS = 8
 
const RANGE = 16
 
const STABLE = 4
 
const STUB = XmlDumpWriter::WRITE_STUB
 
const TEXT = XmlDumpWriter::WRITE_CONTENT
 

Protected Member Functions

 do_list_authors ( $cond)
 Generates the distinct list of authors of an article Not called by default (depends on $this->list_authors) Can be set by Special:Export when not exporting whole history.
 
 dumpFrom ( $cond='', $orderRevs=false)
 
 dumpLogs ( $cond)
 
 dumpPages ( $cond, $orderRevs)
 
 finishPageStreamOutput ( $lastRow)
 Final page stream output, after all batches are complete.
 
 getSlotRowBatch ( $results, &$carry=null)
 Returns all slot rows for a revision.
 
 outputLogStream ( $resultset)
 
 outputPageStreamBatch ( $results, $lastRow)
 Runs through a query result set dumping page, revision, and slot records.
 

Protected Attributes

IReadableDatabase $db
 
array int $history
 
array null $limitNamespaces
 
const BATCH_SIZE = 10000
 

Detailed Description

Definition at line 40 of file WikiExporter.php.

Constructor & Destructor Documentation

◆ __construct()

MediaWiki\Export\WikiExporter::__construct ( $db,
CommentStore $commentStore,
HookContainer $hookContainer,
RevisionStore $revisionStore,
TitleParser $titleParser,
$history = self::CURRENT,
$text = self::TEXT,
$limitNamespaces = null )
Parameters
IReadableDatabase$db
CommentStore$commentStore
HookContainer$hookContainer
RevisionStore$revisionStore
TitleParser$titleParser
int | array$historyOne of WikiExporter::FULL, WikiExporter::CURRENT, WikiExporter::RANGE or WikiExporter::STABLE, or an associative array:
  • offset: non-inclusive offset at which to start the query
  • limit: maximum number of rows to return
  • dir: "asc" or "desc" timestamp order
int$textOne of WikiExporter::TEXT or WikiExporter::STUB
null | array$limitNamespacesList of namespace numbers to limit results

Definition at line 117 of file WikiExporter.php.

References MediaWiki\Export\WikiExporter\$db, MediaWiki\Export\WikiExporter\$history, MediaWiki\Export\WikiExporter\$limitNamespaces, and MediaWiki\Export\WikiExporter\$text.

Member Function Documentation

◆ allLogs()

MediaWiki\Export\WikiExporter::allLogs ( )

Definition at line 250 of file WikiExporter.php.

References MediaWiki\Export\WikiExporter\dumpFrom().

◆ allPages()

MediaWiki\Export\WikiExporter::allPages ( )

Dumps a series of page and revision records for all pages in the database, either including complete history or only the most recent version.

Definition at line 179 of file WikiExporter.php.

References MediaWiki\Export\WikiExporter\dumpFrom().

◆ closeStream()

MediaWiki\Export\WikiExporter::closeStream ( )

Definition at line 169 of file WikiExporter.php.

◆ do_list_authors()

MediaWiki\Export\WikiExporter::do_list_authors ( $cond)
protected

Generates the distinct list of authors of an article Not called by default (depends on $this->list_authors) Can be set by Special:Export when not exporting whole history.

Parameters
string$cond

Definition at line 273 of file WikiExporter.php.

Referenced by MediaWiki\Export\WikiExporter\dumpPages().

◆ dumpFrom()

◆ dumpLogs()

MediaWiki\Export\WikiExporter::dumpLogs ( $cond)
protected
Parameters
string$cond

Definition at line 312 of file WikiExporter.php.

References MediaWiki\Export\WikiExporter\outputLogStream().

Referenced by MediaWiki\Export\WikiExporter\dumpFrom().

◆ dumpPages()

MediaWiki\Export\WikiExporter::dumpPages ( $cond,
$orderRevs )
protected

◆ finishPageStreamOutput()

MediaWiki\Export\WikiExporter::finishPageStreamOutput ( $lastRow)
protected

Final page stream output, after all batches are complete.

Parameters
\\stdClass$lastRowthe last row output from the last batch (or null if none)

Definition at line 585 of file WikiExporter.php.

References MediaWiki\Export\WikiExporter\$author_list.

Referenced by MediaWiki\Export\WikiExporter\dumpPages().

◆ getSlotRowBatch()

MediaWiki\Export\WikiExporter::getSlotRowBatch ( $results,
& $carry = null )
protected

Returns all slot rows for a revision.

Takes and returns a carry row from the last batch;

Parameters
IResultWrapper | array$results
null | \\stdClass&$carryA row carried over from the last call to getSlotRowBatch()
Returns
\stdClass[]

Definition at line 556 of file WikiExporter.php.

Referenced by MediaWiki\Export\WikiExporter\outputPageStreamBatch().

◆ logsByRange()

MediaWiki\Export\WikiExporter::logsByRange ( $start,
$end )
Parameters
int$start
int$end

Definition at line 258 of file WikiExporter.php.

References MediaWiki\Export\WikiExporter\dumpFrom().

◆ openStream()

MediaWiki\Export\WikiExporter::openStream ( )

Definition at line 164 of file WikiExporter.php.

◆ outputLogStream()

MediaWiki\Export\WikiExporter::outputLogStream ( $resultset)
protected
Parameters
IResultWrapper$resultset
Returns
int|null the log_id value of the last item output, or null if none

Definition at line 599 of file WikiExporter.php.

Referenced by MediaWiki\Export\WikiExporter\dumpLogs().

◆ outputPageStreamBatch()

MediaWiki\Export\WikiExporter::outputPageStreamBatch ( $results,
$lastRow )
protected

Runs through a query result set dumping page, revision, and slot records.

The result set should join the page, revision, slots, and content tables, and be sorted/grouped by page and revision to avoid duplicate page records in the output.

Parameters
IResultWrapper$results
\\stdClass | null$lastRowthe last row output from the previous call (or null if none)
Returns
\stdClass the last row processed

Definition at line 496 of file WikiExporter.php.

References MediaWiki\Export\WikiExporter\getSlotRowBatch().

Referenced by MediaWiki\Export\WikiExporter\dumpPages().

◆ pageByName()

MediaWiki\Export\WikiExporter::pageByName ( $name)
Parameters
string$name

Definition at line 230 of file WikiExporter.php.

References MediaWiki\Export\WikiExporter\dumpFrom().

Referenced by MediaWiki\Export\WikiExporter\pagesByName().

◆ pageByTitle()

MediaWiki\Export\WikiExporter::pageByTitle ( PageIdentity $page)

◆ pagesByName()

MediaWiki\Export\WikiExporter::pagesByName ( $names)
Parameters
string[]$names

Definition at line 244 of file WikiExporter.php.

References MediaWiki\Export\WikiExporter\pageByName().

◆ pagesByRange()

MediaWiki\Export\WikiExporter::pagesByRange ( $start,
$end,
$orderRevs )

Dumps a series of page and revision records for those pages in the database falling within the page_id range given.

Parameters
int$startInclusive lower limit (this id is included)
int$endExclusive upper limit (this id is not included) If 0, no upper limit.
bool$orderRevsorder revisions within pages in ascending order

Definition at line 191 of file WikiExporter.php.

References MediaWiki\Export\WikiExporter\dumpFrom().

◆ revsByRange()

MediaWiki\Export\WikiExporter::revsByRange ( $start,
$end )

Dumps a series of page and revision records for those pages in the database with revisions falling within the rev_id range given.

Parameters
int$startInclusive lower limit (this id is included)
int$endExclusive upper limit (this id is not included) If 0, no upper limit.

Definition at line 213 of file WikiExporter.php.

References MediaWiki\Export\WikiExporter\dumpFrom().

◆ schemaVersion()

static MediaWiki\Export\WikiExporter::schemaVersion ( )
static

Returns the default export schema version, as defined by the XmlDumpSchemaVersion setting.

Returns
string

Definition at line 98 of file WikiExporter.php.

References MediaWiki\MediaWikiServices\getInstance(), and MediaWiki\MainConfigNames\XmlDumpSchemaVersion.

Referenced by MediaWiki\Api\ApiQuery\getAllowedParams().

◆ setOutputSink()

MediaWiki\Export\WikiExporter::setOutputSink ( & $sink)

Set the DumpOutput or DumpFilter object which will receive various row objects and XML output for filtering.

Filters can be chained or used as callbacks.

Parameters
DumpOutput | DumpFilter&$sink

Definition at line 160 of file WikiExporter.php.

References MediaWiki\Export\WikiExporter\$sink.

◆ setSchemaVersion()

MediaWiki\Export\WikiExporter::setSchemaVersion ( $schemaVersion)
Parameters
string$schemaVersionwhich schema version the generated XML should comply to. One of the values from self::$supportedSchemas, using the XML_DUMP_SCHEMA_VERSION_XX constants.

Definition at line 149 of file WikiExporter.php.

Member Data Documentation

◆ $author_list

string MediaWiki\Export\WikiExporter::$author_list = ""

◆ $db

IReadableDatabase MediaWiki\Export\WikiExporter::$db
protected

Definition at line 74 of file WikiExporter.php.

Referenced by MediaWiki\Export\WikiExporter\__construct().

◆ $dumpUploadFileContents

bool MediaWiki\Export\WikiExporter::$dumpUploadFileContents = false

Definition at line 48 of file WikiExporter.php.

◆ $dumpUploads

bool MediaWiki\Export\WikiExporter::$dumpUploads = false

Definition at line 45 of file WikiExporter.php.

◆ $history

array int MediaWiki\Export\WikiExporter::$history
protected

Definition at line 77 of file WikiExporter.php.

Referenced by MediaWiki\Export\WikiExporter\__construct().

◆ $limitNamespaces

array null MediaWiki\Export\WikiExporter::$limitNamespaces
protected

Definition at line 80 of file WikiExporter.php.

Referenced by MediaWiki\Export\WikiExporter\__construct().

◆ $list_authors

bool MediaWiki\Export\WikiExporter::$list_authors = false

Return distinct author list (when not returning full history)

Definition at line 42 of file WikiExporter.php.

◆ $sink

DumpOutput MediaWiki\Export\WikiExporter::$sink

Definition at line 68 of file WikiExporter.php.

Referenced by MediaWiki\Export\WikiExporter\setOutputSink().

◆ $text

int MediaWiki\Export\WikiExporter::$text

Definition at line 65 of file WikiExporter.php.

Referenced by MediaWiki\Export\WikiExporter\__construct().

◆ BATCH_SIZE

const MediaWiki\Export\WikiExporter::BATCH_SIZE = 10000
protected

Definition at line 62 of file WikiExporter.php.

Referenced by MediaWiki\Export\WikiExporter\dumpPages().

◆ CURRENT

const MediaWiki\Export\WikiExporter::CURRENT = 2

Definition at line 54 of file WikiExporter.php.

◆ FULL

const MediaWiki\Export\WikiExporter::FULL = 1

Definition at line 53 of file WikiExporter.php.

◆ LOGS

const MediaWiki\Export\WikiExporter::LOGS = 8

Definition at line 56 of file WikiExporter.php.

◆ RANGE

const MediaWiki\Export\WikiExporter::RANGE = 16

Definition at line 57 of file WikiExporter.php.

◆ STABLE

const MediaWiki\Export\WikiExporter::STABLE = 4

Definition at line 55 of file WikiExporter.php.

◆ STUB

const MediaWiki\Export\WikiExporter::STUB = XmlDumpWriter::WRITE_STUB

Definition at line 60 of file WikiExporter.php.

◆ TEXT

const MediaWiki\Export\WikiExporter::TEXT = XmlDumpWriter::WRITE_CONTENT

Definition at line 59 of file WikiExporter.php.


The documentation for this class was generated from the following file: