X-Git-Url: https://git.cyclocoop.org/?a=blobdiff_plain;f=includes%2FExport.php;h=bc14dcff1f10507f612a61f223c82c946ea4bcca;hb=380a6661a14e96709f6b03f1d350d850ac22493e;hp=7bbc66773308cd878e0e2d0462f47317bd4f4fa2;hpb=ab86423a715af5aef15de8d39f8dd121cf0f2af8;p=lhc%2Fweb%2Fwiklou.git diff --git a/includes/Export.php b/includes/Export.php index 7bbc667733..bc14dcff1f 100644 --- a/includes/Export.php +++ b/includes/Export.php @@ -31,6 +31,9 @@ define( 'MW_EXPORT_CURRENT', 1 ); define( 'MW_EXPORT_BUFFER', 0 ); define( 'MW_EXPORT_STREAM', 1 ); +define( 'MW_EXPORT_TEXT', 0 ); +define( 'MW_EXPORT_STUB', 1 ); + /** * @package MediaWiki @@ -49,12 +52,13 @@ class WikiExporter { * @param int $buffer one of MW_EXPORT_BUFFER or MW_EXPORT_STREAM */ function WikiExporter( &$db, $history = MW_EXPORT_CURRENT, - $buffer = MW_EXPORT_BUFFER ) { + $buffer = MW_EXPORT_BUFFER, $text = MW_EXPORT_TEXT ) { $this->db =& $db; $this->history = $history; $this->buffer = $buffer; $this->writer = new XmlDumpWriter(); $this->sink = new DumpOutput(); + $this->text = $text; } /** @@ -158,13 +162,21 @@ class WikiExporter { $pageindex = ''; $revindex = ''; } - $result = $this->db->query( - "SELECT * FROM - $page $pageindex, - $revision $revindex, - $text - WHERE $where $join AND rev_text_id=old_id - ORDER BY page_id", $fname ); + if( $this->text == MW_EXPORT_STUB ) { + $sql = "SELECT * FROM + $page $pageindex, + $revision $revindex + WHERE $where $join + ORDER BY page_id"; + } else { + $sql = "SELECT * FROM + $page $pageindex, + $revision $revindex, + $text + WHERE $where $join AND rev_text_id=old_id + ORDER BY page_id"; + } + $result = $this->db->query( $sql, $fname ); $wrapper = $this->db->resultObject( $result ); $this->outputStream( $wrapper ); @@ -345,7 +357,7 @@ class XmlDumpWriter { $out = " \n"; $out .= " " . wfElement( 'id', null, strval( $row->rev_id ) ) . "\n"; - $ts = wfTimestamp2ISO8601( strval( $row->rev_timestamp ) ); + $ts = wfTimestamp( TS_ISO_8601, $row->rev_timestamp ); $out .= " " . wfElement( 'timestamp', null, $ts ) . "\n"; $out .= " \n"; @@ -363,11 +375,19 @@ class XmlDumpWriter { if( $row->rev_comment != '' ) { $out .= " " . wfElementClean( 'comment', null, strval( $row->rev_comment ) ) . "\n"; } - - $text = strval( Revision::getRevisionText( $row ) ); - $out .= " " . wfElementClean( 'text', - array( 'xml:space' => 'preserve' ), - strval( $text ) ) . "\n"; + + if( isset( $row->old_text ) ) { + // Raw text from the database may have invalid chars + $text = strval( Revision::getRevisionText( $row ) ); + $out .= " " . wfElementClean( 'text', + array( 'xml:space' => 'preserve' ), + strval( $text ) ) . "\n"; + } else { + // Stub output + $out .= " " . wfElement( 'text', + array( 'id' => $row->rev_text_id ), + "" ) . "\n"; + } $out .= " \n"; @@ -651,13 +671,6 @@ class DumpMultiWriter { } } - - -function wfTimestamp2ISO8601( $ts ) { - #2003-08-05T18:30:02Z - return preg_replace( '/^(....)(..)(..)(..)(..)(..)$/', '$1-$2-$3T$4:$5:$6Z', wfTimestamp( TS_MW, $ts ) ); -} - function xmlsafe( $string ) { $fname = 'xmlsafe'; wfProfileIn( $fname );