MediaWiki  1.34.0
XmlDumpWriter Class Reference
Collaboration diagram for XmlDumpWriter:

Public Member Functions

 __construct ( $contentMode=self::WRITE_CONTENT, $schemaVersion=XML_DUMP_SCHEMA_VERSION_11)
 XmlDumpWriter constructor. More...
 
 caseSetting ()
 
 closePage ()
 Closes a "<page>" section on the output stream. More...
 
 closeStream ()
 Closes the output stream with the closing root element. More...
 
 dbname ()
 
 generator ()
 
 homelink ()
 
 namespaces ()
 
 openPage ( $row)
 Opens a "<page>" section on the output stream, with data from the given database row. More...
 
 openStream ()
 Opens the XML output stream's root "<mediawiki>" element. More...
 
 siteInfo ()
 
 sitename ()
 
 writeContributor ( $id, $text, $indent=" ")
 
 writeLogItem ( $row)
 Dumps a "<logitem>" section on the output stream, with data filled in from the given database row. More...
 
 writeRevision ( $row, $slotRows=null)
 Dumps a "<revision>" section on the output stream, with data filled in from the given database row. More...
 
 writeTimestamp ( $timestamp, $indent=" ")
 
 writeUpload ( $file, $dumpContents=false)
 
 writeUploads ( $row, $dumpContents=false)
 Warning! This data is potentially inconsistent. More...
 

Static Public Member Functions

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

Public Attributes

const WRITE_CONTENT = 0
 Output serialized revision content. More...
 
const WRITE_STUB = 1
 Only output subs for revision content. More...
 
const WRITE_STUB_DELETED = 2
 Only output subs for revision content, indicating that the content has been deleted/suppressed. More...
 

Static Public Attributes

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

Private Member Functions

 getBlobStore ()
 
 getRevisionStore ()
 
 invokeLenient ( $obj, $method, $args=[], $warning)
 Invokes the given method on the given object, catching and logging any storage related exceptions. More...
 
 writeSlot (SlotRecord $slot, $contentMode)
 
 writeText (Content $content, $textAttributes, $indent)
 

Private Attributes

int $contentMode
 Whether to output revision content or just stubs. More...
 
Title null $currentTitle = null
 Title of the currently processed page. More...
 
string $schemaVersion
 which schema version the generated XML should comply to. More...
 

Detailed Description

Definition at line 36 of file XmlDumpWriter.php.

Constructor & Destructor Documentation

◆ __construct()

XmlDumpWriter::__construct (   $contentMode = self::WRITE_CONTENT,
  $schemaVersion = XML_DUMP_SCHEMA_VERSION_11 
)

XmlDumpWriter constructor.

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.

Definition at line 86 of file XmlDumpWriter.php.

References $contentMode, and $schemaVersion.

Member Function Documentation

◆ canonicalTitle()

static 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 709 of file XmlDumpWriter.php.

References $title.

Referenced by openPage().

◆ caseSetting()

XmlDumpWriter::caseSetting ( )
Returns
string

Definition at line 191 of file XmlDumpWriter.php.

References $wgCapitalLinks, and Xml\element().

Referenced by siteInfo().

◆ closePage()

XmlDumpWriter::closePage ( )

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

Access:\n private
Returns
string

Definition at line 270 of file XmlDumpWriter.php.

◆ closeStream()

XmlDumpWriter::closeStream ( )

Closes the output stream with the closing root element.

Call when finished dumping things.

Returns
string

Definition at line 226 of file XmlDumpWriter.php.

◆ dbname()

XmlDumpWriter::dbname ( )
Returns
string

Definition at line 168 of file XmlDumpWriter.php.

References $wgDBname, and Xml\element().

Referenced by siteInfo().

◆ generator()

XmlDumpWriter::generator ( )
Returns
string

Definition at line 176 of file XmlDumpWriter.php.

References $wgVersion, and Xml\element().

Referenced by siteInfo().

◆ getBlobStore()

XmlDumpWriter::getBlobStore ( )
private
Returns
SqlBlobStore

Definition at line 290 of file XmlDumpWriter.php.

Referenced by writeSlot().

◆ getRevisionStore()

XmlDumpWriter::getRevisionStore ( )
private
Returns
RevisionStore

Definition at line 283 of file XmlDumpWriter.php.

Referenced by writeRevision().

◆ homelink()

XmlDumpWriter::homelink ( )
Returns
string

Definition at line 184 of file XmlDumpWriter.php.

References Xml\element(), and Title\newMainPage().

Referenced by siteInfo().

◆ invokeLenient()

XmlDumpWriter::invokeLenient (   $obj,
  $method,
  $args = [],
  $warning 
)
private

Invokes the given method on the given object, catching and logging any storage related exceptions.

Parameters
object$obj
string$method
array$args
string$warningThe warning to output in case of a storage related exception.
Returns
mixed Returns the method's return value, or null in case of a storage related exception.
Exceptions
Exception

Definition at line 307 of file XmlDumpWriter.php.

References $args, and MWDebug\warning().

Referenced by writeRevision(), and writeSlot().

◆ namespaces()

XmlDumpWriter::namespaces ( )
Returns
string

Definition at line 201 of file XmlDumpWriter.php.

References $title, and Xml\element().

Referenced by siteInfo().

◆ openPage()

XmlDumpWriter::openPage (   $row)

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

