$out .= " " . Xml::elementClean( 'comment', array(), strval( $row->rev_comment ) ) . "\n";
}
- if ( isset( $row->rev_content_model ) && !is_null( $row->rev_content_model ) ) {
- $name = ContentHandler::getContentModelName( $row->rev_content_model );
- $out .= " " . Xml::element('model', array( 'name' => $name ), strval( $row->rev_content_model ) ) . "\n";
- }
-
- if ( isset( $row->rev_content_format ) && !is_null( $row->rev_content_format ) ) {
- $mime = ContentHandler::getContentFormatMimeType( $row->rev_content_format );
- $out .= " " . Xml::element('format', array( 'mime' => $mime ), strval( $row->rev_content_format ) ) . "\n";
- }
-
- if ( $row->rev_sha1 && !( $row->rev_deleted & Revision::DELETED_TEXT ) ) {
- $out .= " " . Xml::element('sha1', null, strval( $row->rev_sha1 ) ) . "\n";
- } else {
- $out .= " <sha1/>\n";
- }
-
$text = '';
if ( $row->rev_deleted & Revision::DELETED_TEXT ) {
$out .= " " . Xml::element( 'text', array( 'deleted' => 'deleted' ) ) . "\n";
"" ) . "\n";
}
+ if ( $row->rev_sha1 && !( $row->rev_deleted & Revision::DELETED_TEXT ) ) {
+ $out .= " " . Xml::element('sha1', null, strval( $row->rev_sha1 ) ) . "\n";
+ } else {
+ $out .= " <sha1/>\n";
+ }
+
+ if ( isset( $row->rev_content_model ) && !is_null( $row->rev_content_model ) ) {
+ $content_model = intval( $row->rev_content_model );
+ } else {
+ // probably using $wgContentHandlerUseDB = false;
+ // @todo: test!
+ $title = Title::makeTitle( $row->page_namespace, $row->page_title );
+ $content_model = ContentHandler::getDefaultModelFor( $title );
+ }
+
+ $name = ContentHandler::getContentModelName( $content_model );
+ $out .= " " . Xml::element('model', array( 'name' => $name ), strval( $content_model ) ) . "\n";
+
+ if ( isset( $row->rev_content_format ) && !is_null( $row->rev_content_format ) ) {
+ $content_format = intval( $row->rev_content_format );
+ } else {
+ // probably using $wgContentHandlerUseDB = false;
+ // @todo: test!
+ $content_handler = ContentHandler::getForModelID( $content_model );
+ $content_format = $content_handler->getDefaultFormat();
+ }
+
+ $mime = ContentHandler::getContentFormatMimeType( $content_format );
+ $out .= " " . Xml::element('format', array( 'mime' => $mime ), strval( $content_format ) ) . "\n";
+
wfRunHooks( 'XmlDumpWriterWriteRevision', array( &$this, &$out, $row, $text ) );
$out .= " </revision>\n";
* @param $text_sha1 string: the base36 SHA-1 of the revision's text
* @param $text string|false: (optional) The revision's string, or false to check for a
* revision stub
+ * @param $model int: the expected content model id (default: CONTENT_MODEL_WIKITEXT)
+ * @param $format int: the expected format model id (default: CONTENT_FORMAT_WIKITEXT)
*/
- protected function assertRevision( $id, $summary, $text_id, $text_bytes, $text_sha1, $text = false ) {
+ protected function assertRevision( $id, $summary, $text_id, $text_bytes, $text_sha1, $text = false,
+ $model = CONTENT_MODEL_WIKITEXT, $format = CONTENT_FORMAT_WIKITEXT ) {
$this->assertNodeStart( "revision" );
$this->skipWhitespace();
$this->assertTextNode( "comment", $summary );
$this->skipWhitespace();
- if ( $this->xml->name == "model" ) { // model tag is optional
- $this->assertTextNode( "model", CONTENT_MODEL_WIKITEXT ); //@todo: make this a test parameter
- $this->skipWhitespace();
+ if ( $this->xml->name == "text" ) {
+ // note: <text> tag may occur here or at the very end.
+ $text_found = true;
+ $this->assertText( $id, $text_id, $text_bytes, $text );
+ } else {
+ $text_found = false;
}
+ $this->assertTextNode( "sha1", $text_sha1 );
- if ( $this->xml->name == "format" ) { // format tag is optional
- $this->assertTextNode( "format", CONTENT_FORMAT_WIKITEXT ); //@todo: make this a test parameter
- $this->skipWhitespace();
+ $this->assertTextNode( "model", $model );
+ $this->skipWhitespace();
+
+ $this->assertTextNode( "format", $format );
+ $this->skipWhitespace();
+
+ if ( !$text_found ) {
+ $this->assertText( $id, $text_id, $text_bytes, $text );
}
- $this->assertTextNode( "sha1", $text_sha1 );
+ $this->assertNodeEnd( "revision" );
+ $this->skipWhitespace();
+ }
+ protected function assertText( $id, $text_id, $text_bytes, $text ) {
$this->assertNodeStart( "text", false );
if ( $text_bytes !== false ) {
$this->assertEquals( $this->xml->getAttribute( "bytes" ), $text_bytes,
$this->assertNodeEnd( "text" );
$this->skipWhitespace();
}
-
- $this->assertNodeEnd( "revision" );
- $this->skipWhitespace();
}
-
-}
+}
\ No newline at end of file
<comment>BackupDumperTestP1Summary1</comment>
<text xml:space="preserve">BackupDumperTestP1Text1</text>
<sha1>0bolhl6ol7i6x0e7yq91gxgaan39j87</sha1>
+ <model name="wikitext">1</model>
+ <format mime="text/x-wiki">1</format>
</revision>
</page>
';
<comment>BackupDumperTestP2Summary1</comment>
<text xml:space="preserve">BackupDumperTestP2Text1</text>
<sha1>jprywrymfhysqllua29tj3sc7z39dl2</sha1>
+ <model name="wikitext">1</model>
+ <format mime="text/x-wiki">1</format>
</revision>
<revision>
<id>5</id>
<comment>BackupDumperTestP2Summary4 extra</comment>
<text xml:space="preserve">BackupDumperTestP2Text4 some additional Text</text>
<sha1>6o1ciaxa6pybnqprmungwofc4lv00wv</sha1>
+ <model name="wikitext">1</model>
+ <format mime="text/x-wiki">1</format>
</revision>
</page>
';
<comment>Talk BackupDumperTestP1 Summary1</comment>
<text xml:space="preserve">Talk about BackupDumperTestP1 Text1</text>
<sha1>nktofwzd0tl192k3zfepmlzxoax1lpe</sha1>
+ <model name="wikitext">1</model>
+ <format mime="text/x-wiki">1</format>
</revision>
</page>
';
</contributor>
<comment>BackupDumperTestP1Summary1</comment>
<sha1>0bolhl6ol7i6x0e7yq91gxgaan39j87</sha1>
+ <model name="wikitext">1</model>
+ <format mime="text/x-wiki">1</format>
<text id="' . $this->textId1_1 . '" bytes="23" />
</revision>
</page>
</contributor>
<comment>BackupDumperTestP2Summary1</comment>
<sha1>jprywrymfhysqllua29tj3sc7z39dl2</sha1>
+ <model name="wikitext">1</model>
+ <format mime="text/x-wiki">1</format>
<text id="' . $this->textId2_1 . '" bytes="23" />
</revision>
<revision>
</contributor>
<comment>BackupDumperTestP2Summary2</comment>
<sha1>b7vj5ks32po5m1z1t1br4o7scdwwy95</sha1>
+ <model name="wikitext">1</model>
+ <format mime="text/x-wiki">1</format>
<text id="' . $this->textId2_2 . '" bytes="23" />
</revision>
<revision>
</contributor>
<comment>BackupDumperTestP2Summary3</comment>
<sha1>jfunqmh1ssfb8rs43r19w98k28gg56r</sha1>
+ <model name="wikitext">1</model>
+ <format mime="text/x-wiki">1</format>
<text id="' . $this->textId2_3 . '" bytes="23" />
</revision>
<revision>
</contributor>
<comment>BackupDumperTestP2Summary4 extra</comment>
<sha1>6o1ciaxa6pybnqprmungwofc4lv00wv</sha1>
+ <model name="wikitext">1</model>
+ <format mime="text/x-wiki">1</format>
<text id="' . $this->textId2_4 . '" bytes="44" />
</revision>
</page>
</contributor>
<comment>Talk BackupDumperTestP1 Summary1</comment>
<sha1>nktofwzd0tl192k3zfepmlzxoax1lpe</sha1>
+ <model name="wikitext">1</model>
+ <format mime="text/x-wiki">1</format>
<text id="' . $this->textId4_1 . '" bytes="35" />
</revision>
</page>