MediaWiki master
MediaWiki\Export\XmlDumpWriter Class Reference

Public Member Functions

 __construct ( $contentMode=self::WRITE_CONTENT, $schemaVersion=XML_DUMP_SCHEMA_VERSION_11, ?HookContainer $hookContainer=null, ?CommentStore $commentStore=null)
 
 closePage ()
 Closes a "<page>" section on the output stream.
 
 closeStream ()
 Closes the output stream with the closing root element.
 
 openPage ( $row)
 Opens a "<page>" section on the output stream, with data from the given database row.
 
 openStream ()
 Opens the XML output stream's root "<mediawiki>" element.
 
 writeContributor ( $id, $text, $indent=" ")
 
 writeLogItem ( $row)
 Dumps a "<logitem>" section on the output stream, with data filled in from the given database row.
 
 writeRevision ( $row, $slotRows=null)
 Dumps a "<revision>" section on the output stream, with data filled in from the given database row.
 
 writeTimestamp ( $timestamp, $indent=" ")
 
 writeUploads ( $row, $dumpContents=false)
 Warning! This data is potentially inconsistent.
 

Static Public Member Functions

static canonicalTitle (Title $title)
 Return prefixed text form of title, but using the content language's canonical namespace.
 

Public Attributes

const WRITE_CONTENT = 0
 Output serialized revision content.
 
const WRITE_STUB = 1
 Only output subs for revision content.
 

Static Public Attributes

static string[] $supportedSchemas
 the schema versions supported for output @final
 

Detailed Description

Definition at line 46 of file XmlDumpWriter.php.

Constructor & Destructor Documentation

◆ __construct()

MediaWiki\Export\XmlDumpWriter::__construct ( $contentMode = self::WRITE_CONTENT,
$schemaVersion = XML_DUMP_SCHEMA_VERSION_11,
?HookContainer $hookContainer = null,
?CommentStore $commentStore = null )
Parameters
int$contentModeWRITE_CONTENT or WRITE_STUB.
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.
HookContainer | null$hookContainer
CommentStore | null$commentStore

Definition at line 102 of file XmlDumpWriter.php.

References MediaWiki\MediaWikiServices\getInstance().

Member Function Documentation

◆ canonicalTitle()

static MediaWiki\Export\XmlDumpWriter::canonicalTitle ( Title $title)
static

Return prefixed text form of title, but using the content language's canonical namespace.

This skips any special-casing such as gendered user namespaces – which while useful, are not yet listed in the XML "<siteinfo>" data so are unsafe in export.

Parameters
Title$title
Returns
string
Since
1.18

Definition at line 762 of file XmlDumpWriter.php.

References MediaWiki\MediaWikiServices\getInstance(), MediaWiki\Title\Title\getNamespace(), MediaWiki\Title\Title\getPrefixedText(), MediaWiki\Title\Title\getText(), and MediaWiki\Linker\LinkTarget\isExternal().

Referenced by MediaWiki\Export\XmlDumpWriter\openPage().

◆ closePage()

MediaWiki\Export\XmlDumpWriter::closePage ( )

Closes a "<page>" section on the output stream.

Access: internal
Returns
string

Definition at line 295 of file XmlDumpWriter.php.

References MediaWiki\MediaWikiServices\getInstance().

◆ closeStream()

MediaWiki\Export\XmlDumpWriter::closeStream ( )

Closes the output stream with the closing root element.

Call when finished dumping things.

Returns
string

Definition at line 249 of file XmlDumpWriter.php.

◆ openPage()

MediaWiki\Export\XmlDumpWriter::openPage ( $row)

Opens a "<page>" section on the output stream, with data from the given database row.

Parameters
\\stdClass$row
Returns
string

Definition at line 260 of file XmlDumpWriter.php.

References MediaWiki\Export\XmlDumpWriter\canonicalTitle(), MediaWiki\Html\Html\element(), MediaWiki\MediaWikiServices\getInstance(), and MediaWiki\Title\Title\isValidRedirectTarget().