Parameters
object$row
Returns
string

Definition at line 237 of file XmlDumpWriter.php.

References canonicalTitle(), Xml\element(), Xml\elementClean(), WikiPage\factory(), Title\isValidRedirectTarget(), Title\newFromRow(), and Hooks\run().

◆ openStream()

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 117 of file XmlDumpWriter.php.

References $schemaVersion, Xml\element(), and siteInfo().

◆ siteInfo()

XmlDumpWriter::siteInfo ( )
Returns
string

Definition at line 144 of file XmlDumpWriter.php.

References caseSetting(), dbname(), generator(), homelink(), namespaces(), and sitename().

Referenced by openStream().

◆ sitename()

XmlDumpWriter::sitename ( )
Returns
string

Definition at line 160 of file XmlDumpWriter.php.

References $wgSitename, and Xml\element().

Referenced by siteInfo().

◆ writeContributor()

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

Definition at line 620 of file XmlDumpWriter.php.

References Xml\element(), Xml\elementClean(), and IP\isValid().

Referenced by writeLogItem(), writeRevision(), and writeUpload().

◆ writeLogItem()

XmlDumpWriter::writeLogItem (   $row)

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

Parameters
object$row
Returns
string
Access:\n private

Definition at line 565 of file XmlDumpWriter.php.

References $title, LogPage\DELETED_ACTION, LogPage\DELETED_COMMENT, LogPage\DELETED_USER, Xml\element(), Xml\elementClean(), CommentStore\getStore(), Title\makeTitle(), writeContributor(), and writeTimestamp().

◆ writeRevision()

XmlDumpWriter::writeRevision (   $row,
  $slotRows = null 
)

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

Parameters
object$row
null | object[]$slotRows
Returns
string
Exceptions
FatalError
MWException
Access:\n private

Definition at line 335 of file XmlDumpWriter.php.

References $content, $contentMode, Xml\element(), Xml\elementClean(), getRevisionStore(), invokeLenient(), Hooks\run(), WRITE_STUB_DELETED, writeContributor(), writeSlot(), and writeTimestamp().

◆ writeSlot()

◆ writeText()

XmlDumpWriter::writeText ( Content  $content,
  $textAttributes,
  $indent 
)
private
Parameters
Content$content
string[]$textAttributes
string$indent
Returns
string

Definition at line 536 of file XmlDumpWriter.php.

References $content, and Xml\elementClean().

Referenced by writeSlot().

◆ writeTimestamp()

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

Definition at line 609 of file XmlDumpWriter.php.

References Xml\element(), and wfTimestamp().

Referenced by writeLogItem(), writeRevision(), and writeUpload().

◆ writeUpload()

XmlDumpWriter::writeUpload (   $file,
  $dumpContents = false 
)
Parameters
File$file
bool$dumpContents
Returns
string

Definition at line 659 of file XmlDumpWriter.php.

References $file, File\DELETED_COMMENT, Xml\element(), Xml\elementClean(), writeContributor(), and writeTimestamp().

Referenced by writeUploads().

◆ writeUploads()

XmlDumpWriter::writeUploads (   $row,
  $dumpContents = false 
)

Warning! This data is potentially inconsistent.

:(

Parameters
object$row
bool$dumpContents
Returns
string

Definition at line 638 of file XmlDumpWriter.php.

References NS_FILE, and writeUpload().

Member Data Documentation

◆ $contentMode

int XmlDumpWriter::$contentMode
private

Whether to output revision content or just stubs.

WRITE_CONTENT or WRITE_STUB.

Definition at line 76 of file XmlDumpWriter.php.

Referenced by __construct(), writeRevision(), and writeSlot().

◆ $currentTitle

Title null XmlDumpWriter::$currentTitle = null
private

Title of the currently processed page.

Definition at line 71 of file XmlDumpWriter.php.

◆ $schemaVersion

string XmlDumpWriter::$schemaVersion
private

which schema version the generated XML should comply to.

One of the values from self::$supportedSchemas, using the SCHEMA_VERSION_XX constants.

Definition at line 64 of file XmlDumpWriter.php.

Referenced by __construct(), and openStream().

◆ $supportedSchemas

string [] XmlDumpWriter::$supportedSchemas
static
Initial value:

the schema versions supported for output @final

Definition at line 54 of file XmlDumpWriter.php.

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

◆ WRITE_CONTENT

const XmlDumpWriter::WRITE_CONTENT = 0

Output serialized revision content.

Definition at line 39 of file XmlDumpWriter.php.

Referenced by TextPassDumper\dump().

◆ WRITE_STUB

const XmlDumpWriter::WRITE_STUB = 1

Only output subs for revision content.

Definition at line 42 of file XmlDumpWriter.php.

◆ WRITE_STUB_DELETED

const XmlDumpWriter::WRITE_STUB_DELETED = 2

Only output subs for revision content, indicating that the content has been deleted/suppressed.

For internal use only.

Definition at line 48 of file XmlDumpWriter.php.

Referenced by writeRevision().


The documentation for this class was generated from the following file:
XML_DUMP_SCHEMA_VERSION_11
const XML_DUMP_SCHEMA_VERSION_11
Definition: Defines.php:309
XML_DUMP_SCHEMA_VERSION_10
const XML_DUMP_SCHEMA_VERSION_10
Definition: Defines.php:308