MediaWiki  1.34.0
WikiExporter Class Reference
Collaboration diagram for WikiExporter:

Public Member Functions

 __construct ( $db, $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. More...
 
 closeStream ()
 
 logsByRange ( $start, $end)
 
 openStream ()
 
 pageByName ( $name)
 
 pageByTitle ( $title)
 
 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. More...
 
 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. More...
 
 setOutputSink (&$sink)
 Set the DumpOutput or DumpFilter object which will receive various row objects and XML output for filtering. More...
 
 setSchemaVersion ( $schemaVersion)
 

Static Public Member Functions

static schemaVersion ()
 Returns the default export schema version, as defined by $wgXmlDumpSchemaVersion. More...
 

Public Attributes

string $author_list = ""
 
bool $dumpUploadFileContents = false
 
bool $dumpUploads = false
 
bool $list_authors = false
 Return distinct author list (when not returning full history) More...
 
DumpOutput $sink
 
int $text
 
const BATCH_SIZE = 50000
 
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. More...
 
 dumpFrom ( $cond='', $orderRevs=false)
 
 dumpLogs ( $cond)
 
 dumpPages ( $cond, $orderRevs)
 
 finishPageStreamOutput ( $lastRow)
 Final page stream output, after all batches are complete. More...
 
 getSlotRowBatch ( $results, &$carry=null)
 Returns all slot rows for a revision. More...
 
 outputLogStream ( $resultset)
 
 outputPageStreamBatch ( $results, $lastRow)
 Runs through a query result set dumping page, revision, and slot records. More...
 

Protected Attributes

IDatabase $db
 
array int $history
 
array null $limitNamespaces
 

Private Attributes

XmlDumpWriter $writer
 

Detailed Description

Definition at line 38 of file WikiExporter.php.

Constructor & Destructor Documentation

◆ __construct()

WikiExporter::__construct (   $db,
  $history = self::CURRENT,
  $text = self::TEXT,
  $limitNamespaces = null 
)
Parameters
IDatabase$db
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$limitNamespacesComma-separated list of namespace numbers to limit results

Definition at line 100 of file WikiExporter.php.

References $db, $history, $limitNamespaces, and $text.

Member Function Documentation

◆ allLogs()

WikiExporter::allLogs ( )

Definition at line 222 of file WikiExporter.php.

References dumpFrom().

◆ allPages()

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 149 of file WikiExporter.php.

References dumpFrom().

◆ closeStream()

WikiExporter::closeStream ( )

Definition at line 139 of file WikiExporter.php.

References $output.

◆ do_list_authors()

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 245 of file WikiExporter.php.

References $res, $revQuery, and Revision\getQueryInfo().

Referenced by dumpPages().

◆ dumpFrom()

WikiExporter::dumpFrom (   $cond = '',
  $orderRevs = false 
)
protected
Parameters
string$cond
bool$orderRevs
Exceptions
MWException
Exception

Definition at line 284 of file WikiExporter.php.

References dumpLogs(), and dumpPages().

Referenced by allLogs(), allPages(), logsByRange(), pageByTitle(), pagesByRange(), and revsByRange().

◆ dumpLogs()

WikiExporter::dumpLogs (   $cond)
protected
Parameters
string$cond
Exceptions
Exception

Definition at line 296 of file WikiExporter.php.

References BATCH_SIZE, LogEventsList\getExcludeClause(), CommentStore\getStore(), ActorMigration\newMigration(), and outputLogStream().

Referenced by dumpFrom().

◆ dumpPages()

WikiExporter::dumpPages (   $cond,
  $orderRevs 
)
protected
Parameters
string$cond
bool$orderRevs
Exceptions
MWException
Exception

Definition at line 353 of file WikiExporter.php.

References $revQuery, BATCH_SIZE, do_list_authors(), finishPageStreamOutput(), outputPageStreamBatch(), and Hooks\run().

Referenced by dumpFrom().

◆ finishPageStreamOutput()

WikiExporter::finishPageStreamOutput (   $lastRow)
protected

Final page stream output, after all batches are complete.

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

Definition at line 577 of file WikiExporter.php.

References $author_list, and $output.

Referenced by dumpPages().

◆ getSlotRowBatch()

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 | object&$carryA row carried over from the last call to getSlotRowBatch()
Returns
object[]

Definition at line 550 of file WikiExporter.php.

Referenced by outputPageStreamBatch().

◆ logsByRange()

WikiExporter::logsByRange (   $start,
  $end 
)
Parameters
int$start
int$end

Definition at line 230 of file WikiExporter.php.

References dumpFrom().

◆ openStream()

WikiExporter::openStream ( )

Definition at line 134 of file WikiExporter.php.

References $output.

◆ outputLogStream()

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

Definition at line 591 of file WikiExporter.php.

References $output.

Referenced by dumpLogs().

◆ outputPageStreamBatch()

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
object$lastRowthe last row output from the previous call (or null if none)
Returns
object the last row processed

Definition at line 496 of file WikiExporter.php.

References $output, and getSlotRowBatch().

Referenced by dumpPages().

◆ pageByName()

WikiExporter::pageByName (   $name)
Parameters
string$name
Exceptions
MWException

Definition at line 204 of file WikiExporter.php.

References $title, Title\newFromText(), and pageByTitle().

Referenced by pagesByName().

◆ pageByTitle()

WikiExporter::pageByTitle (   $title)
Parameters
Title$title

Definition at line 194 of file WikiExporter.php.

References $title, and dumpFrom().

Referenced by pageByName().

◆ pagesByName()

WikiExporter::pagesByName (   $names)
Parameters
array$names

Definition at line 216 of file WikiExporter.php.

References pageByName().

◆ pagesByRange()

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 161 of file WikiExporter.php.

References dumpFrom().

◆ revsByRange()

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 183 of file WikiExporter.php.

References dumpFrom().

◆ schemaVersion()

static WikiExporter::schemaVersion ( )
static

Returns the default export schema version, as defined by $wgXmlDumpSchemaVersion.

Returns
string

Definition at line 84 of file WikiExporter.php.

References $wgXmlDumpSchemaVersion.

Referenced by BackupDumper\__construct(), ApiQuery\getAllowedParams(), and BackupDumper\processOptions().

◆ setOutputSink()

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 130 of file WikiExporter.php.

References $sink.

◆ setSchemaVersion()

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 119 of file WikiExporter.php.

Member Data Documentation

◆ $author_list

string WikiExporter::$author_list = ""

Definition at line 49 of file WikiExporter.php.

Referenced by finishPageStreamOutput().

◆ $db

IDatabase WikiExporter::$db
protected

Definition at line 72 of file WikiExporter.php.

Referenced by __construct().

◆ $dumpUploadFileContents

bool WikiExporter::$dumpUploadFileContents = false

Definition at line 46 of file WikiExporter.php.

◆ $dumpUploads

bool WikiExporter::$dumpUploads = false

Definition at line 43 of file WikiExporter.php.

◆ $history

array int WikiExporter::$history
protected

Definition at line 75 of file WikiExporter.php.

Referenced by __construct().

◆ $limitNamespaces

array null WikiExporter::$limitNamespaces
protected

Definition at line 78 of file WikiExporter.php.

Referenced by __construct().

◆ $list_authors

bool WikiExporter::$list_authors = false

Return distinct author list (when not returning full history)

Definition at line 40 of file WikiExporter.php.

◆ $sink

DumpOutput WikiExporter::$sink

Definition at line 66 of file WikiExporter.php.

Referenced by setOutputSink().

◆ $text

int WikiExporter::$text

Definition at line 63 of file WikiExporter.php.

Referenced by __construct().

◆ $writer

XmlDumpWriter WikiExporter::$writer
private

Definition at line 69 of file WikiExporter.php.

◆ BATCH_SIZE

const WikiExporter::BATCH_SIZE = 50000

Definition at line 60 of file WikiExporter.php.

Referenced by dumpLogs(), and dumpPages().

◆ CURRENT

const WikiExporter::CURRENT = 2

◆ FULL

const WikiExporter::FULL = 1

◆ LOGS

const WikiExporter::LOGS = 8

Definition at line 54 of file WikiExporter.php.

Referenced by BackupDumper\dump(), and DumpBackup\execute().

◆ RANGE

const WikiExporter::RANGE = 16

Definition at line 55 of file WikiExporter.php.

Referenced by DumpBackup\execute().

◆ STABLE

const WikiExporter::STABLE = 4

Definition at line 53 of file WikiExporter.php.

Referenced by DumpBackup\execute().

◆ STUB

const WikiExporter::STUB = XmlDumpWriter::WRITE_STUB

Definition at line 58 of file WikiExporter.php.

Referenced by DumpBackup\execute().

◆ TEXT

const WikiExporter::TEXT = XmlDumpWriter::WRITE_CONTENT

Definition at line 57 of file WikiExporter.php.

Referenced by DumpBackup\execute().


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