◆ openStream()

MediaWiki\Export\XmlDumpWriter::openStream ( )

Opens the XML output stream's root "<mediawiki>" element.

This does not include an xml directive, so is safe to include as a subelement in a larger XML stream. Namespace and XML Schema references are included.

Output will be encoded in UTF-8.

Returns
string

Definition at line 139 of file XmlDumpWriter.php.

References MediaWiki\Html\Html\element(), and MediaWiki\MediaWikiServices\getInstance().

◆ writeContributor()

MediaWiki\Export\XmlDumpWriter::writeContributor ( $id,
$text,
$indent = "      " )
Parameters
int$id
string$text
string$indentDefault to six spaces
Returns
string

Definition at line 666 of file XmlDumpWriter.php.

References MediaWiki\Html\Html\element().

Referenced by MediaWiki\Export\XmlDumpWriter\writeLogItem(), and MediaWiki\Export\XmlDumpWriter\writeRevision().

◆ writeLogItem()

MediaWiki\Export\XmlDumpWriter::writeLogItem ( $row)

Dumps a "<logitem>" section on the output stream, with data filled in from the given database row.

Parameters
\\stdClass$row
Returns
string

Definition at line 611 of file XmlDumpWriter.php.

References MediaWiki\Html\Html\element(), MediaWiki\Deferred\LinksUpdate\CategoryLinksTable\makeTitle(), MediaWiki\Export\XmlDumpWriter\writeContributor(), and MediaWiki\Export\XmlDumpWriter\writeTimestamp().

◆ writeRevision()

MediaWiki\Export\XmlDumpWriter::writeRevision ( $row,
$slotRows = null )

Dumps a "<revision>" section on the output stream, with data filled in from the given database row.

Parameters
\\stdClass$row
null | \\stdClass[]$slotRows
Returns
string
Exceptions
RevisionAccessException

Definition at line 350 of file XmlDumpWriter.php.

References MediaWiki\Html\Html\element(), MediaWiki\Export\XmlDumpWriter\writeContributor(), and MediaWiki\Export\XmlDumpWriter\writeTimestamp().

◆ writeTimestamp()

MediaWiki\Export\XmlDumpWriter::writeTimestamp ( $timestamp,
$indent = "      " )
Parameters
string$timestamp
string$indentDefault to six spaces
Returns
string

Definition at line 655 of file XmlDumpWriter.php.

References MediaWiki\Html\Html\element(), and wfTimestamp().

Referenced by MediaWiki\Export\XmlDumpWriter\writeLogItem(), and MediaWiki\Export\XmlDumpWriter\writeRevision().

◆ writeUploads()

MediaWiki\Export\XmlDumpWriter::writeUploads ( $row,
$dumpContents = false )

Warning! This data is potentially inconsistent.

:(

Parameters
\\stdClass$row
bool$dumpContents
Returns
string

Definition at line 684 of file XmlDumpWriter.php.

References MediaWiki\MediaWikiServices\getInstance(), and NS_FILE.

Member Data Documentation

◆ $supportedSchemas

string [] MediaWiki\Export\XmlDumpWriter::$supportedSchemas
static
Initial value:
= [
]
const XML_DUMP_SCHEMA_VERSION_11
Definition Defines.php:349
const XML_DUMP_SCHEMA_VERSION_10
Definition Defines.php:348

the schema versions supported for output @final

Definition at line 64 of file XmlDumpWriter.php.

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

◆ WRITE_CONTENT

const MediaWiki\Export\XmlDumpWriter::WRITE_CONTENT = 0

Output serialized revision content.

Definition at line 49 of file XmlDumpWriter.php.

◆ WRITE_STUB

const MediaWiki\Export\XmlDumpWriter::WRITE_STUB = 1

Only output subs for revision content.

Definition at line 52 of file XmlDumpWriter.php.


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