MediaWiki REL1_35
XmlDumpWriter Class Reference
Collaboration diagram for XmlDumpWriter:

Public Member Functions

 __construct ( $contentMode=self::WRITE_CONTENT, $schemaVersion=XML_DUMP_SCHEMA_VERSION_11)
 
 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
 

Private Member Functions

 caseSetting ()
 
 dbname ()
 
 generator ()
 
 getBlobStore ()
 
 getRevisionStore ()
 
 homelink ()
 
 invokeLenient ( $callback, $warning)
 Invokes the given callback, catching and logging any storage related exceptions.
 
 namespaces ()
 
 siteInfo ()
 
 sitename ()
 
 writeSlot (SlotRecord $slot, $contentMode)
 
 writeText (Content $content, $textAttributes, $indent)
 
 writeUpload ( $file, $dumpContents=false)
 

Private Attributes

int $contentMode
 Whether to output revision content or just stubs.
 
Title null $currentTitle = null
 Title of the currently processed page.
 
HookRunner $hookRunner
 
string $schemaVersion
 which schema version the generated XML should comply to.
 
const WRITE_STUB_DELETED = 2
 Only output subs for revision content, indicating that the content has been deleted/suppressed.
 

Detailed Description

Definition at line 39 of file XmlDumpWriter.php.

Constructor & Destructor Documentation

◆ __construct()

XmlDumpWriter::__construct (   $contentMode = self::WRITE_CONTENT,
  $schemaVersion = XML_DUMP_SCHEMA_VERSION_11 
)
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 90 of file XmlDumpWriter.php.

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

References $title.

◆ caseSetting()

XmlDumpWriter::caseSetting ( )
private
Returns
string

Definition at line 195 of file XmlDumpWriter.php.

References $wgCapitalLinks.

Referenced by siteInfo().

◆ closePage()

XmlDumpWriter::closePage ( )

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

Definition at line 279 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 230 of file XmlDumpWriter.php.

◆ dbname()

XmlDumpWriter::dbname ( )
private
Returns
string

Definition at line 173 of file XmlDumpWriter.php.

References $wgDBname.

Referenced by siteInfo().

◆ generator()

XmlDumpWriter::generator ( )
private
Returns
string

Definition at line 181 of file XmlDumpWriter.php.

References MW_VERSION.

Referenced by siteInfo().

◆ getBlobStore()

XmlDumpWriter::getBlobStore ( )
private
Returns
SqlBlobStore

Definition at line 299 of file XmlDumpWriter.php.

Referenced by writeSlot().

◆ getRevisionStore()

XmlDumpWriter::getRevisionStore ( )
private
Returns
RevisionStore

Definition at line 292 of file XmlDumpWriter.php.

Referenced by writeRevision().

◆ homelink()

XmlDumpWriter::homelink ( )
private
Returns
string

Definition at line 188 of file XmlDumpWriter.php.

Referenced by siteInfo().

◆ invokeLenient()

XmlDumpWriter::invokeLenient (   $callback,
  $warning 
)
private

Invokes the given callback, catching and logging any storage related exceptions.

Parameters
callable$callback
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 314 of file XmlDumpWriter.php.

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

◆ namespaces()

XmlDumpWriter::namespaces ( )
private
Returns
string

Definition at line 205 of file XmlDumpWriter.php.

References $title.

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

References invokeLenient(), and Title\isValidRedirectTarget().

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

References siteInfo().

◆ siteInfo()

XmlDumpWriter::siteInfo ( )
private
Returns
string

Definition at line 149 of file XmlDumpWriter.php.

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

Referenced by openStream().

◆ sitename()

XmlDumpWriter::sitename ( )
private
Returns
string

Definition at line 165 of file XmlDumpWriter.php.

References $wgSitename.

Referenced by siteInfo().

◆ writeContributor()

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

Definition at line 638 of file XmlDumpWriter.php.

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

Definition at line 583 of file XmlDumpWriter.php.

References $title, LogPage\DELETED_ACTION, LogPage\DELETED_COMMENT, LogPage\DELETED_USER, 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

Definition at line 341 of file XmlDumpWriter.php.

References $content, getRevisionStore(), invokeLenient(), 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 554 of file XmlDumpWriter.php.

References $content.

Referenced by writeSlot().

◆ writeTimestamp()

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

Definition at line 627 of file XmlDumpWriter.php.

References wfTimestamp().

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

◆ writeUpload()

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

Definition at line 677 of file XmlDumpWriter.php.

References $file, 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 656 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 79 of file XmlDumpWriter.php.

◆ $currentTitle

Title null XmlDumpWriter::$currentTitle = null
private

Title of the currently processed page.

Definition at line 74 of file XmlDumpWriter.php.

◆ $hookRunner

HookRunner XmlDumpWriter::$hookRunner
private

Definition at line 82 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 67 of file XmlDumpWriter.php.

◆ $supportedSchemas

string [] XmlDumpWriter::$supportedSchemas
static
Initial value:
= [
]
const XML_DUMP_SCHEMA_VERSION_11
Definition Defines.php:319
const XML_DUMP_SCHEMA_VERSION_10
Definition Defines.php:318

the schema versions supported for output @final

Definition at line 57 of file XmlDumpWriter.php.

◆ WRITE_CONTENT

const XmlDumpWriter::WRITE_CONTENT = 0

Output serialized revision content.

Definition at line 42 of file XmlDumpWriter.php.

◆ WRITE_STUB

const XmlDumpWriter::WRITE_STUB = 1

Only output subs for revision content.

Definition at line 45 of file XmlDumpWriter.php.

◆ WRITE_STUB_DELETED

const XmlDumpWriter::WRITE_STUB_DELETED = 2
private

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

Definition at line 51 of file XmlDumpWriter.php.


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