* make additional queries to pull source data while the
* main query is still running.
*
- * @param $db Database
+ * @param $db DatabaseBase
* @param $history Mixed: one of WikiExporter::FULL, WikiExporter::CURRENT,
* WikiExporter::RANGE or WikiExporter::STABLE,
* or an associative array:
function openPage( $row ) {
$out = " <page>\n";
$title = Title::makeTitle( $row->page_namespace, $row->page_title );
- $out .= ' ' . Xml::elementClean( 'title', array(), $title->getPrefixedText() ) . "\n";
+ $out .= ' ' . Xml::elementClean( 'title', array(), self::canonicalTitle( $title ) ) . "\n";
$out .= ' ' . Xml::element( 'ns', array(), strval( $row->page_namespace) ) . "\n";
$out .= ' ' . Xml::element( 'id', array(), strval( $row->page_id ) ) . "\n";
if ( $row->page_is_redirect ) {
$page = WikiPage::factory( $title );
$redirect = $page->getRedirectTarget();
if ( $redirect instanceOf Title && $redirect->isValidRedirectTarget() ) {
- $out .= ' ' . Xml::element( 'redirect', array( 'title' => $redirect->getPrefixedText() ) ) . "\n";
+ $out .= ' ' . Xml::element( 'redirect', array( 'title' => self::canonicalTitle( $redirect ) ) ) . "\n";
}
}
+
+ if ( $row->rev_sha1 ) {
+ $out .= " " . Xml::element('sha1', null, strval( $row->rev_sha1 ) ) . "\n";
+ } else {
+ $out .= " <sha1/>\n";
+ }
+
if ( $row->page_restrictions != '' ) {
$out .= ' ' . Xml::element( 'restrictions', array(),
strval( $row->page_restrictions ) ) . "\n";
* Closes a <page> section on the output stream.
*
* @access private
+ * @return string
*/
function closePage() {
return " </page>\n";
// Raw text from the database may have invalid chars
$text = strval( Revision::getRevisionText( $row ) );
$out .= " " . Xml::elementClean( 'text',
- array( 'xml:space' => 'preserve', 'bytes' => $row->rev_len ),
+ array( 'xml:space' => 'preserve', 'bytes' => intval( $row->rev_len ) ),
strval( $text ) ) . "\n";
} else {
// Stub output
$out .= " " . Xml::element( 'text',
- array( 'id' => $row->rev_text_id, 'bytes' => $row->rev_len ),
+ array( 'id' => $row->rev_text_id, 'bytes' => intval( $row->rev_len ) ),
"" ) . "\n";
}
$out .= " " . Xml::element( 'text', array( 'deleted' => 'deleted' ) ) . "\n";
} else {
$title = Title::makeTitle( $row->log_namespace, $row->log_title );
- $out .= " " . Xml::elementClean( 'logtitle', null, $title->getPrefixedText() ) . "\n";
+ $out .= " " . Xml::elementClean( 'logtitle', null, self::canonicalTitle( $title ) ) . "\n";
$out .= " " . Xml::elementClean( 'params',
array( 'xml:space' => 'preserve' ),
strval( $row->log_params ) ) . "\n";
/**
* Warning! This data is potentially inconsistent. :(
+ * @return string
*/
function writeUploads( $row, $dumpContents = false ) {
if ( $row->page_namespace == NS_IMAGE ) {
" </upload>\n";
}
+ /**
+ * 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.
+ *
+ * @param Title $title
+ * @return string
+ * @since 1.18
+ */
+ public static function canonicalTitle( Title $title ) {
+ if ( $title->getInterwiki() ) {
+ return $title->getPrefixedText();
+ }
+
+ global $wgContLang;
+ $prefix = str_replace( '_', ' ', $wgContLang->getNsText( $title->getNamespace() ) );
+
+ if ( $prefix !== '' ) {
+ $prefix .= ':';
+ }
+
+ return $prefix . $title->getText();
+ }
}
/**
* Returns the name of the file or files which are
* being written to, if there are any.
+ * @return null
*/
function getFilenames() {
return NULL;
* @ingroup Dump
*/
class Dump7ZipOutput extends DumpPipeOutput {
- protected $filename;
-
function __construct( $file ) {
$command = $this->setup7zCommand( $file );
parent::__construct( $command );
return( $command );
}
- function closeRenameAndReopen( $newname ) {
- $this->closeAndRename( $newname, true );
- }
-
function closeAndRename( $newname, $open = false ) {
$newname = $this->checkRenameArgCount( $newname );
if ( $newname ) {
proc_close( $this->procOpenResource );
$this->renameOrException( $newname );
if ( $open ) {
- $command = $this->setup7zCommand( $file );
+ $command = $this->setup7zCommand( $this->filename );
$this->startCommand( $command );
}
}